-
Notifications
You must be signed in to change notification settings - Fork 312
Bash boundary check doesn't catch cd in chained commands #65
Copy link
Copy link
Closed
Description
Context
check_bash_directory_boundary() in src/claude/monitor.py validates filesystem-modifying bash commands against the approved directory. However, cd is not in _FS_MODIFYING_COMMANDS or _READ_ONLY_COMMANDS, so it falls through as "allowed."
This means a chained command like:
cd /tmp && touch malicious_file...would have cd /tmp pass through unchecked. The touch malicious_file would also pass because malicious_file is relative and resolves against working_directory (not /tmp — the boundary checker doesn't simulate shell state).
Mitigations already in place
- Sandbox (
sandbox_enabled=Trueby default) blocks filesystem writes outside the sandbox at the OS level - Absolute paths in modifying commands are caught (e.g.,
touch /tmp/filewould be denied) - The
cwdoption scopes the CLI process to the project directory
Risk
Low when sandbox is enabled (default). Higher in trusted environments where sandbox_enabled=False.
Possible fixes
- Add
cdto a new category and validate its target path stays withinapproved_directory - Detect
&&,||,;command chaining and validate each sub-command independently - Accept the current behavior and document that sandbox is the primary enforcement for this case
Spun off from discussion in #64.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels