/

CVE-2026-40518

Severity:

HIGH RISK

(7.1)

Path Traversal in ByteDance DeerFlow Bootstrap Custom-Agent

CVE-2026-40518

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write and Filesystem Manipulation

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

ByteDance DeerFlow before commit 2176b2b contains a path traversal flaw in the bootstrap-mode custom-agent creation flow, where the agent name is insufficiently validated.

An attacker who can create or influence custom agents can supply traversal-style or absolute paths as the agent name, causing directories and files to be written outside the intended custom-agent directory and potentially achieving arbitrary file write within the bounds of filesystem permissions.

Affected context

This vulnerability occurs in DeerFlow deployments that:

  • Use the bootstrap-mode flow for creating custom agents, and
  • Rely on the agent name to derive filesystem paths and directories.

The issue is present where user-controlled agent names are used to construct paths without robust normalization and restriction to a fixed base directory. It becomes relevant wherever untrusted or semi-trusted users can trigger custom-agent creation or influence the agent name field.

Exploit preconditions

  • Attack surface: DeerFlow bootstrap-mode custom-agent creation endpoint, API, or UI.
  • Required access: Ability to initiate or modify custom-agent creation, including control over the agent name parameter.
  • Trigger point: Submission of an agent name containing .., path separators, or absolute paths during bootstrap-mode setup.
  • Why exploitation is possible: The system concatenates or resolves the agent name into filesystem paths without sufficient canonicalization and enforcement of a restricted root directory, allowing directory traversal and file creation outside the intended custom-agent directory, subject to OS-level permissions.

Why this happens

The core issue is improper restriction of a path used to access the filesystem, aligning with CWE-22.

An input field (agent name) that should represent a logical identifier is instead used directly or with minimal validation to construct filesystem paths. Without rigorous normalization and checks that the resulting path stays inside an allowed base directory, attackers can inject .. segments or absolute paths to traverse out of the intended directory tree. This insecure pattern allows influence over where directories and files are created or modified, transforming a naming parameter into a path control primitive.

Potential impact

  • Creation or overwriting of files outside the designated custom-agent directory, where filesystem permissions allow.
  • Manipulation of configuration files that could alter application behavior.
  • Planting of web-accessible or service-consumed files that may enable indirect code execution, if other components load or execute them.
  • Log or data tampering, potentially impacting auditability and integrity of stored information.
  • Escalation of impact when combined with other vulnerabilities (e.g., components that execute or interpret written files).

General mitigation guidance

Effective mitigation centers on strictly separating identifiers from filesystem paths and enforcing robust path normalization:

  • Treat the agent name as data, not a path: map it to a safe internal identifier or sanitize it to a limited character set (e.g., alphanumerics, underscores, hyphens).
  • When constructing paths, always join the sanitized identifier with a pre-defined, constant base directory, and canonicalize the result (e.g., via realpath-style resolution).
  • Enforce that the canonicalized path remains within the intended base directory; reject or log and block any operation where it escapes this root.
  • Avoid honoring absolute paths or path separators in user-controlled fields; strip or reject them at validation time.
  • Apply least-privilege filesystem permissions to the process, restricting the directories it can write to and limiting the impact of any traversal that might still occur.

How teams detect issues like this

Detection can focus on both code-level patterns and runtime behavior:

  • Static analysis rules that flag concatenation of user-controlled input (such as agent names) into filesystem paths without canonicalization or base-directory checks.
  • Code review checklists that explicitly ask whether all file operations involving user input enforce a restricted root directory and validate against traversal.
  • Centralized logging of file creation and write operations from the DeerFlow process, with alerts for accesses outside expected directories (e.g., custom-agent root).
  • CI/CD policy enforcement that scans for unsafe filesystem usage patterns and blocks merges when path traversal risks are detected.

Automated code review and SAST tools can be configured to identify typical CWE-22 indicators, such as use of ..-prone inputs or lack of path normalization logic.

Sources

SourceLink
github.comgithub.com/bytedance/deer-flow/commit/2176b2bbfccfce25ceee08318813f96d843a13fd
github.comgithub.com/bytedance/deer-flow/pull/2274
vulncheck.comvulncheck.com/advisories/bytedance-deerflow-path-traversal-and-arbitrary-file-write-via-bootstrap-mode

Frequently asked

questions

It can be, if the custom-agent creation functionality is exposed over a network interface or API to remote users. Exploitability depends on how broadly the bootstrap-mode and agent creation endpoints are exposed and authenticated.

The attacker must be able to create or influence custom agents, specifically controlling the agent name field. This could be through a web UI, API, or scriptable interface, depending on the deployment.

The most robust pattern is to treat the agent name strictly as an identifier, sanitize it to a safe character set, and map it to file paths using a fixed base directory with canonicalization and enforcement that the resulting path does not leave that directory. Reject any input that attempts to introduce path separators, .. segments, or absolute paths.

Adopt a consistent design where user input is never treated as a raw path. Enforce path normalization and root-directory containment checks for all filesystem operations derived from user data, incorporate CWE-22 checks into code review and static analysis rules, and restrict process filesystem permissions so that even if a mistake occurs, the reachable damage is minimized.

Find out what's already
exploitable in your codebase.