claude-code - 💡(How to fix) Fix [BUG] Write tool bypasses sandbox filesystem write restrictions that Bash tool correctly enforces [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52325Fetched 2026-04-24 06:10:09
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Timeline (top)
labeled ×7commented ×2

Error Message

The built-in Write tool ignores sandbox filesystem write restrictions configured in settings.json. When sandbox is configured with denyWrite: ["/"] and a limited allowWrite list, the Write tool successfully creates files outside the allowed paths without any error or permission prompt. The Write tool should be blocked from writing files outside the allowWrite list, the same way the Bash tool correctly enforces these restrictions. Writing to a restricted path should fail with a permission error.

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

The built-in Write tool ignores sandbox filesystem write restrictions configured in settings.json. When sandbox is configured with denyWrite: ["/"] and a limited allowWrite list, the Write tool successfully creates files outside the allowed paths without any error or permission prompt.

What Should Happen?

The Write tool should be blocked from writing files outside the allowWrite list, the same way the Bash tool correctly enforces these restrictions. Writing to a restricted path should fail with a permission error.

Error Messages/Logs

Steps to Reproduce

  1. Configure settings.json with sandbox restrictions: { "sandbox": { "enabled": true, "failIfUnavailable": true, "filesystem": { "denyWrite": ["/"], "allowWrite": ["/your/project/dir", "/tmp"], "denyRead": ["/your/parent/dir"], "allowRead": ["/your/project/dir"] } } }

  2. Ask Claude to write a file to a path outside allowWrite using the Write tool. Example: "Create hello.txt in the parent directory with some content"

  3. Observe that the file is created successfully at the restricted path.

  4. For comparison, ask Claude to do the same via Bash tool: echo "test" > /restricted/path/hello.txt → This correctly returns "operation not permitted"

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.118

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

Warp

Additional Information

No response

extent analysis

TL;DR

The Write tool in Claude Code may need an update to properly enforce sandbox filesystem write restrictions configured in settings.json.

Guidance

  • Review the Write tool's implementation to ensure it checks the denyWrite and allowWrite settings in settings.json before creating files.
  • Compare the Write tool's behavior with the Bash tool, which correctly enforces these restrictions, to identify potential differences.
  • Test the Write tool with different sandbox configurations to verify its behavior and identify any edge cases.
  • Consider adding error handling to the Write tool to return a permission error when attempting to write to a restricted path.

Example

No code snippet is provided as the issue does not include specific implementation details.

Notes

The issue may be specific to the Write tool's implementation or the sandbox configuration in settings.json. Further investigation is needed to determine the root cause.

Recommendation

Apply a workaround by modifying the Write tool to check the denyWrite and allowWrite settings in settings.json before creating files, until a fixed version is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING