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
| Source | Link |
|---|---|
| gist. | gist.github.com/ |
| github. | github.com/ |

