Sandbox
The sandbox runs Bash commands inside a wall that the operating system enforces.
It limits which files a command can write and which hosts it can reach, even when a permission rule allows the command.
Permission rules decide whether a call runs. The sandbox limits what the call can touch once it runs.
The sandbox works on macOS, Linux, and WSL. sandbox.enabled turns it on, and it is false by default. Without its dependencies, a warning shows and commands run unsandboxed. The sandbox key works in any settings scope, but some keys work only in managed or user settings.
Example
{
"sandbox": {
"enabled": true,
"failIfUnavailable": true,
"network": {
"allowedDomains": ["github.com", "*.npmjs.org"]
},
"filesystem": {
"allowWrite": ["~/.cache/build"],
"denyRead": ["~/.ssh"]
}
}
}
Bash runs in the sandbox, reaches only those two hosts, can also write to the cache folder, and cannot read ~/.ssh.
Claude Code exits at startup if the sandbox cannot start.
Core Keys
Official pages: Configure the Sandboxed Bash Tool and Settings Reference.
| Key | Status | What it does | How it works | Scope |
|---|---|---|---|---|
sandbox. | Documented | Runs Bash in the sandbox | Default false. Without dependencies, a warning shows and commands run unsandboxed | Each scope |
sandbox. | Documented | Exit at startup if the sandbox cannot start | Default false. For managed hard gates | Each scope |
sandbox. | Documented | Auto-allows sandboxed commands | Reason text Auto-. Default true per the filesystem. text | Each scope |
⚠️ sandbox. | Documented | Lets a call use dangerously | Default true. When false, the parameter is ignored. A false from managed, --, or user settings holds | Each scope |
sandbox. | Documented | Patterns that run outside the sandbox | Bash rule syntax. A convenience, not a boundary: the permission flow still applies. Only managed, --, and user entries count | Merged |
sandbox. | Documented | Map of command patterns (* for all) to paths whose violations are not reported | Merged across scopes | Each scope |
sandbox. | Documented | Linux: no fresh / mount | For hosts like unprivileged Docker. Reduces security. Default false | Each scope |
sandbox. | Documented | macOS: allow com. | For Go tools with a MITM proxy. Reduces security. Default false | Each scope |
sandbox. | Documented | macOS: allow Apple Events | Needed for open and osascript. Removes code-execution isolation. Default false | User, managed, -- |
sandbox., sandbox. | Undocumented | Custom rg for bundled ripgrep support | Strings | User, managed, -- |
sandbox. | Documented | Linux and WSL: path to bwrap | Absolute path. Overrides PATH detection | Managed only |
sandbox. | Documented | Linux and WSL: path to socat | Absolute path | Managed only |
Network Keys
| Key | Status | What it does | How it works | Scope |
|---|---|---|---|---|
sandbox. | Documented | Domains reachable without a prompt | Wildcards like *.. Merged with Web allow rules | Merged |
sandbox. | Documented | Domains always blocked | Wins over allowed. Merged from all scopes | Merged |
sandbox. | Documented | Only managed domains count | Denied domains still come from all scopes | Managed only |
sandbox. | Documented | Deny hosts not in allowed without a prompt | Not for in-process tools like Web. Web rules leave the allowlist | User, managed, -- |
sandbox. | Documented | macOS: socket paths to allow | Ignored on Linux | Merged |
sandbox. | Documented | Allow all Unix sockets | Both platforms | Each scope |
sandbox. | Documented | macOS: bind to localhost ports | Boolean | Each scope |
sandbox. | Documented | macOS: extra XPC or Mach names | Trailing * prefix match. For iOS Simulator or Playwright | Merged |
sandbox., sandbox. | Documented | Use your own proxy | Local TCP port | Each scope |
🧪 sandbox., . | Gated | Experimental TLS termination | Lets the filter see HTTPS bodies. Omit both for an ephemeral CA. Gate: marked [EXPERIMENTAL] | User, managed, -- |
Filesystem Keys
| Key | Status | What it does | How it works | Scope |
|---|---|---|---|---|
sandbox. | Documented | Extra writable paths | Repo-committed entries are limited to trusted tiers | Merged |
sandbox. | Documented | Paths denied for writes | - | Merged |
sandbox. | Documented | Paths denied for reads | - | Merged |
sandbox. | Documented | Re-allows reads inside deny | Wins over deny | Merged |
sandbox. | Documented | Only managed allow paths | Boolean | Managed |
sandbox. | Documented | Skip filesystem isolation | macOS and Linux and WSL only. Network and seccomp stay. Ignored on native Windows. Pinned to managed when managed sets filesystem rules | User, managed, -- |
Credential Keys
These keys hide secrets from commands. A command sees a placeholder, and the proxy swaps in the real value only for the hosts you name.
| Key | Status | What it does | How it works | Scope |
|---|---|---|---|---|
sandbox. | Documented | Protects credential files or directories | Fields path, mode (deny or mask), extract, on (warn, deny, error), decode (jwt), mask, mask, inject. | Merged |
sandbox. | Documented | Protects environment variables | Fields name, mode, extract, on, decode, mask, inject. extract and decode cannot combine | Merged |
sandbox. | Documented | Sentinel swap on the plain HTTP path | Default false | User, managed, -- |
sandbox. | Documented | Groups masked env vars into AWS pairs for SigV4 re-signing | The standard AWS trio pairs by itself | User, managed, -- |
sandbox. | Documented | Policy for SigV4 shapes the proxy cannot re-sign | deny (default) or passthrough | User, managed, -- |
Environment Variables
Source: the program. See also Environment Variables.
| Variable | Status | What it does | How it works | Scope |
|---|---|---|---|---|
CLAUDE_ | Undocumented | Shows Sandboxed as the tool name | Truthy value, for sandboxed calls | Env |
IS_ | Undocumented | Marks a host that is already a sandbox | Skips the sandbox gate when truthy | Env |
CLAUDE_ | Undocumented | Treats the folder as trusted | Skips the trust dialog check | Env |
CLAUDE_ | Undocumented | Windows: skip the parent-folder grants | Boolean | Env |
CLAUDE_ | Undocumented | Windows: leave the deny lists to sandbox- | Boolean | Env |
Other Behavior
- The
Bashtool takesdangerouslyDisableSandbox: true. The tool prompt tells the model to use it only after a violation that blocks the task.sandbox.allowUnsandboxedCommands: falseignores it. - A call with
allowed_domainsgoes to the auto mode classifier. Allow rules do not approve those hosts. - The sandbox creates empty placeholder files such as
.mcp.jsonin places where none exists. - Since
2.1.304, sandboxed commands start on Linux when asandbox.filesystem.denyReadglob has brackets that are not a character class, such as a[user-id]route folder. Source: the release notes. - Linux ignores glob patterns in
EditandReadrules for the sandbox, and shows a warning.
Source for all four: the program prompt and warning texts.
How It Works
With sandbox.autoAllowBashIfSandboxed on, a sandboxed command skips the prompt.
See Permission Flow.