Summary
OpenClaude versions prior to 0.5.1 contain a logic flaw in the Bash tool permission check that can allow shell commands to escape intended directory restrictions.
When sandbox auto-allow is enabled and no explicit deny rules exist, path traversal sequences in commands may bypass path constraint filtering, potentially granting unauthorized file system access.
Affected context
This vulnerability affects OpenClaude deployments that use the Bash tool with the sandbox auto-allow feature enabled and no explicit deny rules configured.
In this configuration, the permission check logic short-circuits and returns an "allow" decision before path constraints are evaluated, meaning commands with traversal patterns such as ../ may be executed outside the intended sandbox directory.
The risk is most significant when the Bash tool is used against host file systems with sensitive data or powerful OS utilities.
Exploit preconditions
- Attack surface: The Bash tool command execution interface exposed by OpenClaude (CLI, agents, or any workflow that lets users or external inputs influence shell commands).
- Required access: Ability to cause OpenClaude to run Bash commands (directly via CLI arguments, prompts to the coding agent, or integrated tooling).
- Trigger point: Execution of a command while:
- The sandbox auto-allow feature is active, and
- No explicit deny rule is present for the targeted path or command.
- Why exploitation is possible: The
bashToolHasPermission()function returns an "allow" result as soon as auto-allow applies, without invokingcheckPathConstraints, so directory traversal sequences are never filtered or rejected.
Why this happens
The core issue is an authorization logic flaw combined with insufficient path validation.
Instead of enforcing a strict evaluation order—first validating paths, then applying allow/deny decisions—the permission function short-circuits on an auto-allow condition when no deny rule is configured.
This prematurely grants permission without checking path traversal or directory boundaries, mapping to:
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because traversal sequences can escape the intended sandbox.
- CWE-284: Improper Access Control, because the access control logic fails to reliably apply path constraints before authorizing execution.
Abstractly, this pattern reflects any system where convenience shortcuts (auto-allow) are evaluated before safety checks (path constraints), leaving security controls unenforced.
Potential impact
- Unauthorized reading of files outside the intended sandbox directory (e.g., system configuration or application secrets).
- Unauthorized modification or deletion of files reachable via the traversal path.
- Execution of shell commands in directories that were meant to be restricted.
- Escalation of the coding agent's effective capabilities, potentially impacting the host system or adjacent projects.
- Violation of tenant or project isolation if multiple workspaces are assumed to be separated by directory constraints.
General mitigation guidance
Effective mitigation focuses on enforcing path checks unconditionally and narrowing the Bash tool's authority:
- Ensure that any permission check function always evaluates path constraints before returning an allow/deny decision, regardless of auto-allow settings.
- Normalize and canonicalize paths (e.g., resolving
..and symbolic links) before comparison to sandbox roots, then enforce strict "must-be-under-root" checks. - Treat auto-allow features as advisory convenience layers, not as a replacement for hard security boundaries; safeguards should remain in force even when auto-allow is enabled.
- Configure the Bash tool to run with least privilege (separate OS user, restricted file system permissions) so that even if traversal occurs, damage is limited.
- Consider default-deny patterns for file system access, where explicit allowlists define which directories or file types can be touched, instead of relying on denylists.
- Where possible, separate sensitive configuration and secrets from directories that the Bash tool user can access.
How teams detect issues like this
Organizations can look for this class of flaw using a mix of static and process-based techniques:
- Static analysis and code review:
- Identify authorization functions where "auto-allow" or "fallback allow" paths exist and verify that validation (path checks, scope checks) is always executed first.
- Flag early returns in permission-checking functions that bypass security-relevant filters such as
checkPathConstraintsor path normalization helpers. - Review any code handling file paths from user-driven inputs (including prompts to agents) for missing checks against a defined root directory.
- Configuration and policy checks:
- Periodically scan OpenClaude configurations to detect where sandbox auto-allow is enabled without complementary deny or allow rules.
- Enforce internal policies that require explicit sandbox boundaries and documented rationale when auto-allow is used.
- Runtime monitoring:
- Monitor process activity of the Bash tool user for file access outside expected sandbox directories.
- Implement logging of commands executed via the Bash tool and alert on suspicious patterns like repeated
../sequences or access to high-value paths (e.g.,/etc, home directories, SSH keys). - Automated code review tools can be configured with custom rules to highlight permission-checking functions that contain early
allowbranches or that do not invoke path constraint checks in all code paths.

