Summary
OpenClaw's browser control API accepts user-supplied output paths for trace and download files without reliably constraining them to temporary directories, enabling path traversal.
Attackers with API access can craft paths that escape intended temp roots via POST /trace/stop, POST /wait/download, and POST /download endpoints, potentially writing files to arbitrary locations on the host filesystem.
Affected context
This vulnerability appears in OpenClaw deployments that expose the browser control API and allow clients to specify file output locations for traces and downloads.
It is relevant where:
- The API is reachable to untrusted or semi-trusted callers
- The server runs with permissions that grant write access beyond the intended temp directories
- File path handling does not robustly normalize and validate user-supplied paths before use
Environments that colocate OpenClaw with sensitive application code, configuration, or shared volumes are at higher risk from arbitrary file writes.
Exploit preconditions
- Attack surface: OpenClaw browser control HTTP API, specifically:
- POST /trace/stop
- POST /wait/download
- POST /download
- Required access: Ability to issue authenticated or otherwise accepted API requests to these endpoints (e.g., API key, session, or network access depending on deployment).
- Trigger point: Supplying a crafted output path parameter that includes path traversal sequences or absolute paths when requesting trace stop or file download operations.
- Why exploitation is possible: The server trusts user-supplied file paths and does not consistently enforce confinement to a temporary directory or a safe root.
Insufficient normalization and validation allow traversal components (e.g., parent directory references) or absolute paths to be interpreted by the filesystem API, resulting in writes outside the intended temp roots.
Why this happens
The underlying issue is improper restriction of user-controlled file paths before they are used for filesystem writes, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Instead of treating output paths as untrusted data that must be constrained to a known-safe directory, the implementation accepts user-supplied values and passes them to file creation or write routines without robust checks.
Missing or inconsistent normalization, canonicalization, and enforcement of a dedicated output root allows attacker-controlled paths to escape the designated temp directory structure.
Conceptually, this is a broken filesystem boundary: user input is directly influencing where on disk an operation is performed, without a security gate that validates the final canonical path remains within an allowed subtree.
Potential impact
- Arbitrary file creation or overwrite in directories writable by the OpenClaw process
- Overwriting application configuration files, logs, or other operational data, which can affect integrity or availability
- Placement of malicious scripts, serialized objects, or configuration that may later be executed or interpreted by other services (indirect code execution scenarios)
- Persistence mechanisms, such as dropping files into locations that are backed up, synchronized, or consumed by background jobs
- Expanded attack surface when combined with other vulnerabilities that read or execute attacker-controlled files
General mitigation guidance
Effective mitigation centers on strictly confining file writes to controlled directories and treating all path components derived from clients as untrusted:
- Introduce a fixed, server-controlled root directory for all trace and download outputs; never allow clients to specify absolute paths.
- Normalize and canonicalize requested paths (e.g., resolving ".." and symbolic links) before use, then verify the resulting canonical path resides within the approved root directory.
- Restrict accepted filenames to a minimal character set and structure (e.g., no directory separators) and combine them with server-side directory paths instead of using full paths from clients.
- Avoid reusing user-supplied paths for anything other than basic filenames; derive full storage paths on the server using configuration and internal logic.
- Run the OpenClaw service with least-privilege filesystem permissions, limiting the damage if path validation fails (e.g., confined service accounts, dedicated volumes).
- Enforce defense-in-depth via OS-level controls such as containerization, chroot-like environments, or filesystem sandboxing where appropriate.
How teams detect issues like this
Detection can focus on both code-level patterns and runtime behavior:
- Static analysis and code review:
- Flag any usage of user-controlled parameters that are passed into file open, write, or create functions without clear normalization and root directory enforcement.
- Look for APIs that accept full file paths from callers, particularly in HTTP handlers for download, trace, or export functionality.
- Verify that canonicalization checks compare the final resolved path against a known-safe root directory.
- Automated tooling and policies:
- Apply static analysis rules or linters targeting CWE-22, highlighting string concatenation with filesystem paths based on input parameters.
- Use security-focused code scanning tools integrated into CI to enforce path validation requirements around I/O operations.
- Runtime monitoring:
- Monitor filesystem activity from the OpenClaw process and alert on writes to unexpected directories, especially outside designated temp or data roots.
- Inspect access logs for suspicious file path patterns (e.g., repeated "../" sequences) in API requests to /trace/stop, /wait/download, and /download.

