Summary
OpenClaw versions prior to 2026.2.14 contain a path traversal vulnerability in the apply_patch functionality that can be abused to read, write, or delete files outside the intended workspace directory.
When filesystem sandboxing or path containment is not enforced, crafted patch paths using traversal sequences or absolute paths may allow attackers to escape the workspace boundary and tamper with arbitrary files on the host.
Affected context
This vulnerability arises in OpenClaw deployments where the apply_patch feature is enabled and is expected to operate only within a designated workspace directory.
It is particularly relevant in environments that:
- Accept patch content or filenames from remote or untrusted sources
- Do not enforce OS-level sandboxing (e.g., chroot, containers with strict mounts, or mandatory access control)
- Rely solely on logical path checks to keep file operations inside a workspace
In such setups, path components embedded in patches can be interpreted relative to the host filesystem rather than being constrained to the configured workspace root.
Exploit preconditions
- Attack surface: The apply_patch interface (e.g., API endpoints, automation hooks, or services) that accepts file paths or patch content.
- Required access: Ability to submit or influence patch data processed by apply_patch (such as authenticated user input, CI integration, or compromised upstream service).
- Trigger point: Processing of a patch that references paths containing directory traversal sequences (
../) or absolute paths. - Why exploitation is possible: The path handling logic does not canonicalize and revalidate paths against the workspace root, nor does it robustly reject paths escaping that root. As a result, normalized paths can point to locations outside the configured workspace, enabling writes or deletions on arbitrary filesystem targets permitted by the OpenClaw process privileges.
Why this happens
The core issue maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
The apply_patch implementation trusts path segments supplied through patch metadata and uses them directly (or with incomplete normalization) when constructing filesystem paths.
Without strict resolution of relative components (. and ..), removal of symbolic links, and enforcement that the final canonical path remains within the workspace root, an attacker can construct paths that traverse out of the intended directory tree.
This design assumes that paths in patches are benign and implicitly scoped, rather than treating them as untrusted input that must be constrained to a safe subtree.
Potential impact
- Modification of configuration files outside the intended workspace, which may change application behavior or security controls.
- Deletion of critical files on the host accessible to the OpenClaw process, potentially causing denial of service.
- Overwriting scripts, binaries, or libraries to facilitate code execution under the OpenClaw service account.
- Corruption or unauthorized alteration of build artifacts, logs, or source code in adjacent directories.
- Escalation of impact when combined with other misconfigurations, such as over-privileged service accounts or shared host paths in containerized environments.
General mitigation guidance
Effective mitigation focuses on strictly confining all file operations to an intended directory and reducing the trust placed in incoming path data.
Path handling and confinement patterns:
- Resolve all user-controlled or patch-provided paths using canonicalization (e.g., resolving
..,., and symbolic links) before any filesystem operation. - After canonicalization, enforce that the resulting absolute path is a descendant of the configured workspace root; reject or fail closed when this check fails.
- Disallow absolute paths and paths containing traversal sequences at the validation layer rather than trying to silently fix them.
Sandboxing and privilege constraints:
- Run OpenClaw components that handle apply_patch within a restricted filesystem view (e.g., container with minimal mounts, chroot-like environments, or per-workspace sandboxes).
- Apply least privilege principles to the OpenClaw process account so it can only write and delete in directories that are part of the trusted workspace.
Input validation and configuration practices:
- Treat patch metadata and file paths as untrusted input, even when coming from upstream automated tools.
- Provide configuration options that default apply_patch to safe behavior, such as enforcing a non-relaxable workspace root and disabling writes outside it.
How teams detect issues like this
Detecting and monitoring for this class of issue generally combines code-level review with runtime observation.
Static and code review approaches:
- Review apply_patch and related file handling code for:
- Direct concatenation of user-influenced strings into filesystem paths.
- Absence of canonicalization and lack of checks that paths remain under the workspace root.
- Handling of absolute paths or segments containing
... - Use static analysis tools configured with rules for path traversal patterns, highlighting calls to file APIs where parameters may contain untrusted path segments.
Runtime and operational monitoring:
- Enable file access auditing for the OpenClaw process to detect unexpected writes or deletions outside the configured workspace directories.
- Implement policy-based controls (e.g., AppArmor, SELinux, or container security profiles) to restrict filesystem access and generate alerts on policy violations.
- Log and analyze rejected patches or suspicious path usage patterns to identify attempted exploitation.
Process and policy enforcement:
- Integrate secure coding guidelines for path handling into development standards and CI checks.
- Apply pre-commit or CI linters that flag path manipulations lacking explicit root confinement checks.

