[BUG] sandbox.filesystem.denyWithinAllow not enforced for Edit/Write tools
Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Aug 11, 2026 · closed Aug 17, 2026
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description:
The denyWithinAllow sandbox rule does not prevent the Edit tool from writing to explicitly denied paths.
What Should Happen?
- Use the Edit tool to modify ~/.claude/settings.json.
Expected: Edit is rejected because the path matches denyWithinAllow.
Actual: Edit succeeds and the file is modified.
Impact: Users who configure denyWithinAllow to protect sensitive config files (e.g., settings.json, settings.local.json) from being modified by the agent have their restriction silently bypassed.
Error Messages/Logs
Steps to Reproduce
- In ~/.claude/settings.json, configure the sandbox with a denyWithinAllow entry:
"sandbox": {
"enabled": true,
"filesystem": {
"allowWrite": ["."]
}
}
- The system-level sandbox config includes:
"write": {
"allowOnly": ["/home/user/.claude", "."],
"denyWithinAllow": ["/home/user/.claude/settings.json"]
}
- Use the Edit tool to modify ~/.claude/settings.json.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
1.0.127
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
3 Comments
Reproduced on v2.1.233 (macOS) — the behavior you describe is real, but it's the documented boundary between the sandbox and the permission system rather than a bug in the sandbox.
Steps:
.claude/settings.json:{"sandbox":{"enabled":true,"filesystem":{"allowWrite":["."]}}}.claudeand ask: "Using the Bash tool, runecho test >> ~/.claude/settings.json.""repro85761": trueto ~/.claude/settings.json."Observed:
operation not permittedon macOS,Read-only file systemon Linux).bypassPermissionsmode it goes through.Expected (per the report): Edit rejected because the path is in the sandbox's "denied within allowed" list.
Assessment: This is working as designed. The sandbox (
sandbox.filesystem.*, including the built-in "denied within allowed" list you see in/sandbox→ Config) isolates commands run by the Bash tool. The built-in Read/Edit/Write tools run in-process and are governed by the permission system instead — see https://code.claude.com/docs/en/sandboxing#scope ("Read, Edit, and Write use the permission system directly rather than running through the sandbox"). On the permission side,~/.claude/settings.jsonis a protected path that always prompts unless you're inbypassPermissionsmode (https://code.claude.com/docs/en/permission-modes#protected-paths). If you want the Edit/Write tools hard-blocked from a path regardless of mode, use a permission deny rule, e.g."permissions": {"deny": ["Edit(~/.claude/settings.json)", "Write(~/.claude/settings.json)"]}(https://code.claude.com/docs/en/permissions#read-and-edit). If your edit went through without any prompt, you were most likely in auto or bypass mode.🤖 Generated with Claude Code
Thanks for the detailed report. I tested this on a fresh 2.1.233 install on Linux and can reproduce the observation, but it's intended, documented behavior rather than a bypass.
sandbox.filesystemrules are an OS-enforced boundary on Bash commands and their subprocesses — they don't govern Claude's in-process Edit/Write tools. (Also,denyWithinAllowisn't a settings key; the write-deny key issandbox.filesystem.denyWrite.) What I observed on 2.1.233 with your config (usingdenyWrite):~/.claude/settings.json: not blocked by the sandbox, but it was never silent —.claudeis a protected path, so Claude Code showed the "Do you want to make this edit to settings.json?" prompt and the edit only succeeded after I explicitly approved it.echo >> ~/.claude/settings.json: blocked by the sandbox as expected, then fell back to a permission prompt naming the denied path.To hard-block the file tools on those paths, use a permission deny rule instead:
"permissions": {"deny": ["Edit(~/.claude/settings.json)", "Edit(~/.claude/settings.local.json)"]}. I verified on 2.1.233 that this rejects the Edit tool outright, with no prompt.Docs: How sandboxing relates to permissions and Read and Edit rules.
🤖 Generated with Claude Code
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.