Summary
OpenClaw through 2026.3.23 contains a path traversal flaw in its media parsing logic that allows attackers to read arbitrary files on the host system by bypassing path validation in isLikelyLocalPath() and isValidMedia().
When an attacker can supply or influence media paths, they may escape the intended sandbox via incomplete validation and the allowBareFilename bypass, leading to disclosure of sensitive files such as system configs, environment files, and SSH keys.
Affected context
This vulnerability affects OpenClaw deployments that accept media paths or references from external or semi-trusted sources (e.g., user uploads, configuration, or remote content descriptors).
The issue lies in the media parsing layer, where file paths are checked for locality and validity using isLikelyLocalPath() and isValidMedia(), but the checks are incomplete.
In environments where the application is assumed to operate within a restricted media directory or sandbox, the allowBareFilename behavior can permit references that resolve to files outside that intended boundary.
Exploit preconditions
- Attack surface: Any feature that accepts or processes media paths (file references, URLs, or similar) through OpenClaw's media parsing.
- Required access: Ability to control or influence the media path input (e.g., authenticated or unauthenticated HTTP requests, API parameters, or configuration fields, depending on deployment).
- Trigger point: Invocation of media parsing routines that call
isLikelyLocalPath()andisValidMedia()with attacker-controlled paths. - Why exploitation is possible: Path validation is incomplete, and the
allowBareFilenamelogic can be abused to craft traversal sequences that are not properly normalized or rejected, allowing paths that reference files outside the intended sandbox.
Why this happens
The core issue is an inadequate implementation of path validation and canonicalization, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
The isLikelyLocalPath() and isValidMedia() functions attempt to enforce that media paths are local and safe, but their checks can be bypassed due to incomplete normalization, inconsistent handling of relative components, and special-casing such as allowBareFilename.
Conceptually, the bug stems from relying on heuristic or pattern-based checks instead of deriving a canonical path and strictly enforcing that it resides within a predefined directory root, leading to trust in user-influenced paths that can escape the intended sandbox.
Potential impact
- Disclosure of application configuration files that may contain secrets or database credentials
- Exposure of system configuration files (e.g., password or service configuration stores)
- Reading environment files that may include API keys, tokens, or other sensitive metadata
- Access to private SSH keys and related authentication material stored on the host
- Increased ability to pivot to other attacks by harvesting sensitive information (e.g., credentials reuse in other services)
General mitigation guidance
Effective mitigation focuses on strict path normalization and enforcement of directory boundaries, rather than heuristic checks:
- Resolve all user-influenced paths to their canonical (absolute, normalized) form before use, removing
..and other relative components. - Enforce that all media paths resolve within a designated, fixed media root directory; reject or log any path that attempts to escape this root.
- Avoid special flags like
allowBareFilenamethat change validation behavior without re-verifying containment in the sandbox. - Treat any externally supplied path segments as untrusted, regardless of whether they look "local" or "benign".
- Consider running the media handling component with minimal file-system privileges and isolating media storage from sensitive directories.
- Apply a deny-by-default approach for file access, explicitly whitelisting directories or patterns that are intended to be accessible.
How teams detect issues like this
Organizations can identify this class of issues using a combination of automated and manual approaches:
- Static analysis: Create rules that flag any use of file-system APIs where paths are derived from external input without canonicalization and strict directory checks.
- Code review: Look for custom path validators such as
isLikelyLocalPath()andisValidMedia()that rely on string matching (prefix/suffix checks, simple regexes) instead of canonical path containment checks. - Security testing: Use dynamic analysis or fuzzing to provide crafted media paths containing traversal sequences (
../, nested directories, symlink abuse) and monitor whether the application returns unexpected file contents. - Policy enforcement: Incorporate secure file-access patterns into coding standards, and enforce them via pre-commit hooks or CI pipeline checks (including generalized SAST or custom linters).

