Summary
OpenClaw before 2026.3.24 contains a path traversal flaw in its sandbox enforcement logic that lets sandboxed agents read files outside their permitted workspace.
By abusing unnormalized mediaUrl or fileUrl parameters and gaps in sandbox root validation, an attacker-controlled agent can access arbitrary files from other agents' workspaces, including sensitive configuration and API key material.
Affected context
This vulnerability arises in OpenClaw deployments that use sandboxed agents with separated workspaces and rely on mediaUrl or fileUrl parameters for media or file access.
It affects code paths that invoke normalizeSandboxMediaParams to enforce sandbox boundaries but do not correctly validate or reconstruct paths against mediaLocalRoots or equivalent sandbox root context.
The risk is elevated when agent workspaces contain secrets such as API keys, access tokens, or environment-specific configuration files.
Exploit preconditions
- Attack surface: Interfaces (APIs, queues, or control planes) that allow an attacker to run or control a sandboxed agent and influence
mediaUrl/fileUrlvalues. - Required access: Ability to submit or modify tasks, jobs, or agent configurations such that the agent processes attacker-controlled
mediaUrlorfileUrlparameters. - Trigger point: Any code path that calls
normalizeSandboxMediaParamsor related media/file access helpers without strict normalization and root checks, eventually resolving local file paths. - Why exploitation is possible:
- Paths derived from
mediaUrl/fileUrlare insufficiently normalized. - Validation logic does not robustly prevent
.., absolute paths, or crafted encodings from escaping the intended sandbox root. - Missing or incomplete
mediaLocalRootscontext means the system cannot reliably enforce "stay under this directory" constraints. - The sandbox relies on application-level path checks rather than a fully enforced OS-level or container-level isolation boundary for file reads.
Why this happens
The underlying bug is a classic path traversal issue where user-controllable parameters are turned into file system paths without strict normalization and containment checks.
In OpenClaw, normalizeSandboxMediaParams is expected to enforce sandbox boundaries but does not fully sanitize or canonicalize the mediaUrl / fileUrl input before using it to locate files.
Additionally, missing or misapplied mediaLocalRoots context means the code cannot reliably assert that the resolved path stays within a designated sandbox root directory.
This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where an attacker supplies crafted path components (e.g., directory traversal sequences or encoded variants) that bypass naive validation and reach files outside the intended directory tree.
Potential impact
- Access to other agents' workspace files, including logs, artifacts, or intermediate data.
- Exposure of API keys, secrets, and configuration files stored within or adjacent to agent workspaces.
- Discovery of environment-specific details (endpoints, credentials, feature flags) that could support broader compromise.
- Violation of multi-tenant isolation promises, enabling a noisy neighbor to read another tenant's data.
- Potential chaining with other flaws (e.g., if sensitive files contain tokens usable for remote access or privilege escalation elsewhere).
General mitigation guidance
Effective mitigation focuses on robust path handling and stronger sandbox boundaries rather than ad hoc filters on input parameters.
Path handling and validation patterns:
- Convert all incoming path-like data from
mediaUrl/fileUrlinto canonical, absolute paths before validation, resolving symbolic links where feasible. - Enforce a strict "must be under this directory" policy by checking that the canonical path has the sandbox root as its prefix, rejecting any path that escapes this root.
- Reject or ignore paths containing traversal patterns (
.., ambiguous separators) or malformed encodings, rather than attempting partial cleanup. - Prefer constructing paths from vetted identifiers (IDs, handles) mapped to known locations instead of accepting arbitrary relative or absolute paths from clients.
Sandbox and privilege patterns:
- Maintain clear, explicit
mediaLocalRoots(or equivalent) for each agent or tenant, and ensure all file access helpers receive and enforce this context. - Run agents with least-privilege file system access so that, even if logic fails, the process cannot read outside its designated directories.
- Avoid co-locating high-value secrets in the same file system namespace as agent workspaces; use dedicated secret stores or separate mounts with tighter ACLs.
- Treat all agent-supplied URLs and file parameters as untrusted input, applying the same scrutiny as external user input.
How teams detect issues like this
Organizations can detect this class of issue through a combination of code-level analysis and runtime monitoring.
Static and code review approaches:
- Search for direct or indirect usage of
mediaUrl,fileUrl, or similar parameters that are passed to file APIs (open, read, stat) or media handlers. - Flag any code that constructs file paths from user-controlled pieces without:
- Canonicalization (e.g., using platform-specific realpath/resolution), and
- An explicit check that the resulting path is under a defined sandbox root.
- Review implementations of
normalizeSandboxMediaParamsand related helpers to ensure they: - Operate on canonical paths,
- Use configured
mediaLocalRootsfor containment checks, and - Fail closed (rejecting input) on abnormal path patterns.
- Apply static analysis rules or security linters that detect suspicious concatenation of untrusted input with file system paths.
Runtime and operational approaches:
- Configure logs to capture suspicious
mediaUrl/fileUrlvalues (e.g., containing.., unusual encodings, or absolute paths) for anomaly detection. - Monitor file access logs or OS-level audit trails for agents reading outside their expected workspace directories.
- Integrate automated security tests or fuzzers that supply crafted path values to APIs handling media or files, verifying they cannot escape sandbox roots.

