/

CVE-2026-51852

Severity:

HIGH RISK

(7.5)

Directory Traversal (CWE-22) in agent-zero FileBrowser

CVE-2026-51852

Deferred

Vulnerability type

Category:

Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

HIGH RISK

(7.5)

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

A directory traversal vulnerability in agent-zero's FileBrowser.save_file_b64 method allows user-controlled paths to be used without sufficient normalization or validation. An attacker who can reach this file-saving functionality may write base64-decoded content outside the intended directory by supplying traversal sequences.

A directory traversal vulnerability in agent-zero's FileBrowser.save_file_b64 method allows user-controlled paths to be used without sufficient normalization or validation. An attacker who can reach this file-saving functionality may write base64-decoded content outside the intended directory by supplying traversal sequences.

Affected context

The issue occurs in deployments that expose or invoke the save_file_b64 functionality with paths influenced by untrusted users. Risk is higher when the process has write access to sensitive application, configuration, or system locations and when the destination path is not constrained to an approved directory.

The issue occurs in deployments that expose or invoke the save_file_b64 functionality with paths influenced by untrusted users. Risk is higher when the process has write access to sensitive application, configuration, or system locations and when the destination path is not constrained to an approved directory.

Exploit preconditions

  • Attack surface: The file browser or another application path that invokes FileBrowser.save_file_b64
  • Required access: Ability to submit or influence the file path and encoded file content
  • Trigger point: File saving after the method receives the user-controlled path
  • Why exploitation is possible: The supplied path is accepted without adequate canonicalization, boundary checks, or validation against an allowed storage directory
  • Attack surface: The file browser or another application path that invokes FileBrowser.save_file_b64
  • Required access: Ability to submit or influence the file path and encoded file content
  • Trigger point: File saving after the method receives the user-controlled path
  • Why exploitation is possible: The supplied path is accepted without adequate canonicalization, boundary checks, or validation against an allowed storage directory

Why this happens

The underlying bug is improper limitation of a pathname to an intended directory, which maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The method uses a user-controlled path for file creation without reliably normalizing the path and verifying that its resolved location remains within an approved base directory.

The underlying bug is improper limitation of a pathname to an intended directory, which maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The method uses a user-controlled path for file creation without reliably normalizing the path and verifying that its resolved location remains within an approved base directory.

Potential impact

  • An attacker may overwrite or create files outside the intended upload directory
  • Application configuration or data files could be modified
  • The service may experience denial of service through destructive or invalid file writes
  • Sensitive files could be affected if the process has sufficient filesystem permissions
  • Arbitrary file write may contribute to code execution in environments with writable executable or startup locations
  • An attacker may overwrite or create files outside the intended upload directory
  • Application configuration or data files could be modified
  • The service may experience denial of service through destructive or invalid file writes
  • Sensitive files could be affected if the process has sufficient filesystem permissions
  • Arbitrary file write may contribute to code execution in environments with writable executable or startup locations

General mitigation guidance

Mitigation generally focuses on reducing path trust and enforcing a strict storage boundary.

Common defensive patterns include:

  • Resolve and normalize candidate paths before use, then verify they remain beneath an approved base directory
  • Prefer server-generated opaque filenames over user-supplied filesystem paths
  • Reject traversal indicators, absolute paths, alternate separators, and symbolic-link escapes as defense-in-depth controls
  • Store uploads in a dedicated directory with restrictive permissions and avoid placing them in executable or configuration locations
  • Apply least-privilege filesystem access to the service account
  • Validate file type, size, and destination policy independently of path validation

Mitigation generally focuses on reducing path trust and enforcing a strict storage boundary.

Common defensive patterns include:

  • Resolve and normalize candidate paths before use, then verify they remain beneath an approved base directory
  • Prefer server-generated opaque filenames over user-supplied filesystem paths
  • Reject traversal indicators, absolute paths, alternate separators, and symbolic-link escapes as defense-in-depth controls
  • Store uploads in a dedicated directory with restrictive permissions and avoid placing them in executable or configuration locations
  • Apply least-privilege filesystem access to the service account
  • Validate file type, size, and destination policy independently of path validation

How teams detect issues like this

Organizations can identify related issues through:

  • Static analysis rules for filesystem APIs that combine user input with path construction
  • Code review checks for missing canonicalization, containment validation, or allowlisted storage roots
  • Tests using normalized and non-normalized path variants, including absolute paths and alternate separators
  • Runtime monitoring for writes outside approved application data directories
  • Policy enforcement that restricts service accounts from writing to sensitive or executable locations

Automated security review tools may help flag path concatenation and untrusted filename flows, but findings should be verified against the deployment's filesystem boundaries.

Organizations can identify related issues through:

  • Static analysis rules for filesystem APIs that combine user input with path construction
  • Code review checks for missing canonicalization, containment validation, or allowlisted storage roots
  • Tests using normalized and non-normalized path variants, including absolute paths and alternate separators
  • Runtime monitoring for writes outside approved application data directories
  • Policy enforcement that restricts service accounts from writing to sensitive or executable locations

Automated security review tools may help flag path concatenation and untrusted filename flows, but findings should be verified against the deployment's filesystem boundaries.

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/13af0869833757245685d2d390458664
github.comgithub.com/agent0ai/agent-zero/issues/1540

Frequently asked

questions

It may be remotely exploitable when the file-saving functionality is exposed through an accessible application interface and accepts attacker-influenced paths.

The attacker generally needs access to a workflow that invokes save_file_b64 and permits control over the destination path. Authentication and authorization requirements depend on the surrounding application.

Use server-controlled filenames and a dedicated storage root, then canonicalize the resulting path and enforce that it remains within that root before writing.

Treat all path components as untrusted, enforce least-privilege filesystem permissions, test traversal variants, and apply code-review or static-analysis policies to path construction and file-write operations.

It may be remotely exploitable when the file-saving functionality is exposed through an accessible application interface and accepts attacker-influenced paths.

The attacker generally needs access to a workflow that invokes save_file_b64 and permits control over the destination path. Authentication and authorization requirements depend on the surrounding application.

Use server-controlled filenames and a dedicated storage root, then canonicalize the resulting path and enforce that it remains within that root before writing.

Treat all path components as untrusted, enforce least-privilege filesystem permissions, test traversal variants, and apply code-review or static-analysis policies to path construction and file-write operations.

Find out what's already
exploitable in your codebase.