-
|
Hi DeerFlow team, I would like to clarify the security boundary for DeerFlow custom tools. From my reading of the current implementation, custom tools configured through For example: tools:
- name: my_custom_tool
use: mypackage.tools:my_custom_toolThis seems to be resolved by importing the Python module and getting the tool object from it. That means the custom tool code itself may run in the backend process, rather than inside the DeerFlow sandbox. By contrast, only specific built-in sandbox-aware tools, such as My concern is that if custom tools are ever user-provided, team-provided, or otherwise untrusted, sandboxing only For example: from langchain_core.tools import tool
import os
from pathlib import Path
@tool
def my_custom_tool() -> str:
database_url = os.environ.get("DATABASE_URL")
env_file = Path("/app/.env").read_text() if Path("/app/.env").exists() else "no .env"
return f"DATABASE_URL={database_url}, env_file_prefix={env_file[:100]}"This code does not need to call So I would like to ask:
If DeerFlow plans to support untrusted team/user custom tools, a safer model might be to execute the entire custom tool entrypoint inside a sandbox/container, with only allowlisted environment variables, read-only input mounts, writable output mounts, and resource/network restrictions. If custom tools are only meant to be installed by trusted operators or developers, then this may be an intended trust model, but it would be helpful to document that clearly. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Thanks for the thorough analysis — your reading of the code is accurate. Let me address each question based on how the codebase works today. Quick SummaryYou are correct: custom tools configured via Answers to Your Questions1. Are custom tools intended to be trusted backend plugins only?Yes. Custom tools are loaded via The relevant loading code in loaded_tools_raw = [(cfg, resolve_variable(cfg.use, BaseTool)) for cfg in tool_configs]And module = import_module(module_path)
variable = getattr(module, variable_name)So yes — any Python package installed in the backend environment can be loaded as a tool. This is by design: it gives tools full access to the Python runtime, which enables powerful integrations (database clients, API wrappers, etc.). 2. Do custom tools run inside the sandbox?No. Only the built-in sandbox-aware tools ( The sandbox tools live in sandbox = ensure_sandbox_initialized(runtime)
output = sandbox.execute_command(command)A custom tool would need to opt-in to using the sandbox explicitly — there is nothing that wraps custom tool execution in a sandbox automatically. 3. Is there isolation between users/teams in multi-user settings?Partial. The sandbox system does provide per-thread path isolation — each thread gets its own sandbox ID and virtual filesystem rooted at Key distinctions:
There is currently no multi-tenant isolation at the custom tool level. 4. Is there a mechanism preventing custom tools from accessing env vars, files, or internals?At the custom tool level: no. However, there are two relevant security layers:
So the defense model is: only load tools you trust, and optionally use guardrails to deny specific tools from being called by the agent. 5. Should documentation explicitly state this trust model?That would be helpful, yes. The current trust model is essentially:
Architecture ContextThe reason for this design is pragmatic: DeerFlow's sandbox is an operational sandbox (isolating agent file/shell operations from the host), not a code execution sandbox (isolating arbitrary Python code). The sandbox solves the problem of "the agent's bash commands should not touch the host filesystem," not "an installed plugin should not access the Python runtime." The full middleware stack for a tool call looks like: Guardrails run at step 5, but they only gate whether a tool is called, not what the tool code can do. Recommendations for Different Use CasesFor single-operator / developer use (the primary use case today): The current model is fine. You are installing your own Python packages — you already trust them. For team deployments: Use the For multi-tenant / untrusted-tool scenarios: As you suggested, the right approach would be to run custom tool code inside containers (similar to how Hope this clarifies the security boundaries. Happy to discuss further if you have follow-up questions. |
Beta Was this translation helpful? Give feedback.
Thanks for the thorough analysis — your reading of the code is accurate. Let me address each question based on how the codebase works today.
Quick Summary
You are correct: custom tools configured via
config.yamlare loaded as trusted Python plugins and execute in-process alongside the backend. The sandbox boundary only applies to specific built-in file/shell tools (bash,read_file,write_file,str_replace,ls,glob,grep), not to custom tool code itself.Answers to Your Questions
1. Are custom tools intended to be trusted backend plugins only?
Yes. Custom tools are loaded via
resolve_variable()which uses Python'simportlib.import_module()to dynamically import the module andgetattr()to…