claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Add setting to block dangerouslyOverrideSandbox parameter in Bash tool calls

Open johngrimes opened this issue 2 months ago • 3 comments

Problem

Claude Code's Bash tool includes a dangerouslyOverrideSandbox parameter that bypasses sandbox restrictions. While the system prompt instructs Claude to only use this parameter after seeing sandbox violation errors or when explicitly requested by the user, there is no technical enforcement to prevent misuse.

Note: Issue #8368 claims this parameter was removed in v2.0.0, but it still functions in v2.0.25, creating confusion about its status and making it even more critical to have explicit controls.

In practice, Claude can preemptively use dangerouslyOverrideSandbox: true without first attempting the command normally, bypassing:

  • Sandbox security restrictions
  • Permission hooks and prompts
  • User review workflows

This occurred when Claude ran gh pr create with the sandbox override flag without first seeing a failure, creating a pull request despite user settings that should have required permission/review first.

Related issues

  • #8961
  • #8368 - Documents that dangerouslyOverrideSandbox was supposedly removed in v2.0.0 (but still works in v2.0.25)

Expected behavior

Users should be able to prevent the use of dangerouslyOverrideSandbox through a configuration setting, similar to how filesystem and network access can be restricted in settings.json.

Proposed solution

Add a setting in settings.json to control sandbox override behavior:

{
  "sandbox": {
    "allowOverride": false  // default: true for backwards compatibility
  }
}

When allowOverride: false, any Bash tool calls with dangerouslyOverrideSandbox: true should either:

  1. Fail with an error message indicating the setting blocks sandbox overrides, or
  2. Be automatically downgraded to run with sandbox enabled (ignoring the parameter)

Additional context

This would provide defence-in-depth alongside the existing behavioral guidelines in the system prompt, preventing accidental or unintended bypass of sandbox restrictions.

Environment:

  • Claude Code version: 2.0.25

johngrimes avatar Oct 22 '25 05:10 johngrimes

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/7097
  2. https://github.com/anthropics/claude-code/issues/4320
  3. https://github.com/anthropics/claude-code/issues/8961

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 22 '25 05:10 github-actions[bot]

I am experiencing the same thing in 2.0.25!

rcbeall1 avatar Oct 23 '25 04:10 rcbeall1

still here (or still similar here) for version 2.0.62

drswobodziczka avatar Dec 10 '25 18:12 drswobodziczka