Summary
OpenClaw mirror mode before version 2026.4.2 contains a path traversal-style configuration flaw that can lead to arbitrary remote directory deletion.
By manipulating the remoteWorkspaceDir and remoteAgentWorkspaceDir configuration values, an attacker can cause mirror sync operations to delete unintended directories and replace their contents with attacker-controlled workspace data.
Affected context
This vulnerability appears in OpenClaw deployments that use mirror mode with configurable remote workspace paths.
The issue becomes relevant when:
- The OpenShell configuration allows user-provided or loosely validated values for remoteWorkspaceDir and remoteAgentWorkspaceDir
- The mirror sync feature is enabled to keep local and remote workspaces aligned
- The system trusts these configured paths without enforcing strict boundaries (e.g., a fixed root directory)
Under these conditions, crafted configuration values can redirect delete and sync operations to unintended locations on the remote system.
Exploit preconditions
- Attack surface: OpenClaw/OpenShell configuration for mirror mode and associated remote workspace paths.
- Required access: Ability to modify or influence remoteWorkspaceDir and/or remoteAgentWorkspaceDir (e.g., via configuration files, UI settings, environment variables, or API-controlled config).
- Trigger point: Execution of a mirror synchronization operation that:
- Deletes remote contents assumed to be part of the workspace, and
- Replaces them with the local or uploaded workspace data.
- Why exploitation is possible: The product does not sufficiently constrain or normalize the remote workspace paths before using them in deletion and synchronization routines, allowing attacker-controlled paths to point to directories outside the intended workspace boundary.
Why this happens
The core issue maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
OpenClaw trusts the configured remoteWorkspaceDir and remoteAgentWorkspaceDir as safe root locations for mirror operations without:
- Enforcing that these paths remain under a specific allowed directory tree, or
- Applying robust normalization and validation to remove traversal sequences or unsafe values.
As a result, delete-and-sync logic operates on attacker-directed paths and can recursively remove directory contents in arbitrary remote locations, effectively turning a workspace sync into a powerful deletion and overwrite primitive.
Potential impact
- Deletion of arbitrary directories on the remote host that are accessible to the OpenClaw agent.
- Overwrite of remote directories with attacker-controlled workspace data, leading to data corruption.
- Disruption of services whose configuration, logs, or data directories are targeted.
- Loss of integrity for build artifacts, deployment assets, or shared project files stored on the remote system.
- Potential stepping stone to broader operational impact if critical system paths or application data are affected.
General mitigation guidance
Hardening typically focuses on constraining and validating file system paths used by synchronization features and reducing the blast radius of any misconfiguration.
Common defensive patterns include:
- Restrict workspace roots: Enforce that remoteWorkspaceDir and remoteAgentWorkspaceDir must reside within a predefined, application-controlled root directory, rejecting any configuration outside that boundary.
- Normalize and validate paths: Apply canonicalization, removal of traversal sequences (e.g., ".."), and checks against symbolic links before performing delete or sync operations.
- Use allowlists instead of raw config: Offer predefined or server-side managed workspace roots rather than arbitrary user-specified paths.
- Limit deletion scope: Design sync routines to operate on known subdirectories and avoid broad recursive deletion on configurable paths.
- Least privilege for the agent: Run remote agents with the minimum file system privileges required, avoiding permissions on sensitive system or shared directories.
- Protect configuration channels: Treat configuration inputs as sensitive, applying authentication, authorization, and change auditing to prevent unauthorized modifications.
How teams detect issues like this
Detection efforts can focus both on code-level patterns and runtime behavior:
- Static analysis and code review:
- Flag code that uses configuration-derived paths in delete, move, or recursive sync operations without path normalization and boundary checks.
- Look for direct concatenation of configuration values into file system operations (e.g., rm, recursive delete, or library equivalents).
- Verify that all workspace-related paths are validated against an enforced root directory.
- Configuration policy checks:
- Implement policies that disallow unsafe path patterns (e.g., "..", absolute paths outside allowed roots) in workspace configuration fields.
- Apply automated checks on configuration changes to detect suspicious or out-of-bound paths before they are deployed.
- Runtime and operational monitoring:
- Log mirror operations with the resolved target paths and detect deletions targeting unexpected directories.
- Use host-based monitoring to alert on large-scale deletions initiated by the OpenClaw agent outside expected workspace trees.
- Automated tooling:
- Integrate security linters or SAST tools configured to detect unvalidated path usage in sync and cleanup routines.

