Configure the sandboxed Bash tool
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -524,7 +524,7 @@
Permission rules and sandboxing control different things:
- * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to every tool: Bash, Read, Edit, WebFetch, MCP, and others, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains.
+ * **Permission rules** control which tools Claude Code can use and are evaluated before a tool runs. They apply to Bash, Read, Edit, WebFetch, MCP, and other tools. A deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains.
* **Sandboxing** provides OS-level enforcement that restricts what shell commands can access at the filesystem and network level. It applies to Bash, PowerShell, and [Monitor](</docs/en/tools-reference#monitor-tool>) tool commands and their child processes.
The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
Show diff (104 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -184,7 +184,7 @@
* **An ask rule for the parameter** : add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)` to be prompted on Bash retries. You get the prompt in auto mode and `bypassPermissions` mode too, and the rule takes precedence over a matching allow rule
* **[`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>)** : [Actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) covers the retries that prompt while it’s on
-While commands are refused with a `Sandbox is required` message, Claude Code ignores the `dangerouslyDisableSandbox` parameter and refuses the retry too.
+If you use Code Mode, retries in auto mode work differently. See [Limit shell commands with the sandbox](</docs/en/code-mode#limit-shell-commands-with-the-sandbox>). While commands are refused with a `Sandbox is required` message, Claude Code ignores the `dangerouslyDisableSandbox` parameter and refuses the retry too.
#### Turn off the retry with strict sandbox mode
@@ -338,7 +338,7 @@
When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
* **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. To check for this misconfiguration, run `claude doctor` in your terminal and look for the `TLS termination is unavailable` warning.
- * **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
+ * **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For most `mask` entries with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
* **A trusted settings scope** : masking authorizes the proxy to send your real credential somewhere, so Claude Code honors `mask` entries, `network.tlsTerminate`, [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), `awsPairs`, and `sigv4` only from user settings, managed settings, and the `--settings` flag. It ignores them in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>).
#### Mask environment variables
@@ -370,7 +370,7 @@
#### Re-sign AWS requests
-AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs the request with the real values, which requires Claude Code v2.1.221 or later. If you mask only the secret, requests are signed with a placeholder the proxy can’t detect, so they fail at AWS. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential is in variables with other names, group them with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. Streaming uploads, presigned URLs, and SigV4A requests carry signatures the proxy can’t recompute. When one of these requests is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature. Requests signed with unmasked credentials aren’t affected. Use [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>), which requires Claude Code v2.1.224 or later, to forward one of these request forms instead. AWS still rejects the request, so the calling tool receives AWS’s own rejection response instead of a proxy error.
+AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel. Re-signing a request with the real values requires Claude Code v2.1.221 or later. If you mask only the secret, requests are signed with a placeholder the proxy can’t detect, so they fail at AWS. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential is in variables with other names, group them with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. Streaming uploads, presigned URLs, and SigV4A requests carry signatures the proxy can’t recompute. When one of these requests is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature. Requests signed with unmasked credentials aren’t affected. Use [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>), which requires Claude Code v2.1.224 or later, to forward one of these request forms instead. AWS still rejects the request, so the calling tool receives AWS’s own rejection response instead of a proxy error.
#### Mask credential files
@@ -433,11 +433,11 @@
If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true` on Linux or WSL2, don’t rely on protected paths: code from a sandboxed command can end up running outside the sandbox.
-To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
+To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
#### When the sandbox deletes `HEAD`, `objects`, or `refs`
-After a sandboxed command ends, a newer top-level `HEAD`, `objects`, or `refs` entry in your working directory is deleted unless it’s a folder with contents. Newer means the entry wasn’t there when the sandbox last built its configuration: at session start, or after a change such as [`/cd`](</docs/en/commands>). A newer `objects` or `refs` folder with contents is deleted too, with its contents, when a `HEAD` file or symlink was there the last time the sandbox built its configuration. To keep a folder, see A folder named `objects` or `refs` disappears after a command.
+After a sandboxed command ends, a newer top-level `HEAD`, `objects`, or `refs` entry in your working directory is deleted unless it’s a folder with contents. Newer means the entry wasn’t there when the sandbox last built its configuration: at session start, or after a change such as [`/cd`](</docs/en/commands>). When a `HEAD` file or symlink was there the last time the sandbox built its configuration, a newer `objects` or `refs` folder is instead renamed to `<name>.claude-sandbox-quarantine-<hex>`. Its contents stay intact. To keep a folder or restore a renamed one, see A folder named `objects` or `refs` disappears after a command.
#### Denied paths that pass through a symlink
@@ -498,6 +498,13 @@
* **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist
To find ambiguous entries, run `claude doctor` in your terminal and look for the `Sandbox network domain entries have unreliable spellings` warning. Rewrite each ambiguous entry in the bracketed form.
+
+#### Usernames and passwords in proxy variables
+
+If a command’s `HTTPS_PROXY` or other proxy URL contains a username and password, check the username and host:
+
+ * **Host`127.0.0.1` or `localhost`, and username `srt` or one that starts with `srt.`**: treat it as the built-in sandbox proxy’s own login, which isn’t one of your credentials
+ * **Any other username or host** : treat it as one of your own credentials
### OS-level enforcement
@@ -566,7 +573,7 @@
The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
- * **`failIfUnavailable`** : when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code refuses to start rather than falling back to unsandboxed execution
+ * **`failIfUnavailable`** : when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code refuses to start rather than falling back to unsandboxed execution. In an Anthropic-hosted environment, the session can start anyway
* **`allowUnsandboxedCommands: false`** : Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can’t retry it unsandboxed
Consider these additions alongside them:
@@ -712,7 +719,12 @@
### A folder named `objects` or `refs` disappears after a command
-A top-level `objects` or `refs` folder that appeared during the session can be deleted after a sandboxed command ends. It doesn’t matter whether a command, Claude, or you created it. To keep a folder, leave something in it. If a `HEAD` file or symlink has been at the top level during the session, move it away, then restart every Claude Code session open there. Before v2.1.307, the folder was deleted even with something in it and no `HEAD`. On an earlier version, [update Claude Code](</docs/en/setup#update-claude-code>).
+A top-level `objects` or `refs` folder that appeared during the session can be renamed or deleted after a sandboxed command ends. It doesn’t matter whether a command, Claude, or you created it. Close the Claude Code sessions running in your working directory, because a running session can rename or delete the folder again. Then look there for an entry named `<name>.claude-sandbox-quarantine-<hex>`, such as `objects.claude-sandbox-quarantine-1a2b3c4d5e6f`, and restore the folder before you start a new session:
+
+ * **You find that entry** : the folder was renamed, with its contents intact. Move any top-level `HEAD` file or symlink out of your working directory. Then rename the entry back to `objects` or `refs`.
+ * **You find no such entry** : the folder was deleted, so create it again.
+
+To keep a new folder from being renamed, move any top-level `HEAD` file or symlink out of your working directory before you start a new session there. With no `HEAD`, leave something in a folder to keep it. Before v2.1.315, a folder could be deleted with its contents. On an earlier version, [update Claude Code](</docs/en/setup#update-claude-code>).
### Bubblewrap fails to start inside a container
@@ -738,19 +750,19 @@
### 0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
-On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. A placeholder stays behind in cases such as these:
+On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. A placeholder can stay behind in cases such as these:
* The session is killed before that cleanup runs, for example by SIGKILL
- * The session exits while a sandboxed command is still running, such as a background command
+ * The session exits while a sandboxed command is still running
Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Sandbox mask files left behind at write-deny paths`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind when a session was killed, without flagging them.
### `git` over SSH fails with the sandbox on
-On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote fail inside the sandbox even when the host is allowed. On Linux and WSL2, they work once the host is allowed. Claude Code tunnels git’s SSH connection through the sandbox proxy, and the macOS tunnel can’t authenticate to that proxy. On Linux and WSL2, check these if the connection still fails:
+On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote can fail inside the sandbox even when the host is allowed. On Linux and WSL2, they work once the host is allowed. If the connection still fails, check these:
* **The host is allowed on port 22** : an `allowedDomains` entry with no port, such as `"git.example.com"`, covers it
- * **Your corporate proxy permits port 22** : if your network requires an upstream proxy, the tunnel goes through it too
+ * **Your corporate proxy permits port 22** : if your network requires an upstream proxy, the connection goes through it too
* **The key is readable as a file** : the sandbox can block the `ssh-agent` socket, and a `denyRead` or `credentials` entry for `~/.ssh` hides your key files
On macOS, switch the remote to HTTPS, which needs HTTPS credentials such as a personal access token:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -113,7 +113,7 @@
WSL2 notes
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing needs WSL2` or `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
#### Add an AppArmor profile for bubblewrap
@@ -835,9 +835,9 @@
In a Linux session with `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` set, every command runs sandboxed, so excluded commands and commands you type are refused too.
-### `/sandbox` fails with `Sandbox settings are overridden by a higher-priority configuration`
-
-`/sandbox` prints `Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.` instead of opening its panel when a higher [settings level](</docs/en/settings#settings-precedence>) sets `sandbox.enabled`, `sandbox.autoAllowBashIfSandboxed`, or `sandbox.allowUnsandboxedCommands`. The panel saves your choices to `.claude/settings.local.json`, and a value saved there can’t override those levels. Managed settings and `--settings` rank above local settings. To see which of them this session loaded, run `/status` and read the `Setting sources` line:
+### `/sandbox` fails with `Sandbox settings can't be changed here`
+
+When `sandbox.enabled`, `sandbox.autoAllowBashIfSandboxed`, or `sandbox.allowUnsandboxedCommands` is set above the local [settings level](</docs/en/settings#settings-precedence>), `/sandbox` prints `Sandbox settings can't be changed here. Higher-priority settings override them.` and its panel stays closed. The panel saves your choices to `.claude/settings.local.json`, and a value saved there can’t override higher levels. Managed settings and `--settings` rank above local settings. To see which of them this session loaded, run `/status` and read the `Setting sources` line:
* **`Command line arguments`** : if you started Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>), check whether the file or JSON you passed sets one of those keys. If it does, change the value there, or start Claude Code again without those keys.
* **`Enterprise managed settings`** : your organization’s managed settings are loaded. If they set one of those keys, you can’t change that key from `/sandbox` or from any settings file you control, so ask your administrator.
@@ -846,7 +846,7 @@
This line means `/sandbox` couldn’t save the choice you made in its panel to your project’s `.claude/settings.local.json`:
- ✗ Sandbox settings not changed: /home/you/project/.claude/settings.local.json couldn't be updated (EACCES). Start Claude Code in a project folder you can write to.
+ ✗ Sandbox settings not changed: /home/you/project/.claude/settings.local.json couldn't be updated (EACCES). Start Claude Code in a project directory you can write to.
If the reason in parentheses is `EACCES`, `EPERM`, or `EROFS`, start Claude Code in a project folder you can write to, then run `/sandbox` again in that session. If the reason begins with `Invalid JSON syntax in settings file`, correct the JSON in your project’s `.claude/settings.local.json`, then run `/sandbox` again. If no writable project folder is available to you, turn the sandbox on from your user settings instead. Add this to `~/.claude/settings.json`:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,4 +1,4 @@
-The Bash sandbox is a boundary that the operating system enforces around the shell commands Claude runs on your machine. You set which files and network domains those commands can reach, and the limits apply to Bash, PowerShell, and Monitor commands and the processes they start. Because the operating system applies the limits while a command runs, Claude Code can run sandboxed commands without asking you to approve each one. The sandbox covers shell commands only. Claude’s file tools, MCP servers, and hooks run outside it. The sandbox runs on macOS, Linux, and WSL2. On native Windows, Claude Code runs commands unsandboxed. To use the sandbox on a Windows machine, run Claude Code inside a WSL2 distribution.
+The Bash sandbox is a boundary that the operating system enforces around the shell commands Claude runs on your machine. You set which files and network domains those commands can reach, and the limits apply to Bash, PowerShell, and Monitor commands and the processes they start. Sandboxed commands still go through the regular permission flow unless you choose auto-allow mode, which can run them without asking you. The sandbox covers shell commands only. Claude’s file tools, MCP servers, and hooks run outside it. The sandbox runs on macOS, Linux, and WSL2. On native Windows, Claude Code runs commands unsandboxed. To use the sandbox on a Windows machine, run Claude Code inside a WSL2 distribution.
This page covers the sandbox around shell commands on your own machine. Other pages cover related questions:
@@ -304,10 +304,7 @@
`credentials.envVars` `deny` and `mask` entries| Enforced. Environment variable scrubbing is independent of the filesystem layer
`credentials.files` `mask` entries applied as masks| Enforced: masking is independent of the filesystem layer. An entry that fell back to `deny` is not enforced, like any `deny` entry
-Two other things change:
-
- * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the per-user temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the per-user one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
- * [`autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
+Sandboxed commands also inherit your shell’s `$TMPDIR` instead of the per-user temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the per-user one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
### Protect credentials
@@ -859,7 +856,7 @@
}
}
-This turns on auto-allow mode. For regular permissions mode, also set [`sandbox.autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) to `false`. The change takes effect in your running session at the next shell command Claude runs, and the **Mode** tab of `/sandbox` then marks the mode in effect.
+This turns on regular permissions mode. For auto-allow mode, also set [`sandbox.autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) to `true`. The change takes effect in your running session at the next shell command Claude runs, and the **Mode** tab of `/sandbox` then marks the mode in effect.
## Limitations
Show diff (810 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -6,11 +6,7 @@
* To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>)
* To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>)
-##
-
-
-
-What the sandbox restricts
+## What the sandbox restricts
While the sandbox is on, the shell commands Claude runs start inside its boundary, and so do the processes they start. The sandbox is off by default. To turn it on, run `/sandbox` in a session, as Get started shows, or set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in a [settings file](</docs/en/settings>) such as `~/.claude/settings.json`. The table shows what a sandboxed command can reach by default and the settings that change each default.
@@ -23,11 +19,7 @@
Claude Code builds the sandbox on the open source [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package.
-###
-
-
-
-What runs outside the sandbox
+### What runs outside the sandbox
The sandbox wraps shell commands. These tools and processes run outside it:
@@ -43,11 +35,7 @@
To put the tools, processes, and commands in this section behind one boundary, run the Claude Code process itself in a [container, virtual machine, or the sandbox runtime](</docs/en/sandbox-environments>).
-##
-
-
-
-Get started
+## Get started
The sandbox is built into Claude Code. What you install depends on your platform:
@@ -88,11 +76,7 @@
By default, when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code runs commands without sandboxing. To make Claude Code exit at startup instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. Managed deployments that require sandboxing as a security gate can use this setting.
-###
-
-
-
-Confirm commands run inside the sandbox
+### Confirm commands run inside the sandbox
To check that the sandbox is working, ask Claude to run each line in the table. What you type at the `!` prompt usually runs outside the sandbox, so typing a line yourself doesn’t test it.
@@ -103,11 +87,7 @@
If Claude asks to retry a failed command outside the sandbox, decline the retry. If `touch` succeeds and your home directory isn’t one of the directories the sandbox lets commands write to, delete `~/sandbox-probe`. Then run `/sandbox` to check that the sandbox is on and its dependencies are installed.
-###
-
-
-
-Set up Linux and WSL2
+### Set up Linux and WSL2
On Linux and WSL2, the sandbox relies on these packages:
@@ -135,11 +115,7 @@
Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
-####
-
-
-
-Add an AppArmor profile for bubblewrap
+#### Add an AppArmor profile for bubblewrap
Add the profile if Claude Code runs `/usr/bin/bwrap` and either of these happens:
@@ -164,19 +140,11 @@
Then restart Claude Code and confirm the sandbox works.
-###
-
-
-
-Sandbox modes
+### Sandbox modes
Claude Code offers two sandbox modes. In both, the sandbox enforces the same filesystem and network restrictions; the difference is only in whether sandboxed commands are auto-approved or require explicit permission.
-####
-
-
-
-Auto-allow mode
+#### Auto-allow mode
Claude Code approves a command automatically, with no prompt, when the command runs inside the sandbox. A command goes through the regular [permission flow](</docs/en/permissions>) when it runs outside the sandbox because it matches `excludedCommands` or because Claude retries it unsandboxed. A sandboxed command that connects to a host you haven’t allowed stays in the sandbox. Hosts outside your allowed domains covers who decides whether the connection goes through. Even in auto-allow mode, the following still apply:
@@ -196,19 +164,11 @@
Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan.
-####
-
-
-
-Regular permissions mode
+#### Regular permissions mode
All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals.
-####
-
-
-
-The unsandboxed retry escape hatch
+#### The unsandboxed retry escape hatch
The unsandboxed retry is an escape hatch for commands that fail inside the sandbox, such as tools that are incompatible with it. When the sandbox blocks a network connection, Claude Code names the denied host in the command’s result, so Claude sees what was blocked. Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs unsandboxed. In an interactive terminal session, who approves it depends on your permission mode:
@@ -226,11 +186,7 @@
While commands are refused with a `Sandbox is required` message, Claude Code ignores the `dangerouslyDisableSandbox` parameter and refuses the retry too.
-####
-
-
-
-Turn off the retry with strict sandbox mode
+#### Turn off the retry with strict sandbox mode
You can disable the unsandboxed retry by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the retry disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter. While the sandbox is running, commands Claude runs are then sandboxed unless they match an `excludedCommands` entry. To keep Claude Code from running commands unsandboxed when the sandbox can’t start, also set [`failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>). The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. A `false` in your user settings, `--settings`, or managed settings holds even when a project’s settings set `true`. A `false` in your user settings doesn’t make the sandbox admin-required, so a project’s other sandbox settings still apply. Before v2.1.285, a project’s `true` overrode a `false` in your user settings. If you or your administrator disable the retry in managed settings or with the `--settings` flag, the sandbox becomes admin-required. Claude Code then ignores the settings in a repository’s files that loosen the sandbox, `excludedCommands` entries included. Repository settings under an admin-required sandbox lists them. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
@@ -239,19 +195,11 @@
Before v2.1.260, strict sandbox mode sandboxed shell-mode commands in every session.
-####
-
-
-
-Temporary directories
+#### Temporary directories
A per-user temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` when it is set, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. If your shell leaves `$TMPDIR` unset or empty, an unsandboxed command that references `$TMPDIR` receives your [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>) override, or the operating system’s temp directory when you haven’t set one or the override is a long path, so the variable doesn’t expand to an empty string. To pass temporary files between the two, write them under the working directory instead.
-##
-
-
-
-Configure sandboxing
+## Configure sandboxing
Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write to the current working directory, the per-user temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
@@ -264,7 +212,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining the paths rather than replacing one scope’s array with another’s. Claude Code leaves an entry out of the merge when a lock under Keep developers from widening the policy covers it. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute and `~/.kube` is relative to your home directory. This differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. For relative paths, trailing slashes, and wildcards, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. On Linux and WSL2, an entry for a path that doesn’t exist yet has no effect, so create the path first. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining the paths rather than replacing one scope’s array with another’s. Claude Code leaves an entry out of the merge when a lock under Keep developers from widening the policy covers it. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute and `~/.kube` is relative to your home directory. This differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. For relative paths, trailing slashes, and wildcards, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
Example rules| Result
---|---
@@ -286,11 +234,7 @@
If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule. To deny sandboxed commands read access to home directories and mounted volumes while keeping the working directories readable, set [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) instead of writing path rules.
-###
-
-
-
-Run commands outside the sandbox with `excludedCommands`
+### Run commands outside the sandbox with `excludedCommands`
List a command pattern in [`sandbox.excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) to run matching commands outside the sandbox, which means no filesystem restrictions and no network proxy. Use it for a tool that can’t work inside the sandbox and that you trust with your full access. A tool that needs one more directory or one more host may work with `allowWrite` or `allowedDomains`, which keep the command sandboxed. This example takes `docker compose` commands out of the sandbox. Save it in `~/.claude/settings.json` to apply it to all of your projects:
@@ -320,11 +264,7 @@
An excluded command runs with your full access. A broad entry such as `docker *` covers everything that tool can do. If you write a pattern that covers an interpreter, a script inside your working directory, or a tool that acts on a file there, as `docker compose` does with its compose file, Claude can write that file and then run it outside the sandbox. A narrower pattern leaves less that Claude can run outside the sandbox.
-###
-
-
-
-Disable filesystem isolation
+### Disable filesystem isolation
Set `sandbox.filesystem.disabled` to `true` to skip filesystem isolation while keeping network isolation. The example below turns off filesystem isolation while keeping an allowlist of network domains:
@@ -344,25 +284,17 @@
With filesystem isolation off and commands auto-allowed, a sandboxed command can write files that later commands run or read, such as shell startup files, executables on `$PATH`, or `~/.claude/settings.json`, and use them to widen its own access on the next run. Set `filesystem.disabled` to `true` only for workloads you trust not to escalate their own access. Locking network domains with `allowManagedDomainsOnly` narrows the risk but doesn’t remove it, since that lock applies only to commands running inside the sandbox.
-####
-
-
-
-Which settings can disable it
+#### Which settings can disable it
Because turning filesystem isolation off widens what sandboxed commands can do, Claude Code honors `filesystem.disabled` from these settings sources only:
- * User settings, managed settings, and the `--settings` CLI flag can set it. Project settings in `.claude/settings.json` and `.claude/settings.local.json` can’t, so a checked-out project can’t switch filesystem isolation off.
- * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps developers from turning filesystem isolation off in such a deployment; to turn it off for everyone, set `"disabled": true` in managed settings.
- * When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
+ * User settings, managed settings, and the `--settings` CLI flag can set it. Project settings in `.claude/settings.json` and `.claude/settings.local.json` can’t set it.
+ * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. To turn filesystem isolation off for everyone, set `"disabled": true` in managed settings.
+ * When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings.
A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key, even when Claude Code falls back to `deny` for it at startup. List a path that can’t be masked, such as a credential directory, as an explicit `deny` entry in managed settings, which locks the key.
-####
-
-
-
-What changes when filesystem isolation is off
+#### What changes when filesystem isolation is off
Setting `filesystem.disabled` lifts the protections the filesystem layer itself enforces. Protections that other layers enforce keep applying:
@@ -377,11 +309,7 @@
* Sandboxed commands inherit your shell’s `$TMPDIR` instead of the per-user temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the per-user one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
* [`autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
-###
-
-
-
-Protect credentials
+### Protect credentials
The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The file protection is part of the filesystem layer, so it doesn’t apply if you disable filesystem isolation; the environment variable protection still does. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
@@ -408,11 +336,7 @@
There is no built-in credential deny list, so only the files and variables you list are restricted. `sandbox.credentials` affects sandboxed Bash commands only. To strip credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
-###
-
-
-
-Mask credentials
+### Mask credentials
When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
@@ -420,11 +344,7 @@
* **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
* **A trusted settings scope** : masking authorizes the proxy to send your real credential somewhere, so Claude Code honors `mask` entries, `network.tlsTerminate`, [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), `awsPairs`, and `sigv4` only from user settings, managed settings, and the `--settings` flag. It ignores them in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>).
-####
-
-
-
-Mask environment variables
+#### Mask environment variables
To mask an environment variable, set `"mode": "mask"` on its `credentials.envVars` entry. The command and anything it logs never hold the real credential, but its requests still authenticate. When the same variable is listed with `deny` in any scope, `deny` takes precedence. This example masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`:
@@ -451,19 +371,11 @@
The proxy matches each `injectHosts` entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches. `claude doctor` flags entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later.
-####
-
-
-
-Re-sign AWS requests
+#### Re-sign AWS requests
AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs the request with the real values, which requires Claude Code v2.1.221 or later. If you mask only the secret, requests are signed with a placeholder the proxy can’t detect, so they fail at AWS. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential is in variables with other names, group them with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. Streaming uploads, presigned URLs, and SigV4A requests carry signatures the proxy can’t recompute. When one of these requests is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature. Requests signed with unmasked credentials aren’t affected. Use [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>), which requires Claude Code v2.1.224 or later, to forward one of these request forms instead. AWS still rejects the request, so the calling tool receives AWS’s own rejection response instead of a proxy error.
-####
-
-
-
-Mask credential files
+#### Mask credential files
To mask a credential file, set `"mode": "mask"` on its `credentials.files` entry. Masking files requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
@@ -498,17 +410,9 @@
`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text.
-##
-
-
-
-How sandboxing works
-
-###
-
-
-
-Filesystem isolation
+## How sandboxing works
+
+### Filesystem isolation
The sandboxed Bash tool restricts file system access to specific directories:
@@ -519,11 +423,7 @@
To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
-###
-
-
-
-Protected paths
+### Protected paths
Inside the directories that sandboxed commands can write to, the sandbox still denies writes to the files Claude Code loads configuration and code from. A command that could edit those files could grant itself permissions, or add a hook or MCP server that Claude Code runs outside the sandbox. The permission system has its own [protected paths](</docs/en/permission-modes#protected-paths>), which control what Claude Code approves before a tool runs; the sandbox’s list applies to a command that is already running. It covers four groups of paths:
@@ -538,27 +438,15 @@
To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
-####
-
-
-
-When the sandbox deletes `HEAD`, `objects`, or `refs`
+#### When the sandbox deletes `HEAD`, `objects`, or `refs`
After a sandboxed command ends, a newer top-level `HEAD`, `objects`, or `refs` entry in your working directory is deleted unless it’s a folder with contents. Newer means the entry wasn’t there when the sandbox last built its configuration: at session start, or after a change such as [`/cd`](</docs/en/commands>). A newer `objects` or `refs` folder with contents is deleted too, with its contents, when a `HEAD` file or symlink was there the last time the sandbox built its configuration. To keep a folder, see A folder named `objects` or `refs` disappears after a command.
-####
-
-
-
-Denied paths that pass through a symlink
+#### Denied paths that pass through a symlink
On macOS, when a denied path passes through a symlink, such as a `~/.claude` that is a link into a dotfiles repository, the sandbox also denies the path’s real location. This covers the sandbox’s own denials and your literal `denyWrite` and `denyRead` entries. A `denyWrite` entry that contains `*`, `?`, or `[` is also covered when a folder before the first of those characters is a symlink. For example, `~/.claude/*.json` is also denied under the real location of `~/.claude`.
-###
-
-
-
-Network isolation
+### Network isolation
A sandboxed command has no direct route to the network:
@@ -584,11 +472,7 @@
The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
-####
-
-
-
-Hosts outside your allowed domains
+#### Hosts outside your allowed domains
When a sandboxed command connects to a host that isn’t in your allowed domains, the command stays in the sandbox and waits for a decision. In an interactive terminal session, the decision depends on your permission mode:
@@ -601,27 +485,15 @@
With [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) on, the built-in sandbox proxy refuses the connection in every permission mode. In `bypassPermissions` mode, hosts outside your allowed domains are allowed unless one of them is on. The unsandboxed retry escape hatch covers when a command can leave the sandbox in that mode. A connection to a host in [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) is refused in every permission mode too.
-####
-
-
-
-Hostnames that resolve to local addresses
+#### Hostnames that resolve to local addresses
After a hostname passes the allowlist, the sandbox proxy resolves it and refuses the connection when the name resolves only to local addresses. Local addresses include loopback addresses such as `127.0.0.1`, link-local addresses such as the `169.254.169.254` cloud metadata endpoint, and addresses assigned to your own machine. The names `localhost` and `*.localhost` are allowed to resolve to loopback. An allowed intranet hostname that resolves to a private range such as `10.0.0.0/8` connects. To let a name resolve to a refused address, add that IP address to `allowedDomains`, such as `"127.0.0.1:8080"`. The check applies to hostnames. Your allowed domains and permission mode decide a connection to an IP address. The proxy also skips the check for connections it sends through an upstream corporate proxy, because that proxy resolves the name.
-####
-
-
-
-Per-command allowed domains in auto mode
+#### Per-command allowed domains in auto mode
In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) with sandboxing on, Claude names the hosts a command needs on the command itself instead of triggering a network approval for each connection. Each Bash, PowerShell, or [Monitor](</docs/en/tools-reference#monitor-tool>) command that runs in the sandbox can carry a list of hosts beyond the sandbox’s allowlist: a domain such as `registry.npmjs.org`, a wildcard such as `*.pythonhosted.org`, or an IP address, each with an optional `:port`. The classifier reviews the hosts together with the command. Requires Claude Code v2.1.271 or later. An approved list opens those hosts for that one command alone, for as long as it runs. Nothing is added to your session’s allowed hosts or your settings; the next command names its own hosts. A command that carries hosts goes to the classifier instead of being approved by a permission rule or the sandbox’s auto-allow mode. If an [ask rule](</docs/en/permissions#manage-permissions>) forces a prompt for the command, the permission dialog in your terminal lists the hosts beside it, and approving there covers both. A per-command list widens only what the sandbox denies by default. [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) entries still block. When [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) locks the allowlist, Claude Code refuses per-command lists. While per-command lists apply, Claude Code refuses a connection to a host that no approved command listed, without a prompt or a classifier check. The refusal names the host in the command’s result, and Claude re-runs the command with the host added.
-####
-
-
-
-IPv6 addresses in domain lists
+#### IPv6 addresses in domain lists
To match an IPv6 address in `allowedDomains`, `deniedDomains`, or a `WebFetch(domain:...)` rule, write the address in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. The bracketed form requires Claude Code v2.1.229 or later. An unbracketed entry such as `::1:443` is ambiguous between an address and an address with a port:
@@ -630,11 +502,7 @@
To find ambiguous entries, run `claude doctor` in your terminal and look for the `Sandbox network domain entries have unreliable spellings` warning. Rewrite each ambiguous entry in the bracketed form.
-###
-
-
-
-OS-level enforcement
+### OS-level enforcement
The sandboxed Bash tool uses operating system security primitives:
@@ -644,19 +512,11 @@
You can also run the [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package on its own to wrap the Claude Code process. See [Sandbox runtime](</docs/en/sandbox-environments#sandbox-runtime>).
-##
-
-
-
-How sandboxing relates to permissions and permission modes
+## How sandboxing relates to permissions and permission modes
Sandboxing, [permission rules](</docs/en/permissions>), and [permission modes](</docs/en/permission-modes>) are complementary layers. The sections below cover how the sandbox interacts with each.
-###
-
-
-
-Permission rules
+### Permission rules
Permission rules and sandboxing control different things:
@@ -679,11 +539,7 @@
Paths and domains from both sandbox settings and permission rules are merged into the final sandbox configuration. The [claude-code repository’s examples directory](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
-###
-
-
-
-Permission modes
+### Permission modes
`/sandbox` is not a [permission mode](</docs/en/permission-modes>). Permission modes decide whether a tool call runs and whether you are prompted first, while the sandbox restricts what a Bash command can access once it runs. They differ in what they control and what replaces the per-action prompt:
@@ -695,19 +551,11 @@
The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined, with the exceptions listed under Sandbox modes. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>). For a table of common permission mode and sandbox pairings with the flags that start each one, see [Common setups](</docs/en/permission-modes#common-setups>).
-##
-
-
-
-Configure the sandbox for your organization
+## Configure the sandbox for your organization
Administrators can require sandboxing for every user, keep developers from widening the policy, and route sandbox traffic through a corporate proxy.
-###
-
-
-
-Enforce sandboxing with managed settings
+### Enforce sandboxing with managed settings
To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code when the platform is unsupported or a dependency is missing, and prevents the model from retrying commands outside the sandbox:
@@ -734,11 +582,7 @@
* **Deliver the configuration by operating system** : deploy it through your MDM or as a [managed settings file](</docs/en/managed-settings#delivery-mechanisms>) on macOS and Linux machines only. [Server-managed settings](</docs/en/server-managed-settings#give-groups-different-settings>) follow the member, not the device.
* **Move Windows users into a supported environment** : have them run Claude Code inside WSL2 or a container
-###
-
-
-
-Keep developers from widening the policy
+### Keep developers from widening the policy
When managed settings set a Boolean key such as `enabled` or `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `allowRead`, Claude Code merges entries from the scopes the session loads, so a developer can append entries that widen the policy unless a lock covers that key. Unless managed settings set them, a developer’s user settings or `--settings` can turn on the following keys. A repository’s `.claude/settings.json` can too, unless the sandbox is admin-required. Each one weakens the sandbox, so set it to `false` in managed settings if you don’t want it used:
@@ -751,11 +595,7 @@
Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). With `allowManagedDomainsOnly` on, only managed settings can set a proxy port. When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t turn filesystem isolation off with that key. A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key. See Which settings can disable it.
-####
-
-
-
-Repository settings under an admin-required sandbox
+#### Repository settings under an admin-required sandbox
The sandbox is admin-required while one of these settings is in effect:
@@ -780,11 +620,7 @@
The configuration under Enforce sandboxing with managed settings makes the sandbox admin-required. Add the `excludedCommands`, `allowWrite`, and socket entries that your approved tools need to managed settings, because a repository can’t supply them. Requires Claude Code v2.1.285 or later. From v2.1.282 to v2.1.284, the same settings made Claude Code ignore a repository’s `excludedCommands` entries.
-####
-
-
-
-Locks that apply without an admin-required sandbox
+#### Locks that apply without an admin-required sandbox
Some settings make Claude Code ignore the repository keys that directly override one restriction, even when the sandbox isn’t admin-required. Each one has this effect only when you set it in a file its row names, and the repository’s other sandbox settings still apply. Requires Claude Code v2.1.285 or later.
@@ -796,11 +632,7 @@
These locks change what sandboxed commands can reach. The WebFetch tool and Claude’s file tools still follow a repository’s rules and additional directories.
-###
-
-
-
-Custom proxy configuration
+### Custom proxy configuration
To inspect, filter, or log sandbox traffic with your own tooling, replace the built-in sandbox proxy with a proxy you run on the same machine. To route sandbox traffic through a corporate proxy elsewhere on your network, set `HTTPS_PROXY` instead, as the **Corporate proxy** entry under Network isolation describes. That way, Claude Code’s allowlist still applies. To direct sandboxed commands to your proxy, set the localhost ports it listens on in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
@@ -823,59 +655,31 @@
Once either port applies, your proxy is responsible for filtering everything sent to it. Claude Code’s own network controls, such as `allowedDomains`, `deniedDomains`, `strictAllowlist`, approval prompts, and the local-address check, stop applying to that traffic. A sandboxed command can connect to either proxy, so if you set only one port, Claude Code’s domain lists on the other proxy don’t limit what the command reaches through yours.
-##
-
-
-
-Troubleshooting
+## Troubleshooting
Some commands fail inside the sandbox even though they work outside it. Find the heading that matches your symptom or error message. If your organization’s sandbox is admin-required, Claude Code ignores the settings these fixes name in a project’s settings files, so save them in `~/.claude/settings.json`, where they apply in every project. If a fix still has no effect, your organization’s managed settings may set that key. A fix that adds an `excludedCommands` pattern removes the sandbox from the commands the pattern matches. See what an excluded command can do.
-###
-
-
-
-Commands fail with a host-not-allowed error
+### Commands fail with a host-not-allowed error
Many CLI tools need to reach specific hosts. Approve the host when prompted, or add it to [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>). If your organization locks the allowlist with `allowManagedDomainsOnly`, there’s no prompt, so ask your administrator to add the host.
-###
-
-
-
-`jest` hangs or fails
+### `jest` hangs or fails
`watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
-###
-
-
-
-Go-based CLIs fail TLS verification on macOS
+### Go-based CLIs fail TLS verification on macOS
Tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. To run these tools outside the sandbox, add a pattern for each tool, such as `gh *`, to `excludedCommands`. The tool then runs with your full access and its stored credentials. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
-###
-
-
-
-`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS
+### `open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS
The sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Claude Code ignores this key in project settings. Enabling `allowAppleEvents` removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add a pattern such as `open *` to `excludedCommands`. Each `open` call then goes through the permission flow, and `open` can launch any file or app, including one Claude wrote.
-###
-
-
-
-`docker` commands fail
+### `docker` commands fail
`docker` is incompatible with the sandbox. Take the `docker` commands you need out of the sandbox with an `excludedCommands` pattern such as `docker compose *`. Run commands outside the sandbox with `excludedCommands` explains what an excluded `docker` command can reach. A narrower pattern takes fewer commands out of the sandbox.
-###
-
-
-
-Chromium or rootless Podman fails inside the sandbox on Linux
+### Chromium or rootless Podman fails inside the sandbox on Linux
On Linux and WSL2, commands in the sandbox can’t create user namespaces by default, so tools that rely on them fail:
@@ -891,19 +695,11 @@
If you set `allowNestedUserNamespaces` to `true`, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox.Don’t rely on any of the sandbox’s restrictions, including protected paths and [`credentials.files`](</docs/en/settings-reference#sandbox-credentials-files>) entries, to stop a malicious command. In auto-allow mode, that command can run without a permission prompt. If your organization has a security team, check with them before you turn this setting on.
-###
-
-
-
-`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard
+### `pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard
The `pbcopy`, `xclip`, and `wl-copy` clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
-###
-
-
-
-A git command fails with `unable to unlink old`
+### A git command fails with `unable to unlink old`
`git merge`, `git checkout`, and similar commands fail with `unable to unlink old` when they need to replace a file the sandbox denies writes to. On Linux and WSL2 the error ends with `Read-only file system`. The file can be in one of these places:
@@ -913,35 +709,19 @@
After the failure, Claude may offer to rerun the command outside the sandbox. Approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself.
-###
-
-
-
-A git command fails with `Unable to create '…/index.lock'`
+### A git command fails with `Unable to create '…/index.lock'`
If you started Claude Code in a repository’s subdirectory, this error can mean `.git` is outside what sandboxed commands can write to. Start Claude Code from the repository root instead, or from the worktree’s root in a [linked worktree](</docs/en/worktrees>).
-###
-
-
-
-A folder named `objects` or `refs` disappears after a command
+### A folder named `objects` or `refs` disappears after a command
A top-level `objects` or `refs` folder that appeared during the session can be deleted after a sandboxed command ends. It doesn’t matter whether a command, Claude, or you created it. To keep a folder, leave something in it. If a `HEAD` file or symlink has been at the top level during the session, move it away, then restart every Claude Code session open there. Before v2.1.307, the folder was deleted even with something in it and no `HEAD`. On an earlier version, [update Claude Code](</docs/en/setup#update-claude-code>).
-###
-
-
-
-Bubblewrap fails to start inside a container
+### Bubblewrap fails to start inside a container
In an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since the setting exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
-###
-
-
-
-Ubuntu’s AppArmor restriction stops bubblewrap
+### Ubuntu’s AppArmor restriction stops bubblewrap
On Linux and WSL2, the message `Ubuntu's AppArmor restriction on user namespaces stops bubblewrap here` means that Ubuntu’s AppArmor restriction keeps the sandbox from starting. To get the sandbox to start, lift the restriction in one of these two ways:
@@ -950,11 +730,7 @@
Then restart Claude Code and confirm the sandbox works. Until you lift the restriction, commands run without the sandbox under the regular permission flow, or Claude Code refuses to start if [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) is `true`.
-###
-
-
-
-Sandboxed commands fail with `bwrap: setting up uid map: Permission denied`
+### Sandboxed commands fail with `bwrap: setting up uid map: Permission denied`
On Linux and WSL2, this error or `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted` can mean that Ubuntu’s AppArmor restriction on user namespaces is stopping bubblewrap. To check, run `sysctl kernel.apparmor_restrict_unprivileged_userns` in your shell:
@@ -963,11 +739,7 @@
Before v2.1.310, Claude Code didn’t check for this restriction at startup, so `/sandbox` didn’t report it.
-###
-
-
-
-0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
+### 0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. A placeholder stays behind in cases such as these:
@@ -976,11 +748,7 @@
Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Sandbox mask files left behind at write-deny paths`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind when a session was killed, without flagging them.
-###
-
-
-
-`git` over SSH fails with the sandbox on
+### `git` over SSH fails with the sandbox on
On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote fail inside the sandbox even when the host is allowed. On Linux and WSL2, they work once the host is allowed. Claude Code tunnels git’s SSH connection through the sandbox proxy, and the macOS tunnel can’t authenticate to that proxy. On Linux and WSL2, check these if the connection still fails:
@@ -1002,11 +770,7 @@
These entries match `git push origin main`. A call that adds a `cd`, uses `git -C`, or contains a command substitution stays sandboxed. The excluded git commands can reach any host, not only the ones in `allowedDomains`. Plain `ssh`, `scp`, and `rsync` over SSH fail for the reason the database client entry gives.
-###
-
-
-
-A database client or other non-HTTP tool fails to reach an allowed host
+### A database client or other non-HTTP tool fails to reach an allowed host
A tool that ignores the proxy environment variables can’t connect from inside the sandbox, even to a host in `allowedDomains`. A sandboxed command has no direct route to the network, so a tool that opens its own connection fails. Most database drivers, plain `ssh`, and tools that use UDP behave this way. The failure looks like a network or name resolution error:
@@ -1026,11 +790,7 @@
The script runs with your full access, and Claude can edit a script that’s inside your working directory, so review it when the prompt appears.
-###
-
-
-
-A command fails to reach a server on localhost
+### A command fails to reach a server on localhost
By default, a sandboxed command can’t connect directly to a server that’s running on your machine outside the sandbox, such as a dev server or a database in a container. What you can change depends on your platform:
@@ -1049,11 +809,7 @@
An `allowedDomains` entry for `localhost` applies to connections that go through the proxy, so it doesn’t change a direct connection. Claude Code sets `NO_PROXY` for sandboxed commands so that they connect to `localhost` directly instead of through the proxy. The entry also exposes every port on your machine’s localhost to a command that does use the proxy. For a development hostname that points at `127.0.0.1`, see An allowed hostname is refused with `resolved to a loopback address`.
-###
-
-
-
-An allowed hostname is refused with `resolved to a loopback address`
+### An allowed hostname is refused with `resolved to a loopback address`
The sandbox proxy refuses an allowed hostname that resolves to a local address, which affects development names such as `myapp.test` that point at `127.0.0.1`. The command sees a `403` response whose body names the kind of address, such as `Connection to myapp.test blocked: resolved to a loopback address`. Add the IP address the name resolves to alongside the hostname in `allowedDomains`, each with the port your server listens on:
@@ -1067,11 +823,7 @@
An IP address entry with no port lets sandboxed commands reach every service listening on that address. Before v2.1.284, the proxy connected to whatever address an allowed hostname resolved to.
-###
-
-
-
-Commands are refused with `Sandbox is required`
+### Commands are refused with `Sandbox is required`
If you require the sandbox with [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) and it fails in one of these ways after Claude Code starts, each sandboxed command Claude runs is refused with the message shown. The session keeps running, and the refused command doesn’t run unsandboxed:
@@ -1086,22 +838,14 @@
In a Linux session with `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` set, every command runs sandboxed, so excluded commands and commands you type are refused too.
-###
-
-
-
-`/sandbox` fails with `Sandbox settings are overridden by a higher-priority configuration`
+### `/sandbox` fails with `Sandbox settings are overridden by a higher-priority configuration`
`/sandbox` prints `Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.` instead of opening its panel when a higher [settings level](</docs/en/settings#settings-precedence>) sets `sandbox.enabled`, `sandbox.autoAllowBashIfSandboxed`, or `sandbox.allowUnsandboxedCommands`. The panel saves your choices to `.claude/settings.local.json`, and a value saved there can’t override those levels. Managed settings and `--settings` rank above local settings. To see which of them this session loaded, run `/status` and read the `Setting sources` line:
* **`Command line arguments`** : if you started Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>), check whether the file or JSON you passed sets one of those keys. If it does, change the value there, or start Claude Code again without those keys.
* **`Enterprise managed settings`** : your organization’s managed settings are loaded. If they set one of those keys, you can’t change that key from `/sandbox` or from any settings file you control, so ask your administrator.
-###
-
-
-
-`/sandbox` prints `Sandbox settings not changed`
+### `/sandbox` prints `Sandbox settings not changed`
This line means `/sandbox` couldn’t save the choice you made in its panel to your project’s `.claude/settings.local.json`:
@@ -1117,19 +861,11 @@
This turns on auto-allow mode. For regular permissions mode, also set [`sandbox.autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) to `false`. The change takes effect in your running session at the next shell command Claude runs, and the **Mode** tab of `/sandbox` then marks the mode in effect.
-##
-
-
-
-Limitations
+## Limitations
Sandboxing reduces risk but is not a complete isolation boundary. Review the limitations below before relying on it as a hard security control.
-###
-
-
-
-Security limitations
+### Security limitations
* **Network filtering** : the sandbox restricts which domains processes can connect to. By default the built-in proxy does not terminate or inspect TLS on outbound traffic, so the contents of encrypted connections are not examined. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting terminates TLS at the proxy for `mask` credential substitution but does not add content filtering. You are responsible for ensuring that only trusted domains are allowed in your policy.
@@ -1142,11 +878,7 @@
* **Mach and XPC services on macOS** : sandboxed commands can reach outside the sandbox to each service that you list in [`network.allowMachLookup`](</docs/en/settings-reference#sandbox-network-allowmachlookup>), and the sandbox doesn’t confine what those services do for those commands.
* **User namespaces on Linux and WSL2** : by default, sandboxed commands can’t create user namespaces. If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true`, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox. Before you turn this setting on, read the warning in Chromium or rootless Podman fails inside the sandbox on Linux.
-###
-
-
-
-Scope
+### Scope
The sandbox isolates shell commands and their child processes. What runs outside the sandbox lists the tools and helper processes it doesn’t cover. Computer use and subagents relate to the sandbox as follows:
@@ -1158,11 +890,7 @@
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
-##
-
-
-
-See also
+## See also
* [Sandbox environments](</docs/en/sandbox-environments>): compare the built-in sandbox with dev containers, containers, and VMs
* [Security](</docs/en/security>): security features and best practices
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -731,7 +731,7 @@
This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See strict sandbox mode for the sessions where typed commands run sandboxed. The sandbox doesn’t run on native Windows, so with `failIfUnavailable` set, Claude Code exits at startup on those machines. If your fleet includes Windows hosts, you can:
- * **Deliver the configuration by operating system** : deploy it through your MDM or as a [managed settings file](</docs/en/managed-settings#delivery-mechanisms>) on macOS and Linux machines only. [Server-managed settings](</docs/en/server-managed-settings#current-limitations>) apply to all users in the organization
+ * **Deliver the configuration by operating system** : deploy it through your MDM or as a [managed settings file](</docs/en/managed-settings#delivery-mechanisms>) on macOS and Linux machines only. [Server-managed settings](</docs/en/server-managed-settings#give-groups-different-settings>) follow the member, not the device.
* **Move Windows users into a supported environment** : have them run Claude Code inside WSL2 or a container
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -917,6 +917,14 @@
+A git command fails with `Unable to create '…/index.lock'`
+
+If you started Claude Code in a repository’s subdirectory, this error can mean `.git` is outside what sandboxed commands can write to. Start Claude Code from the repository root instead, or from the worktree’s root in a [linked worktree](</docs/en/worktrees>).
+
+###
+
+
+
A folder named `objects` or `refs` disappears after a command
A top-level `objects` or `refs` folder that appeared during the session can be deleted after a sandboxed command ends. It doesn’t matter whether a command, Claude, or you created it. To keep a folder, leave something in it. If a `HEAD` file or symlink has been at the top level during the session, move it away, then restart every Claude Code session open there. Before v2.1.307, the folder was deleted even with something in it and no `HEAD`. On an earlier version, [update Claude Code](</docs/en/setup#update-claude-code>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -33,6 +33,7 @@
* **Built-in file and web tools** : tools such as Read, Edit, Write, WebFetch, and WebSearch follow [permission rules](</docs/en/permissions>) instead. A `denyRead` entry doesn’t stop the Read tool, and `allowedDomains` doesn’t limit WebFetch
* **Other processes Claude Code starts** : command [hooks](</docs/en/hooks>), local [MCP servers](</docs/en/mcp>), [plugin monitors](</docs/en/plugins/components#monitors>), [LSP servers](</docs/en/tools-reference#lsp-tool-behavior>), and helper commands such as your [status line](</docs/en/statusline>) command and `apiKeyHelper` run with your full access
+ * **Mods** : a [mod](</docs/en/plugins/mods/overview>) runs its own code inside Claude Code, so its file access, network requests, and programs started with [`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>) aren’t sandboxed. See [What a mod can reach](</docs/en/plugins/mods/overview#what-a-mod-can-reach>)
Some shell commands also run outside the sandbox, depending on your settings:
Show diff (113 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -67,7 +67,7 @@
* **Overrides** : choose whether commands that fail under the sandbox can fall back to running unsandboxed. This is the [`allowUnsandboxedCommands`](</docs/en/settings-reference#sandbox-allowunsandboxedcommands>) setting
* **Config** : view the resolved sandbox settings
-If the panel shows only a Dependencies tab, a required package is missing. Install it as described in Set up Linux and WSL2, restart Claude Code, and run `/sandbox` again.
+If the panel shows only a Dependencies tab, the sandbox can’t start yet. Fix what the tab reports as described in Set up Linux and WSL2, restart Claude Code, and run `/sandbox` again.
2
@@ -85,7 +85,7 @@
claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'
-By default, if the sandbox can’t start because a dependency is missing or the platform is unsupported, Claude Code runs commands without sandboxing. To make Claude Code exit at startup instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. Managed deployments that require sandboxing as a security gate can use this setting.
+By default, when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code runs commands without sandboxing. To make Claude Code exit at startup instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. Managed deployments that require sandboxing as a security gate can use this setting.
###
@@ -123,11 +123,29 @@
sudo dnf install bubblewrap socat
-When a dependency is missing, the Dependencies tab in `/sandbox` lists which of `ripgrep`, `bubblewrap`, `socat`, and the seccomp filter your platform lacks. If you don’t see the tab after installing and restarting Claude Code, all dependencies are present. Ripgrep is bundled with the native Claude Code binary. The seccomp filter is optional and adds Unix domain socket blocking. Install it with `npm install -g @anthropic-ai/sandbox-runtime` if it is missing. When a required dependency is missing, the Dependencies tab is the only tab shown until you install it. When only the optional seccomp filter is missing, the Dependencies tab appears alongside the other tabs. The dependency check runs at startup, so restart Claude Code after installing packages for `/sandbox` to detect them.
-
-Ubuntu 24.04 and later: allow bubblewrap to create user namespaces
-
-On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation.To check whether your environment enforces this restriction, including inside WSL2, run `sysctl kernel.apparmor_restrict_unprivileged_userns`. If the command returns `0`, skip this step. If it prints a `No such file or directory` error, the key doesn’t exist and you can skip this step. If it returns `1`, add an AppArmor profile that grants `bwrap` this capability:
+When a dependency is missing, the Dependencies tab in `/sandbox` lists which of `ripgrep`, `bubblewrap`, `socat`, and the seccomp filter your platform lacks. If you don’t see the tab after installing and restarting Claude Code, all dependencies are present. Ripgrep is bundled with the native Claude Code binary. The seccomp filter is optional and adds Unix domain socket blocking. Install it with `npm install -g @anthropic-ai/sandbox-runtime` if it is missing.
+
+ * **Dependencies is the only tab** : the sandbox can’t start. Install what the tab lists as missing, or if it reports Ubuntu’s AppArmor restriction, add an AppArmor profile for bubblewrap
+ * **Dependencies appears beside the other tabs** : the tab lists a missing optional item, such as the seccomp filter. The sandbox can start without it, so install it only if you want what it adds
+
+The dependency check runs at startup, so restart Claude Code after installing packages for `/sandbox` to detect them.
+
+WSL2 notes
+
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
+
+####
+
+
+
+Add an AppArmor profile for bubblewrap
+
+Add the profile if Claude Code runs `/usr/bin/bwrap` and either of these happens:
+
+ * Claude Code reports Ubuntu’s AppArmor restriction on user namespaces
+ * Sandboxed commands fail with `bwrap: setting up uid map: Permission denied` or `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted` while that restriction is on
+
+Claude Code runs the first `bwrap` on `PATH`, unless managed settings name one in [`sandbox.bwrapPath`](</docs/en/settings-reference#sandbox-bwrappath>). To see which `bwrap` is first, run `which bwrap` in the shell you start Claude Code from. If Claude Code runs any path other than `/usr/bin/bwrap`, lift the restriction with `sysctl` instead. To add the profile for `/usr/bin/bwrap`, run this command:
sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
abi <abi/4.0>,
@@ -139,13 +157,11 @@
}
EOF
-The profile applies only to `bwrap` itself, not to the commands it runs inside the sandbox. Reload AppArmor to apply it:
+Reload AppArmor to apply it:
sudo systemctl reload apparmor
-WSL2 notes
-
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
+Then restart Claude Code and confirm the sandbox works.
###
@@ -704,7 +720,7 @@
The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
- * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than falling back to unsandboxed execution
+ * **`failIfUnavailable`** : when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code refuses to start rather than falling back to unsandboxed execution
* **`allowUnsandboxedCommands: false`** : Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can’t retry it unsandboxed
Consider these additions alongside them:
@@ -916,6 +932,32 @@
+Ubuntu’s AppArmor restriction stops bubblewrap
+
+On Linux and WSL2, the message `Ubuntu's AppArmor restriction on user namespaces stops bubblewrap here` means that Ubuntu’s AppArmor restriction keeps the sandbox from starting. To get the sandbox to start, lift the restriction in one of these two ways:
+
+ * Add an AppArmor profile for bubblewrap if Claude Code runs `/usr/bin/bwrap`
+ * In your shell, run `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`, which lifts the restriction for every program on the machine and lasts until you reboot
+
+Then restart Claude Code and confirm the sandbox works. Until you lift the restriction, commands run without the sandbox under the regular permission flow, or Claude Code refuses to start if [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) is `true`.
+
+###
+
+
+
+Sandboxed commands fail with `bwrap: setting up uid map: Permission denied`
+
+On Linux and WSL2, this error or `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted` can mean that Ubuntu’s AppArmor restriction on user namespaces is stopping bubblewrap. To check, run `sysctl kernel.apparmor_restrict_unprivileged_userns` in your shell:
+
+ * `kernel.apparmor_restrict_unprivileged_userns = 1`: the restriction is on. Add an AppArmor profile if Claude Code runs `/usr/bin/bwrap`, or run `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`, which lifts it for every program until you reboot. Then restart Claude Code and confirm the sandbox works
+ * Any other output: the restriction isn’t the cause. To report the failure, run [`/feedback`](</docs/en/commands#all-commands>) at the Claude Code prompt
+
+Before v2.1.310, Claude Code didn’t check for this restriction at startup, so `/sandbox` didn’t report it.
+
+###
+
+
+
0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. A placeholder stays behind in cases such as these:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1088,6 +1088,7 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
+ * **Mach and XPC services on macOS** : sandboxed commands can reach outside the sandbox to each service that you list in [`network.allowMachLookup`](</docs/en/settings-reference#sandbox-network-allowmachlookup>), and the sandbox doesn’t confine what those services do for those commands.
* **User namespaces on Linux and WSL2** : by default, sandboxed commands can’t create user namespaces. If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true`, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox. Before you turn this setting on, read the warning in Chromium or rootless Podman fails inside the sandbox on Linux.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -535,7 +535,7 @@
Denied paths that pass through a symlink
-On macOS, when a denied path passes through a symlink, such as a `~/.claude` that is a link into a dotfiles repository, the sandbox also denies the path’s real location. This covers the sandbox’s own denials and your literal `denyWrite` and `denyRead` entries.
+On macOS, when a denied path passes through a symlink, such as a `~/.claude` that is a link into a dotfiles repository, the sandbox also denies the path’s real location. This covers the sandbox’s own denials and your literal `denyWrite` and `denyRead` entries. A `denyWrite` entry that contains `*`, `?`, or `[` is also covered when a folder before the first of those characters is a symlink. For example, `~/.claude/*.json` is also denied under the real location of `~/.claude`.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -290,6 +290,7 @@
* **Every command in the call has to match** : `npm ci && docker compose build` stays sandboxed unless another entry covers `npm ci`
* **Claude Code matches the text of the call** : a script or `make` target that calls `docker` internally doesn’t match, and neither does `/usr/local/bin/docker`
* **Some calls stay sandboxed** : a redirect to a file, a `cd`, or a command substitution such as `$(...)` keeps the whole call sandboxed. The [reference entry](</docs/en/settings-reference#sandbox-excludedcommands>) lists more calls that stay sandboxed
+ * **A`git clone` needs relative paths**: your entry doesn’t cover a clone that names an absolute path, a path starting with `~`, or one with a `..` segment. If the clone can go inside your working directory, ask Claude to use a relative path with no `..` segment, such as `vendor/lib`
* **Where you save the entry can matter** : while the sandbox is admin-required, Claude Code ignores entries in `.claude/settings.json` and `.claude/settings.local.json`
An excluded command goes through the regular permission flow:
@@ -322,7 +323,7 @@
}
}
-The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. `sandbox.filesystem.disabled` defaults to `false`. Requires Claude Code v2.1.216 or later.
+The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. `sandbox.filesystem.disabled` defaults to `false`.
With filesystem isolation off and commands auto-allowed, a sandboxed command can write files that later commands run or read, such as shell startup files, executables on `$PATH`, or `~/.claude/settings.json`, and use them to widen its own access on the next run. Set `filesystem.disabled` to `true` only for workloads you trust not to escalate their own access. Locking network domains with `allowManagedDomainsOnly` narrows the risk but doesn’t remove it, since that lock applies only to commands running inside the sandbox.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -206,6 +206,8 @@
* **A matching allow rule** : if an allow rule such as `Bash(curl *)` matches the command, it also approves the retry, so the command runs outside the sandbox with no prompt
* **An ask rule for the parameter** : add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)` to be prompted on Bash retries. You get the prompt in auto mode and `bypassPermissions` mode too, and the rule takes precedence over a matching allow rule
* **[`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>)** : [Actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) covers the retries that prompt while it’s on
+
+While commands are refused with a `Sandbox is required` message, Claude Code ignores the `dangerouslyDisableSandbox` parameter and refuses the retry too.
####
@@ -915,7 +917,12 @@
0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
-On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Sandbox mask files left behind at write-deny paths`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
+On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. A placeholder stays behind in cases such as these:
+
+ * The session is killed before that cleanup runs, for example by SIGKILL
+ * The session exits while a sandboxed command is still running, such as a background command
+
+Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Sandbox mask files left behind at write-deny paths`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind when a session was killed, without flagging them.
###
@@ -1007,6 +1014,25 @@
}
An IP address entry with no port lets sandboxed commands reach every service listening on that address. Before v2.1.284, the proxy connected to whatever address an allowed hostname resolved to.
+
+###
+
+
+
+Commands are refused with `Sandbox is required`
+
+If you require the sandbox with [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) and it fails in one of these ways after Claude Code starts, each sandboxed command Claude runs is refused with the message shown. The session keeps running, and the refused command doesn’t run unsandboxed:
+
+ * **`Sandbox is required but failed to initialize:<reason>`**: Claude Code started, but the sandbox then failed to initialize. Take the step the message gives: `Restart to retry.` or `Fix the sandbox settings to retry`.
+ * **`Sandbox is required (sandbox.failIfUnavailable) and stopped being available in this session:<reason>`**: on Linux or WSL2, the sandbox started and Claude Code then found a dependency missing. Fix what the reason names, such as installing a missing dependency, then restart Claude Code.
+
+Excluded commands and commands you type yourself keep running, and Claude can’t retry a refused command unsandboxed:
+
+ * **Excluded commands** : commands that match an `excludedCommands` entry keep running outside the sandbox. When one writes to a [`filesystem.allowWrite`](</docs/en/settings-reference#sandbox-filesystem-allowwrite>) path outside your working directory, that write goes through the regular permission flow. Under an admin-required sandbox, Claude Code ignores entries from the repository’s settings
+ * **Commands you type at the[`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>)**: keep running outside the sandbox. In a [background session](</docs/en/agent-view>), they’re refused too
+ * **Unsandboxed retries** : Claude Code ignores the `dangerouslyDisableSandbox` parameter of an unsandboxed retry
+
+In a Linux session with `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` set, every command runs sandboxed, so excluded commands and commands you type are refused too.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -509,7 +509,7 @@
* **In your working directory and the directories above it** : the `.claude` settings files, the `.claude/skills`, `.claude/agents`, `.claude/commands`, and `.claude/hooks` directories, `.mcp.json`, and the files Claude Code runs on its own, such as `.claude/workflows` and `.claude/scheduled_tasks.json`
* **In your working directory only** : shell startup files such as `.bashrc` and `.zshrc`, `.gitconfig`, the `.vscode` and `.idea` directories, and `hooks` and `config` inside `.git`
- * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
+ * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` file or symlink sits beside them. A file named `config` is denied even with no `HEAD`. A `HEAD`, `objects`, or `refs` that appears later can be deleted. On Linux and WSL2, a sandboxed command can create one where none exists.
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. If you add an `allowWrite` entry or an `Edit` allow rule that covers one of these paths, the protection still applies. To turn the protection off, set `filesystem.disabled`, which also turns off the rest of filesystem isolation.
@@ -517,6 +517,14 @@
If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true` on Linux or WSL2, don’t rely on protected paths: code from a sandboxed command can end up running outside the sandbox.
To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
+
+####
+
+
+
+When the sandbox deletes `HEAD`, `objects`, or `refs`
+
+After a sandboxed command ends, a newer top-level `HEAD`, `objects`, or `refs` entry in your working directory is deleted unless it’s a folder with contents. Newer means the entry wasn’t there when the sandbox last built its configuration: at session start, or after a change such as [`/cd`](</docs/en/commands>). A newer `objects` or `refs` folder with contents is deleted too, with its contents, when a `HEAD` file or symlink was there the last time the sandbox built its configuration. To keep a folder, see A folder named `objects` or `refs` disappears after a command.
####
@@ -889,6 +897,14 @@
+A folder named `objects` or `refs` disappears after a command
+
+A top-level `objects` or `refs` folder that appeared during the session can be deleted after a sandboxed command ends. It doesn’t matter whether a command, Claude, or you created it. To keep a folder, leave something in it. If a `HEAD` file or symlink has been at the top level during the session, move it away, then restart every Claude Code session open there. Before v2.1.307, the folder was deleted even with something in it and no `HEAD`. On an earlier version, [update Claude Code](</docs/en/setup#update-claude-code>).
+
+###
+
+
+
Bubblewrap fails to start inside a container
In an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since the setting exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -899,7 +899,7 @@
0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
-On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
+On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Sandbox mask files left behind at write-deny paths`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -333,7 +333,7 @@
Because turning filesystem isolation off widens what sandboxed commands can do, Claude Code honors `filesystem.disabled` from these settings sources only:
* User settings, managed settings, and the `--settings` CLI flag can set it. Project settings in `.claude/settings.json` and `.claude/settings.local.json` can’t, so a checked-out project can’t switch filesystem isolation off.
- * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
+ * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps developers from turning filesystem isolation off in such a deployment; to turn it off for everyone, set `"disabled": true` in managed settings.
* When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key, even when Claude Code falls back to `deny` for it at startup. List a path that can’t be masked, such as a credential directory, as an explicit `deny` entry in managed settings, which locks the key.
@@ -512,7 +512,11 @@
* **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
-If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
+If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. If you add an `allowWrite` entry or an `Edit` allow rule that covers one of these paths, the protection still applies. To turn the protection off, set `filesystem.disabled`, which also turns off the rest of filesystem isolation.
+
+If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true` on Linux or WSL2, don’t rely on protected paths: code from a sandboxed command can end up running outside the sandbox.
+
+To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
####
@@ -715,8 +719,9 @@
* [`network.allowAllUnixSockets`](</docs/en/settings-reference#sandbox-network-allowallunixsockets>)
* [`network.allowLocalBinding`](</docs/en/settings-reference#sandbox-network-allowlocalbinding>)
* [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>), which a repository can’t turn on
-
-Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). With the lock on, only managed settings can set a proxy port. When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key. See Which settings can disable it.
+ * [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>), which a repository can’t turn on
+
+Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). With `allowManagedDomainsOnly` on, only managed settings can set a proxy port. When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t turn filesystem isolation off with that key. A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key. See Which settings can disable it.
####
@@ -842,6 +847,26 @@
+Chromium or rootless Podman fails inside the sandbox on Linux
+
+On Linux and WSL2, commands in the sandbox can’t create user namespaces by default, so tools that rely on them fail:
+
+ * Chromium exits with `No usable sandbox!`
+ * `unshare -U true` prints `unshare: unshare failed: Operation not permitted`. With [`allowAllUnixSockets`](</docs/en/settings-reference#sandbox-network-allowallunixsockets>) on, it can print `No space left on device` instead
+ * Rootless Podman prints `cannot clone: Operation not permitted`, or stops earlier with `read-only file system` on one of its own folders
+
+In a session with [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars#variables>) set to `1`, start Chromium or Electron with `--no-sandbox`, and run any other tool yourself outside Claude Code. In that session, every command runs sandboxed, and the settings that the other fixes below name have no effect. Each fix works for the tools it names and gives up some isolation:
+
+ * For Chromium or Electron, start the browser with `--no-sandbox`. The Claude Code sandbox stays as it is, but the browser runs web content without its own sandbox.
+ * For rootless Podman, Buildah, or a script or test command that runs a browser or `unshare`, add a pattern to `sandbox.excludedCommands`, such as `podman *`. Commands that match run outside the sandbox with your full access, and Claude can edit a script in your working directory before running it. The pattern has to match the command Claude runs, so for a browser, match the test command rather than the browser.
+ * To keep Chromium’s or Electron’s own sandbox, or to run a nested bubblewrap or `unshare`, set [`sandbox.allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true` in `~/.claude/settings.json`, not the project’s `.claude/settings.json`. Requires Claude Code v2.1.305 or later. A command that begins with `unshare` stays sandboxed whatever `excludedCommands` pattern you list, because `unshare` can start any other program. This setting alone isn’t enough for rootless Podman or Buildah, which the sandbox stops in other ways too.
+
+If you set `allowNestedUserNamespaces` to `true`, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox.Don’t rely on any of the sandbox’s restrictions, including protected paths and [`credentials.files`](</docs/en/settings-reference#sandbox-credentials-files>) entries, to stop a malicious command. In auto-allow mode, that command can run without a permission prompt. If your organization has a security team, check with them before you turn this setting on.
+
+###
+
+
+
`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard
The `pbcopy`, `xclip`, and `wl-copy` clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
@@ -1020,6 +1045,7 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
+ * **User namespaces on Linux and WSL2** : by default, sandboxed commands can’t create user namespaces. If you set [`allowNestedUserNamespaces`](</docs/en/settings-reference#sandbox-allownestedusernamespaces>) to `true`, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox. Before you turn this setting on, read the warning in Chromium or rootless Podman fails inside the sandbox on Linux.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -514,6 +514,14 @@
If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
+####
+
+
+
+Denied paths that pass through a symlink
+
+On macOS, when a denied path passes through a symlink, such as a `~/.claude` that is a link into a dotfiles repository, the sandbox also denies the path’s real location. This covers the sandbox’s own denials and your literal `denyWrite` and `denyRead` entries.
+
###
@@ -980,7 +988,15 @@
✗ Sandbox settings not changed: /home/you/project/.claude/settings.local.json couldn't be updated (EACCES). Start Claude Code in a project folder you can write to.
-If the reason in parentheses is `EACCES`, `EPERM`, or `EROFS`, start Claude Code in a project folder you can write to, then run `/sandbox` again in that session. If the reason begins with `Invalid JSON syntax in settings file`, correct the JSON in your project’s `.claude/settings.local.json`, then run `/sandbox` again.
+If the reason in parentheses is `EACCES`, `EPERM`, or `EROFS`, start Claude Code in a project folder you can write to, then run `/sandbox` again in that session. If the reason begins with `Invalid JSON syntax in settings file`, correct the JSON in your project’s `.claude/settings.local.json`, then run `/sandbox` again. If no writable project folder is available to you, turn the sandbox on from your user settings instead. Add this to `~/.claude/settings.json`:
+
+ {
+ "sandbox": {
+ "enabled": true
+ }
+ }
+
+This turns on auto-allow mode. For regular permissions mode, also set [`sandbox.autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) to `false`. The change takes effect in your running session at the next shell command Claude runs, and the **Mode** tab of `/sandbox` then marks the mode in effect.
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -163,8 +163,8 @@
Claude Code approves a command automatically, with no prompt, when the command runs inside the sandbox. A command goes through the regular [permission flow](</docs/en/permissions>) when it runs outside the sandbox because it matches `excludedCommands` or because Claude retries it unsandboxed. A sandboxed command that connects to a host you haven’t allowed stays in the sandbox. Hosts outside your allowed domains covers who decides whether the connection goes through. Even in auto-allow mode, the following still apply:
- * Explicit [deny rules](</docs/en/permissions>) are always respected
- * `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
+ * A command in a [form that a `Bash` deny rule matches](</docs/en/permissions#bash-rule-limits>) is still blocked
+ * `rm` or `rmdir` commands recognized as targeting a [critical path](</docs/en/permission-modes#which-paths-are-critical>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that run outside the sandbox. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
* [Monitor tool](</docs/en/tools-reference#monitor-tool>) commands aren’t approved automatically, though they still run in the sandbox. To skip the prompt, add an [allow rule](</docs/en/permissions#bash>) that matches the command, such as `Bash(npm run *)`
@@ -970,6 +970,18 @@
* **`Command line arguments`** : if you started Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>), check whether the file or JSON you passed sets one of those keys. If it does, change the value there, or start Claude Code again without those keys.
* **`Enterprise managed settings`** : your organization’s managed settings are loaded. If they set one of those keys, you can’t change that key from `/sandbox` or from any settings file you control, so ask your administrator.
+###
+
+
+
+`/sandbox` prints `Sandbox settings not changed`
+
+This line means `/sandbox` couldn’t save the choice you made in its panel to your project’s `.claude/settings.local.json`:
+
+ ✗ Sandbox settings not changed: /home/you/project/.claude/settings.local.json couldn't be updated (EACCES). Start Claude Code in a project folder you can write to.
+
+If the reason in parentheses is `EACCES`, `EPERM`, or `EROFS`, start Claude Code in a project folder you can write to, then run `/sandbox` again in that session. If the reason begins with `Invalid JSON syntax in settings file`, correct the JSON in your project’s `.claude/settings.local.json`, then run `/sandbox` again.
+
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -166,8 +166,16 @@
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
- * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
+ * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that run outside the sandbox. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
* [Monitor tool](</docs/en/tools-reference#monitor-tool>) commands aren’t approved automatically, though they still run in the sandbox. To skip the prompt, add an [allow rule](</docs/en/permissions#bash>) that matches the command, such as `Bash(npm run *)`
+
+Some sandboxed commands also go through the regular [permission flow](</docs/en/permissions>) instead of being approved automatically. This happens with commands such as `FOO=bar npm test`, where a variable set in front of a command can change which program runs, and with `make CC=clang` or `eval "ls"`. Your allow rules and permission mode then decide whether you see a prompt, and the command still runs inside the sandbox. For these three commands, an [allow rule](</docs/en/permissions#bash>) that matches the command stops a recurring prompt. These rules show the pattern:
+
+ * `Bash(make *)` approves `make CC=clang`
+ * `Bash(FOO=bar npm *)` approves `FOO=bar npm test`. When the command starts with a variable assignment, include the assignment in the rule
+ * `Bash(eval "ls")` approves `eval "ls"`. A wildcard rule such as `Bash(eval *)` doesn’t stop this prompt, so write a rule that matches the whole command
+
+An allow rule that matches a command also approves an unsandboxed retry of it, so the command can run outside the sandbox with no prompt.
Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -167,6 +167,7 @@
* `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
+ * [Monitor tool](</docs/en/tools-reference#monitor-tool>) commands aren’t approved automatically, though they still run in the sandbox. To skip the prompt, add an [allow rule](</docs/en/permissions#bash>) that matches the command, such as `Bash(npm run *)`
Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -612,7 +612,7 @@
Permission rules and sandboxing control different things:
* **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to every tool: Bash, Read, Edit, WebFetch, MCP, and others, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains.
- * **Sandboxing** provides OS-level enforcement that restricts what shell commands can access at the filesystem and network level. It applies only to Bash, PowerShell, and [Monitor](</docs/en/tools-reference#monitor-tool>) commands and their child processes.
+ * **Sandboxing** provides OS-level enforcement that restricts what shell commands can access at the filesystem and network level. It applies to Bash, PowerShell, and [Monitor](</docs/en/tools-reference#monitor-tool>) tool commands and their child processes.
The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -994,6 +994,8 @@
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
+ * **Background sessions** : a [background session](</docs/en/agent-view>) runs in its own process, and its Bash commands are sandboxed when [its settings](</docs/en/agent-view#settings-and-provider>) enable sandboxing.
+ * **A boundary around the whole process** : to put the processes in What runs outside the sandbox behind a boundary too, run Claude Code (local mode) inside the [sandbox runtime](</docs/en/sandbox-environments#sandbox-runtime>) with a network allowlist limited to the hosts you approve, or in the [dev container](</docs/en/devcontainer>) with its firewall script. For the background service and the sessions it hosts, see [Run Claude Code behind a corporate launcher](</docs/en/corporate-launcher>).
* **Mods** : a [mod](</docs/en/plugins/mods/overview>) is a plugin that runs its own code inside Claude Code, and a process that a mod starts runs outside the sandbox. See [What a mod can reach](</docs/en/plugins/mods/overview#what-a-mod-can-reach>).
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1005,7 +1005,7 @@
See also
* [Sandbox environments](</docs/en/sandbox-environments>): compare the built-in sandbox with dev containers, containers, and VMs
- * [Security](</docs/en/security>): comprehensive security features and best practices
+ * [Security](</docs/en/security>): security features and best practices
* [Permissions](</docs/en/permissions>): permission configuration and access control
* [All settings](</docs/en/settings-reference>): every settings key
* [CLI reference](</docs/en/cli-reference>): command-line options
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -387,7 +387,7 @@
When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
- * **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup.
+ * **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. To check for this misconfiguration, run `claude doctor` in your terminal and look for the `TLS termination is unavailable` warning.
* **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
* **A trusted settings scope** : masking authorizes the proxy to send your real credential somewhere, so Claude Code honors `mask` entries, `network.tlsTerminate`, [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), `awsPairs`, and `sigv4` only from user settings, managed settings, and the `--settings` flag. It ignores them in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -385,7 +385,7 @@
Mask credentials
-When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. Masking environment variables requires Claude Code v2.1.199 or later. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
+When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
* **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup.
* **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
@@ -533,7 +533,7 @@
In a `WebFetch(domain:...)` rule, the sandbox honors two wildcard forms: a leading `*.`, such as `*.example.com`, and a bare `*`. The bare `*` form requires Claude Code v2.1.186 or later. A wildcard in any other position, such as `WebFetch(domain:example.*)`, still matches fetches but has no effect on sandboxed commands.
-The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
+The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
####
Show diff (868 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,14 +1,57 @@
-The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash, PowerShell, or Monitor command and its child processes.
-
-To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>). To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>).
+The Bash sandbox is a boundary that the operating system enforces around the shell commands Claude runs on your machine. You set which files and network domains those commands can reach, and the limits apply to Bash, PowerShell, and Monitor commands and the processes they start. Because the operating system applies the limits while a command runs, Claude Code can run sandboxed commands without asking you to approve each one. The sandbox covers shell commands only. Claude’s file tools, MCP servers, and hooks run outside it. The sandbox runs on macOS, Linux, and WSL2. On native Windows, Claude Code runs commands unsandboxed. To use the sandbox on a Windows machine, run Claude Code inside a WSL2 distribution.
+
+This page covers the sandbox around shell commands on your own machine. Other pages cover related questions:
+
+ * For how a cloud session is isolated, see [Security and isolation](</docs/en/claude-code-on-the-web#security-and-isolation>)
+ * To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>)
+ * To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>)
##
+What the sandbox restricts
+
+While the sandbox is on, the shell commands Claude runs start inside its boundary, and so do the processes they start. The sandbox is off by default. To turn it on, run `/sandbox` in a session, as Get started shows, or set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in a [settings file](</docs/en/settings>) such as `~/.claude/settings.json`. The table shows what a sandboxed command can reach by default and the settings that change each default.
+
+Access| Default| Change it with
+---|---|---
+Writes| The working directory, a per-user temp directory, and [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>). Protected paths stay write-denied| [`filesystem.allowWrite`](</docs/en/settings-reference#sandbox-filesystem-allowwrite>), [`filesystem.denyWrite`](</docs/en/settings-reference#sandbox-filesystem-denywrite>)
+Reads| Most of the machine, including credential files such as `~/.ssh` and `~/.aws/credentials`| [`filesystem.denyRead`](</docs/en/settings-reference#sandbox-filesystem-denyread>), `credentials`
+Network| No direct route out. Connections go through a proxy on your machine that checks each host against your allowed domains, which start empty. Your permission mode decides what happens to other hosts| [`network.allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>), [`network.deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>)
+Environment variables| Inherited from Claude Code, including any secrets in its environment| `credentials`, [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>)
+
+Claude Code builds the sandbox on the open source [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package.
+
+###
+
+
+
+What runs outside the sandbox
+
+The sandbox wraps shell commands. These tools and processes run outside it:
+
+ * **Built-in file and web tools** : tools such as Read, Edit, Write, WebFetch, and WebSearch follow [permission rules](</docs/en/permissions>) instead. A `denyRead` entry doesn’t stop the Read tool, and `allowedDomains` doesn’t limit WebFetch
+ * **Other processes Claude Code starts** : command [hooks](</docs/en/hooks>), local [MCP servers](</docs/en/mcp>), [plugin monitors](</docs/en/plugins/components#monitors>), [LSP servers](</docs/en/tools-reference#lsp-tool-behavior>), and helper commands such as your [status line](</docs/en/statusline>) command and `apiKeyHelper` run with your full access
+
+Some shell commands also run outside the sandbox, depending on your settings:
+
+ * **Commands you type yourself** : a command you enter at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) runs unsandboxed in most sessions. Strict sandbox mode lists the sessions where a command you type runs sandboxed
+ * **Excluded commands** : commands that match `excludedCommands` run unsandboxed
+ * **Unsandboxed retries** : Claude can ask to run a command unsandboxed, usually after it fails in the sandbox
+
+To put the tools, processes, and commands in this section behind one boundary, run the Claude Code process itself in a [container, virtual machine, or the sandbox runtime](</docs/en/sandbox-environments>).
+
+##
+
+
+
Get started
-The sandbox is built into Claude Code and runs on macOS, Linux, and WSL2. Native Windows is not supported. On Windows, run Claude Code inside a WSL2 distribution. On macOS, there is nothing to install: sandboxing uses the built-in Seatbelt framework. On Linux and WSL2, the sandbox relies on two packages, covered in Set up Linux and WSL2. Even if you haven’t installed them yet, you can start with `/sandbox`, because its panel shows whether anything is missing.
+The sandbox is built into Claude Code. What you install depends on your platform:
+
+ * **macOS** : sandboxing uses the built-in Seatbelt framework, so you can go straight to the steps
+ * **Linux and WSL2** : the sandbox relies on `bubblewrap` and `socat`, covered in Set up Linux and WSL2. Even if you haven’t installed them yet, you can start with `/sandbox`, because its panel shows whether anything is missing
1
@@ -36,13 +79,28 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, a [per-user temp directory](</docs/en/env-vars>), and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, a [per-user temp directory](</docs/en/env-vars>), and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see Bubblewrap fails to start inside a container.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings. To change the sandbox for one session without writing to a settings file, start Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>). For example, this command starts a sandboxed session in which Claude can’t retry a blocked command outside the sandbox:
claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'
-By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+By default, if the sandbox can’t start because a dependency is missing or the platform is unsupported, Claude Code runs commands without sandboxing. To make Claude Code exit at startup instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. Managed deployments that require sandboxing as a security gate can use this setting.
+
+###
+
+
+
+Confirm commands run inside the sandbox
+
+To check that the sandbox is working, ask Claude to run each line in the table. What you type at the `!` prompt usually runs outside the sandbox, so typing a line yourself doesn’t test it.
+
+Command| Result inside the sandbox
+---|---
+`touch ~/sandbox-probe`| Fails with `Operation not permitted` on macOS, or `Read-only file system` on Linux and WSL2
+`curl --noproxy '*' https://example.com`| Fails with `Could not resolve host`, because the command has no route around the sandbox proxy
+
+If Claude asks to retry a failed command outside the sandbox, decline the retry. If `touch` succeeds and your home directory isn’t one of the directories the sandbox lets commands write to, delete `~/sandbox-probe`. Then run `/sandbox` to check that the sandbox is on and its dependencies are installed.
###
@@ -50,7 +108,7 @@
Set up Linux and WSL2
-On Linux and WSL2, the sandbox relies on two packages:
+On Linux and WSL2, the sandbox relies on these packages:
* [`bubblewrap`](<https://github.com/containers/bubblewrap>): the unprivileged sandboxing tool that enforces filesystem isolation
* [`socat`](<http://www.dest-unreach.org/socat/>): the relay used to route network traffic through the sandbox proxy
@@ -87,7 +145,7 @@
WSL2 notes
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`; to keep them out of the sandbox entirely, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`, which opens every Unix socket to sandboxed commands.
###
@@ -103,14 +161,14 @@
Auto-allow mode
-When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode. Even in auto-allow mode, the following still apply:
+Claude Code approves a command automatically, with no prompt, when the command runs inside the sandbox. A command goes through the regular [permission flow](</docs/en/permissions>) when it runs outside the sandbox because it matches `excludedCommands` or because Claude retries it unsandboxed. A sandboxed command that connects to a host you haven’t allowed stays in the sandbox. Hosts outside your allowed domains covers who decides whether the connection goes through. Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
- * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-
-Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+ * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones
+
+Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan.
####
@@ -126,7 +184,27 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow. In Manual mode you get a confirmation prompt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier evaluates the underlying command. While [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on, a retry that needs approval to run outside the sandbox prompts you instead. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the escape hatch disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter, and every command Claude runs must run sandboxed unless you’ve listed it in `excludedCommands`. The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
+The unsandboxed retry is an escape hatch for commands that fail inside the sandbox, such as tools that are incompatible with it. When the sandbox blocks a network connection, Claude Code names the denied host in the command’s result, so Claude sees what was blocked. Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs unsandboxed. In an interactive terminal session, who approves it depends on your permission mode:
+
+ * **`bypassPermissions` mode**: the retry runs without a prompt
+ * **Manual mode and`acceptEdits` mode**: you get a prompt titled “Bash command (unsandboxed)”
+ * **[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)** : a separate classifier model evaluates the underlying command
+ * **`dontAsk` mode**: Claude Code denies the retry
+ * **Plan mode** : see [how Claude Code gates commands while you plan](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>)
+
+These rules and settings change who approves the retry:
+
+ * **A matching allow rule** : if an allow rule such as `Bash(curl *)` matches the command, it also approves the retry, so the command runs outside the sandbox with no prompt
+ * **An ask rule for the parameter** : add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)` to be prompted on Bash retries. You get the prompt in auto mode and `bypassPermissions` mode too, and the rule takes precedence over a matching allow rule
+ * **[`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>)** : [Actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) covers the retries that prompt while it’s on
+
+####
+
+
+
+Turn off the retry with strict sandbox mode
+
+You can disable the unsandboxed retry by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the retry disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter. While the sandbox is running, commands Claude runs are then sandboxed unless they match an `excludedCommands` entry. To keep Claude Code from running commands unsandboxed when the sandbox can’t start, also set [`failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>). The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. A `false` in your user settings, `--settings`, or managed settings holds even when a project’s settings set `true`. A `false` in your user settings doesn’t make the sandbox admin-required, so a project’s other sandbox settings still apply. Before v2.1.285, a project’s `true` overrode a `false` in your user settings. If you or your administrator disable the retry in managed settings or with the `--settings` flag, the sandbox becomes admin-required. Claude Code then ignores the settings in a repository’s files that loosen the sandbox, `excludedCommands` entries included. Repository settings under an admin-required sandbox lists them. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
* **A[background session](</docs/en/agent-view>)**: strict sandbox mode covers shell-mode commands too
* **A Linux session with[`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars#variables>) set**: every command runs sandboxed, shell-mode commands included
@@ -158,15 +236,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining paths from every scope rather than replacing one scope’s array with another’s. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Path prefixes control how paths are resolved:
-
-Prefix| Meaning| Example
----|---|---
-`/`| Absolute path from filesystem root| `/tmp/build` stays `/tmp/build`
-`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
-`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining the paths rather than replacing one scope’s array with another’s. Claude Code leaves an entry out of the merge when a lock under Keep developers from widening the policy covers it. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute and `~/.kube` is relative to your home directory. This differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. For relative paths, trailing slashes, and wildcards, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
Example rules| Result
---|---
@@ -174,7 +244,7 @@
`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. The deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
`"allowRead": ["~/"]` with `"denyRead": ["~/**/.env"]`| Every `.env` under the home directory stays blocked and the rest is readable. A [wildcard deny](</docs/en/settings-reference#sandbox-path-prefixes>) holds inside a wider allow the same way an exact path does
-The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
+The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root when the configuration lives in project settings:
{
"sandbox": {
@@ -187,6 +257,39 @@
}
If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule. To deny sandboxed commands read access to home directories and mounted volumes while keeping the working directories readable, set [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) instead of writing path rules.
+
+###
+
+
+
+Run commands outside the sandbox with `excludedCommands`
+
+List a command pattern in [`sandbox.excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) to run matching commands outside the sandbox, which means no filesystem restrictions and no network proxy. Use it for a tool that can’t work inside the sandbox and that you trust with your full access. A tool that needs one more directory or one more host may work with `allowWrite` or `allowedDomains`, which keep the command sandboxed. This example takes `docker compose` commands out of the sandbox. Save it in `~/.claude/settings.json` to apply it to all of your projects:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "excludedCommands": ["docker compose *"]
+ }
+ }
+
+Claude Code checks your entries against each Bash and Monitor call. A call is the whole command line Claude sends, which can chain several commands. The following rules decide whether a call leaves the sandbox:
+
+ * **End the pattern with` *`**: entries use the same syntax as a `Bash(...)` [permission rule](</docs/en/permissions#permission-rule-syntax>), where a pattern with no wildcard is an exact match. `docker` matches only `docker` with no arguments. `docker *` matches `docker` with or without arguments
+ * **Every command in the call has to match** : `npm ci && docker compose build` stays sandboxed unless another entry covers `npm ci`
+ * **Claude Code matches the text of the call** : a script or `make` target that calls `docker` internally doesn’t match, and neither does `/usr/local/bin/docker`
+ * **Some calls stay sandboxed** : a redirect to a file, a `cd`, or a command substitution such as `$(...)` keeps the whole call sandboxed. The [reference entry](</docs/en/settings-reference#sandbox-excludedcommands>) lists more calls that stay sandboxed
+ * **Where you save the entry can matter** : while the sandbox is admin-required, Claude Code ignores entries in `.claude/settings.json` and `.claude/settings.local.json`
+
+An excluded command goes through the regular permission flow:
+
+ * [Read-only commands](</docs/en/permissions#read-only-commands>) and commands your allow rules cover run without a prompt
+ * In auto mode, the classifier reviews other excluded commands
+ * In `bypassPermissions` mode, an excluded command runs without a prompt unless an ask rule matches it
+
+To confirm an entry matches, switch to Manual mode and ask Claude to run a matching command that changes something, such as `docker compose up -d`. The permission prompt is titled “Bash command (unsandboxed)”.
+
+An excluded command runs with your full access. A broad entry such as `docker *` covers everything that tool can do. If you write a pattern that covers an interpreter, a script inside your working directory, or a tool that acts on a file there, as `docker compose` does with its compose file, Claude can write that file and then run it outside the sandbox. A narrower pattern leaves less that Claude can run outside the sandbox.
###
@@ -208,7 +311,7 @@
}
}
-The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. The setting is off by default and applies on the platforms where the sandbox runs: macOS, Linux, and WSL2. Requires Claude Code v2.1.216 or later.
+The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. `sandbox.filesystem.disabled` defaults to `false`. Requires Claude Code v2.1.216 or later.
With filesystem isolation off and commands auto-allowed, a sandboxed command can write files that later commands run or read, such as shell startup files, executables on `$PATH`, or `~/.claude/settings.json`, and use them to widen its own access on the next run. Set `filesystem.disabled` to `true` only for workloads you trust not to escalate their own access. Locking network domains with `allowManagedDomainsOnly` narrows the risk but doesn’t remove it, since that lock applies only to commands running inside the sandbox.
@@ -224,16 +327,7 @@
* When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
* When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
-Whether a managed `credentials.files` entry pins `filesystem.disabled`, locking the key to managed settings so developers can’t turn filesystem isolation off, depends on the entry’s `mode` and what happens to the entry when the sandbox starts:
-
-Managed entry| Pins `filesystem.disabled`| What protects the file when isolation is off
----|---|---
-`"mode": "deny"`| Yes| Nothing: the read block is part of the filesystem layer
-`"mode": "mask"`, applied as a mask| No| Masking itself: the sentinel copy and proxy on Linux and WSL2, the sandbox’s own read rules on macOS
-`"mode": "mask"`, fallen back to `deny` at setup| No| Nothing, same as `deny`. List a path that can’t be masked, such as a directory, as an explicit `deny` entry, which pins the key
-`"mode": "mask"`, [degraded to `deny` by validation](</docs/en/managed-settings#invalid-entries-in-managed-settings>)| Yes, like an explicit `deny`| Nothing, same as `deny`
-
-A fallback happens when the sandbox starts, after Claude Code has already read the settings the pin check runs on, so a fallen-back entry never pins. Validation rewrites an invalid entry to `deny` while settings load, so a degraded entry pins like one you wrote as `deny`.
+A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key, even when Claude Code falls back to `deny` for it at startup. List a path that can’t be masked, such as a credential directory, as an explicit `deny` entry in managed settings, which locks the key.
####
@@ -281,7 +375,7 @@
Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings-reference#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings. Claude Code merges the `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) the session loads. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. When you exclude a settings source:
* **Project or local settings** : Claude Code applies none of their `credentials` entries. Requires Claude Code v2.1.246 or later.
- * **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions, but drops its environment variable `mask` entries.
+ * **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions that no longer authorize the proxy to substitute the real value, but drops its environment variable `mask` entries.
There is no built-in credential deny list, so only the files and variables you list are restricted. `sandbox.credentials` affects sandboxed Bash commands only. To strip credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
@@ -291,7 +385,11 @@
Mask credentials
-Masking goes further than a `deny` entry under Protect credentials. Instead of blocking a credential, Claude Code shows sandboxed commands a placeholder, the sentinel, and the sandbox proxy swaps in the real value on outbound requests to hosts you allow. For files, the substitution is Linux and WSL2 behavior; macOS blocks the file instead.
+When you mask a credential, Claude Code shows sandboxed commands a per-session placeholder called the sentinel, and the sandbox proxy substitutes the real value on outbound requests to hosts you allow. A `deny` entry under Protect credentials blocks the credential instead. For files on macOS, Claude Code blocks the file instead of masking it. Masking environment variables requires Claude Code v2.1.199 or later. The [`sandbox.credentials`](</docs/en/settings-reference#sandbox-credentials>) reference lists every field. Masking requires the following:
+
+ * **TLS termination** : the proxy substitutes the real value inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup.
+ * **An allowed destination** : each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` host must also be reachable through `network.allowedDomains`. For a `mask` entry with no `injectHosts`, the proxy substitutes the real value on requests to every host in `network.allowedDomains`.
+ * **A trusted settings scope** : masking authorizes the proxy to send your real credential somewhere, so Claude Code honors `mask` entries, `network.tlsTerminate`, [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), `awsPairs`, and `sigv4` only from user settings, managed settings, and the `--settings` flag. It ignores them in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>).
####
@@ -299,7 +397,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`.
+To mask an environment variable, set `"mode": "mask"` on its `credentials.envVars` entry. The command and anything it logs never hold the real credential, but its requests still authenticate. When the same variable is listed with `deny` in any scope, `deny` takes precedence. This example masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`:
{
"sandbox": {
@@ -317,21 +415,12 @@
}
}
-Spell an IPv6 destination differently in the two lists, because each list has its own matcher:
-
- * **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
- * **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-
-`claude doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>). When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
-
- * `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
- * `onExtractNoMatch` controls what happens when the pattern matches nothing:
- * `warn`, the default, warns and passes the variable through unmasked
- * `deny` unsets the variable inside the sandbox
- * `error` stops sandbox setup until you fix the configuration
- * `decode: "jwt"`: for a variable holding a JSON Web Token (JWT). Claude Code verifies the value is a JWT and replaces it with a structurally valid fake token, so code inside the sandbox that decodes the token keeps working. Add `maskClaims` to list top-level payload claims to mask individually instead of replacing the whole token; the other claims stay readable. When the value doesn’t verify as a JWT, or no listed claim matches, Claude Code passes the variable through unmasked with a warning. `decode` can’t be combined with `extract`.
-
-See the [`credentials.envVars[]` rows in the settings reference](</docs/en/settings-reference#sandbox-settings>) for the full field list.
+Masking replaces the whole value by default. For a value with structure, such as a `DATABASE_URL` connection string or a JWT, use the [`extract`, `decode`, `maskClaims`, and `onExtractNoMatch` fields](</docs/en/settings-reference#sandbox-credentials-envvars>) so tools that parse the value keep working. For an IPv6 destination, spell the address differently in the two lists:
+
+ * **`network.allowedDomains`** : the bracketed form, such as `"[::1]"`
+ * **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"`
+
+The proxy matches each `injectHosts` entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches. `claude doctor` flags entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later.
####
@@ -339,36 +428,7 @@
Re-sign AWS requests
-AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential lives in variables with other names, group them yourself with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. This example adds the pairing to a configuration that already masks `MY_KEY_ID`, `MY_SECRET_KEY`, and `MY_SESSION_TOKEN` whole-value, as in the masking configuration above:
-
- {
- "sandbox": {
- "credentials": {
- "awsPairs": [
- {
- "accessKeyIdVar": "MY_KEY_ID",
- "secretAccessKeyVar": "MY_SECRET_KEY",
- "sessionTokenVar": "MY_SESSION_TOKEN"
- }
- ]
- }
- }
- }
-
-Each entry follows these rules:
-
- * `accessKeyIdVar` and `secretAccessKeyVar` name the masked `envVars` entries holding the access key ID and the secret key. The optional `sessionTokenVar` names the entry holding the session token for temporary credentials; when set, the proxy sends the real token as `x-amz-security-token` on re-signed requests.
- * Each named variable must be a `mask` entry that masks its entire value, without `extract` or `decode`.
- * The proxy re-signs requests on the hosts listed in the access key ID entry’s `injectHosts`.
- * Naming any of the conventional variables in a pair replaces the automatic pairing.
-
-Like `mask` entries, `awsPairs` is honored only from user settings, managed settings, and the `--settings` CLI flag. Three AWS request forms carry signatures the proxy can’t recompute. When such a request is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature; requests signed with unmasked credentials are never affected. The [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>) setting, which requires Claude Code v2.1.224 or later, relaxes this per form: setting a form’s key to `passthrough` forwards the request with its placeholder-derived signature, so the calling tool receives AWS’s own rejection response instead of a proxy error. Like `awsPairs`, `sigv4` is honored only from user settings, managed settings, and the `--settings` CLI flag.
-
-Request form| `sigv4` key| Why the proxy can’t re-sign it
----|---|---
-aws-chunked streaming uploads| `streaming`| Per-chunk signatures chain off the seed signature, so re-signing would require rewriting the body
-Presigned URLs| `presigned`| The signature lives in the URL itself, with no `Authorization` header
-SigV4A asymmetric signatures| `sigv4a`| There is no shared-key HMAC to recompute
+AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs the request with the real values, which requires Claude Code v2.1.221 or later. If you mask only the secret, requests are signed with a placeholder the proxy can’t detect, so they fail at AWS. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential is in variables with other names, group them with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. Streaming uploads, presigned URLs, and SigV4A requests carry signatures the proxy can’t recompute. When one of these requests is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature. Requests signed with unmasked credentials aren’t affected. Use [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>), which requires Claude Code v2.1.224 or later, to forward one of these request forms instead. AWS still rejects the request, so the calling tool receives AWS’s own rejection response instead of a proxy error.
####
@@ -376,12 +436,12 @@
Mask credential files
-File entries also accept `"mode": "mask"`, which requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
-
- * **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, a stand-in whose secret is replaced with a placeholder value, and the sandbox proxy substitutes the real value on egress.
- * **macOS** : sandboxed commands can’t read the listed file at all. Claude Code builds no sentinel copy and substitutes nothing on egress, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. Unlike a `deny` entry, the read block holds even when you disable filesystem isolation.
-
-On every platform, Claude Code applies the [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) requirement and `injectHosts` the same way as for masked environment variables, and ignores repository settings the same way. If you exclude user settings, Claude Code keeps the file `mask` entries in `~/.claude/settings.json` as restrictions, but the entries no longer authorize the proxy to substitute the real value. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
+To mask a credential file, set `"mode": "mask"` on its `credentials.files` entry. Masking files requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
+
+ * **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, and the proxy substitutes the real value on outbound requests.
+ * **macOS** : sandboxed commands can’t read the file at all. Claude Code builds no sentinel copy, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. The read block holds even when you disable filesystem isolation.
+
+This example masks a GitHub token stored in `~/.config/gh/hosts.yml`. The `extract` pattern marks which part of the file is the secret, so on Linux and WSL2 `gh` still parses the rest of its config:
{
"sandbox": {
@@ -403,16 +463,11 @@
}
}
-To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command: on Linux and WSL2 the output shows a sentinel value in place of the token, and on macOS the read fails instead. On Linux and WSL2, the `extract` pattern is what keeps the rest of `hosts.yml` readable. Claude Code applies the regular expression across the whole file and replaces only the text captured by group 1 of each match, so `gh` still parses its config and only the token is a placeholder. Use `extract` for any structured file that tools parse, such as `.netrc`, JSON, or YAML; the pattern must contain at least one capturing group. Without `extract`, Claude Code replaces the entire file content with one sentinel value, which suits a file that holds a single bare secret and nothing else. For a file that holds a JSON Web Token (JWT), set `decode: "jwt"` instead of, or together with, `extract`. `decode` requires Claude Code v2.1.224 or later. Claude Code finds JWT candidates with a built-in pattern, or with your `extract` pattern when set, verifies each candidate is a JWT, and replaces it with a structurally valid fake token, so code that decodes the token inside the sandbox keeps working. Add `maskClaims` to mask only the named top-level payload claims inside each verified token and leave the other claims readable. When no candidate verifies, or no named claim matches, the `onExtractNoMatch` field below governs the outcome, as it does for a pattern that matches nothing. Two optional fields refine how matching behaves. Both apply only when `mode` is `mask` and `extract` or `decode` is set. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so these fields, and the no-match outcomes below, take effect there only when filesystem isolation is off:
-
- * `onExtractNoMatch` controls what happens when matching finds nothing to mask in the file:
- * `warn`, the default, warns and skips the entry, so sandboxed commands can read the real file unmasked. The default suits credentials that may be legitimately absent; if the secret might be present but the pattern might miss it, use `deny`
- * `deny` makes the file unreadable instead
- * `error` stops sandbox setup until you fix the configuration
-Claude Code treats `deny` as `error` whenever the read block wouldn’t be enforced: when you disable filesystem isolation, and when a `filesystem.allowRead` entry from any settings source re-opens the file’s path.
- * `maskDuplicates` also replaces verbatim copies of each masked credential value, an `extract` capture or a `decode`-verified token, found outside the matched spans, for a secret repeated where matching doesn’t reach. It matches raw substrings, so a short or common value would be replaced everywhere it appears; reserve it for long, high-entropy secrets. Default: false.
-
-`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text. Write directories as explicit `deny` entries instead; the table under Which settings can disable it covers whether each form pins `filesystem.disabled` and how it behaves with filesystem isolation off.
+To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command. On Linux and WSL2 the output shows a sentinel in place of the token, and on macOS the read fails. Without `extract` or `decode`, Claude Code replaces the entire file with one sentinel, which suits a file holding a single bare secret. Use the [`extract`, `decode`, `maskClaims`, `onExtractNoMatch`, and `maskDuplicates` fields](</docs/en/settings-reference#sandbox-credentials-files>) to control partial masking and what happens when the pattern matches nothing.
+
+When matching finds nothing to mask, the default `onExtractNoMatch` value, `warn`, skips the entry, so sandboxed commands can read the real file unmasked. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so the no-match outcomes take effect there only when filesystem isolation is off. The default suits credentials that may be legitimately absent. If the secret might be present but the pattern might miss it, use [`deny`](</docs/en/settings-reference#mask-fields-for-files>).
+
+`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text.
##
@@ -429,11 +484,9 @@
The sandboxed Bash tool restricts file system access to specific directories:
* **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the per-user temp directory that `$TMPDIR` points to
- * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
+ * **Default read behavior** : read access to the entire computer, except certain denied directories. This default still allows reading credential files, so protect credentials you don’t want commands to read.
* **Read block** : with [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) on, sandboxed commands also lose read access to your home directory and the other directories that hold user files, apart from the paths that [Sandboxed commands under the block](</docs/en/settings-reference#sandboxed-commands-under-the-block>) lists. That section also says when this part of the block doesn’t apply.
- * **Blocked access** : cannot modify files outside the working directory, added directories, and the per-user temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
- * **Configurable** : define custom allowed and denied paths through settings
To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
@@ -450,7 +503,7 @@
* **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
-If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see Troubleshooting.
+If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see A git command fails with `unable to unlink old`.
###
@@ -458,16 +511,25 @@
Network isolation
-Network access is controlled through a proxy server running outside the sandbox:
-
- * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself, per Per-command allowed domains.
- * **Approval choices** : if you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions.
+A sandboxed command has no direct route to the network:
+
+ * **Linux and WSL2** : the command runs in a separate network namespace that has no connection to your network
+ * **macOS** : the Seatbelt sandbox framework by default blocks connections other than the one to the sandbox proxy
+
+Claude Code runs the sandbox proxy on your machine, outside the sandbox, and directs commands to it with `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, and related environment variables. The proxy checks the hostname of each connection against your allowed and denied domains. What a tool can reach depends on whether it uses the proxy:
+
+ * **Tools that read the proxy variables** : `curl`, `npm`, `git` over HTTPS, and similar tools connect once their host is allowed. An `allowedDomains` entry with no port allows every port on that host
+ * **Tools that ignore the proxy variables** : plain `ssh`, most database drivers, and similar tools can’t connect, even to an allowed host. See A database client or other non-HTTP tool fails to reach an allowed host
+ * **Anything that isn’t TCP** : UDP, HTTP/3 over QUIC, and ICMP tools such as `ping` can’t leave the sandbox
+
+The following settings and behaviors control which hosts the proxy allows:
+
+ * **Domain restrictions** : your allowed domains start empty. Hosts outside your allowed domains covers what happens the first time a command needs a new domain.
+ * **Approval choices** : if you choose Yes when prompted, Claude Code allows the host for the rest of the current session. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. While the sandbox is admin-required, Claude Code saves the rule to your user settings, where it applies in every project.
* **Pre-allowed domains** : pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch(domain:...)` allow rules, as described in Permission rules.
- * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
+ * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Locks that apply without an admin-required sandbox covers a repository’s entries. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
- * **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
- * **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
- * **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
+ * **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy. `http://` and `https://` proxy URLs work, with basic authentication in the URL if you need it.
In a `WebFetch(domain:...)` rule, the sandbox honors two wildcard forms: a leading `*.`, such as `*.example.com`, and a bare `*`. The bare `*` form requires Claude Code v2.1.186 or later. A wildcard in any other position, such as `WebFetch(domain:example.*)`, still matches fetches but has no effect on sandboxed commands.
@@ -477,6 +539,31 @@
+Hosts outside your allowed domains
+
+When a sandboxed command connects to a host that isn’t in your allowed domains, the command stays in the sandbox and waits for a decision. In an interactive terminal session, the decision depends on your permission mode:
+
+Permission mode| What happens to the connection
+---|---
+`bypassPermissions` mode, and plan mode with [bypass permissions available](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>)| Allowed without a prompt
+Manual mode, `acceptEdits` mode, and plan mode otherwise| You get a prompt
+Auto mode| Refused unless the command listed the host and the classifier approved the list
+`dontAsk` mode| Refused
+
+With [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) on, the built-in sandbox proxy refuses the connection in every permission mode. In `bypassPermissions` mode, hosts outside your allowed domains are allowed unless one of them is on. The unsandboxed retry escape hatch covers when a command can leave the sandbox in that mode. A connection to a host in [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) is refused in every permission mode too.
+
+####
+
+
+
+Hostnames that resolve to local addresses
+
+After a hostname passes the allowlist, the sandbox proxy resolves it and refuses the connection when the name resolves only to local addresses. Local addresses include loopback addresses such as `127.0.0.1`, link-local addresses such as the `169.254.169.254` cloud metadata endpoint, and addresses assigned to your own machine. The names `localhost` and `*.localhost` are allowed to resolve to loopback. An allowed intranet hostname that resolves to a private range such as `10.0.0.0/8` connects. To let a name resolve to a refused address, add that IP address to `allowedDomains`, such as `"127.0.0.1:8080"`. The check applies to hostnames. Your allowed domains and permission mode decide a connection to an IP address. The proxy also skips the check for connections it sends through an upstream corporate proxy, because that proxy resolves the name.
+
+####
+
+
+
Per-command allowed domains in auto mode
In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) with sandboxing on, Claude names the hosts a command needs on the command itself instead of triggering a network approval for each connection. Each Bash, PowerShell, or [Monitor](</docs/en/tools-reference#monitor-tool>) command that runs in the sandbox can carry a list of hosts beyond the sandbox’s allowlist: a domain such as `registry.npmjs.org`, a wildcard such as `*.pythonhosted.org`, or an IP address, each with an optional `:port`. The classifier reviews the hosts together with the command. Requires Claude Code v2.1.271 or later. An approved list opens those hosts for that one command alone, for as long as it runs. Nothing is added to your session’s allowed hosts or your settings; the next command names its own hosts. A command that carries hosts goes to the classifier instead of being approved by a permission rule or the sandbox’s auto-allow mode. If an [ask rule](</docs/en/permissions#manage-permissions>) forces a prompt for the command, the permission dialog in your terminal lists the hosts beside it, and approving there covers both. A per-command list widens only what the sandbox denies by default. [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) entries still block. When [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) locks the allowlist, Claude Code refuses per-command lists. While per-command lists apply, Claude Code refuses a connection to a host that no approved command listed, without a prompt or a classifier check. The refusal names the host in the command’s result, and Claude re-runs the command with the host added.
@@ -487,12 +574,12 @@
IPv6 addresses in domain lists
-The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. When you choose “Yes, and don’t ask again” at the network approval prompt for an IPv6 address, Claude Code saves the `WebFetch(domain:...)` rule with the address bracketed, so the rule keeps matching the address in future sessions. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
-
- * **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing.
- * **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist.
-
-Run `claude doctor` in your terminal to find the affected entries: the `Sandbox network domain entries have unreliable spellings` warning names up to three of them and counts the rest. Rewrite each one in the bracketed form to clear the warning. The warning also names entries whose spelling is unreliable for other reasons, such as `@`, path or query characters, or wildcards inside brackets.
+To match an IPv6 address in `allowedDomains`, `deniedDomains`, or a `WebFetch(domain:...)` rule, write the address in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. The bracketed form requires Claude Code v2.1.229 or later. An unbracketed entry such as `::1:443` is ambiguous between an address and an address with a port:
+
+ * **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing
+ * **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist
+
+To find ambiguous entries, run `claude doctor` in your terminal and look for the `Sandbox network domain entries have unreliable spellings` warning. Rewrite each ambiguous entry in the bracketed form.
###
@@ -506,7 +593,7 @@
* **Linux** : uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
* **WSL2** : uses bubblewrap, same as Linux
-WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These same primitives are available as the standalone [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package, which the [Sandbox environments](</docs/en/sandbox-environments#sandbox-runtime>) page covers as a separate approach for wrapping the entire Claude Code process.
+You can also run the [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropics/sandbox-runtime>) package on its own to wrap the Claude Code process. See [Sandbox runtime](</docs/en/sandbox-environments#sandbox-runtime>).
##
@@ -573,7 +660,7 @@
Enforce sandboxing with managed settings
-To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
+To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code when the platform is unsupported or a dependency is missing, and prevents the model from retrying commands outside the sandbox:
{
"sandbox": {
@@ -585,10 +672,18 @@
The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
- * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution
+ * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than falling back to unsandboxed execution
* **`allowUnsandboxedCommands: false`** : Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can’t retry it unsandboxed
-Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See The unsandboxed retry escape hatch for the sessions where typed commands run sandboxed. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
+Consider these additions alongside them:
+
+ * Add `excludedCommands` for any organization-approved tools that must run without isolation, because this configuration stops a repository’s settings from taking commands out of the sandbox
+ * Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them
+
+This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See strict sandbox mode for the sessions where typed commands run sandboxed. The sandbox doesn’t run on native Windows, so with `failIfUnavailable` set, Claude Code exits at startup on those machines. If your fleet includes Windows hosts, you can:
+
+ * **Deliver the configuration by operating system** : deploy it through your MDM or as a [managed settings file](</docs/en/managed-settings#delivery-mechanisms>) on macOS and Linux machines only. [Server-managed settings](</docs/en/server-managed-settings#current-limitations>) apply to all users in the organization
+ * **Move Windows users into a supported environment** : have them run Claude Code inside WSL2 or a container
###
@@ -596,7 +691,60 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope the session loads, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+When managed settings set a Boolean key such as `enabled` or `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `allowRead`, Claude Code merges entries from the scopes the session loads, so a developer can append entries that widen the policy unless a lock covers that key. Unless managed settings set them, a developer’s user settings or `--settings` can turn on the following keys. A repository’s `.claude/settings.json` can too, unless the sandbox is admin-required. Each one weakens the sandbox, so set it to `false` in managed settings if you don’t want it used:
+
+ * [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>)
+ * [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>)
+ * [`network.allowAllUnixSockets`](</docs/en/settings-reference#sandbox-network-allowallunixsockets>)
+ * [`network.allowLocalBinding`](</docs/en/settings-reference#sandbox-network-allowlocalbinding>)
+ * [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>), which a repository can’t turn on
+
+Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). With the lock on, only managed settings can set a proxy port. When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. A [valid](</docs/en/settings-reference#invalid-credential-entries-in-managed-settings>) `mask` entry doesn’t lock the key. See Which settings can disable it.
+
+####
+
+
+
+Repository settings under an admin-required sandbox
+
+The sandbox is admin-required while one of these settings is in effect:
+
+ * [`allowUnsandboxedCommands`](</docs/en/settings-reference#sandbox-allowunsandboxedcommands>) set to `false` in managed settings, or with the `--settings` flag unless managed settings set it to `true`
+ * [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) set to `true` in managed settings
+
+These settings don’t turn the sandbox on, so set `enabled` as well. While the sandbox is admin-required, Claude Code takes the settings that loosen it only from managed settings, the `--settings` flag, and each developer’s `~/.claude/settings.json`. It ignores these settings in a repository’s `.claude/settings.json` and `.claude/settings.local.json`:
+
+Repository setting| What Claude Code ignores
+---|---
+`excludedCommands`, `ignoreViolations`, `network.allowedDomains`, `network.allowUnixSockets`, `network.allowMachLookup`, `network.httpProxyPort`, `network.socksProxyPort`| Every entry
+`filesystem.allowWrite`, `Edit(...)` allow rules, `permissions.additionalDirectories`| The write access each entry gives sandboxed commands. Claude’s file tools still follow the `Edit(...)` rules and additional directories
+`WebFetch(domain:...)` allow rules| The host each rule adds to the sandbox allowlist. The WebFetch tool still follows the rule
+`enableWeakerNestedSandbox`, `enableWeakerNetworkIsolation`, `network.allowAllUnixSockets`, `network.allowLocalBinding`| `true`. A `false` still applies
+`enabled`, `failIfUnavailable`| `false`, when the developer’s `~/.claude/settings.json` sets `true`
+`filesystem.allowRead`| An entry at or under a path that managed settings, `--settings`, or user settings deny reading, or a glob that could match one
+
+These settings still apply while the sandbox is admin-required:
+
+ * **In a repository’s files** : deny entries and the `autoAllowBashIfSandboxed` value. Set the key in managed settings to keep a repository from changing it
+ * **In a developer’s own settings** : the settings in the table still apply from `~/.claude/settings.json` or `--settings`, unless a managed-only lock such as `allowManagedDomainsOnly` covers them. Most of them, such as `excludedCommands` and `filesystem.allowWrite`, have no managed-only lock
+
+The configuration under Enforce sandboxing with managed settings makes the sandbox admin-required. Add the `excludedCommands`, `allowWrite`, and socket entries that your approved tools need to managed settings, because a repository can’t supply them. Requires Claude Code v2.1.285 or later. From v2.1.282 to v2.1.284, the same settings made Claude Code ignore a repository’s `excludedCommands` entries.
+
+####
+
+
+
+Locks that apply without an admin-required sandbox
+
+Some settings make Claude Code ignore the repository keys that directly override one restriction, even when the sandbox isn’t admin-required. Each one has this effect only when you set it in a file its row names, and the repository’s other sandbox settings still apply. Requires Claude Code v2.1.285 or later.
+
+Setting| Where you set it| What Claude Code ignores in a repository’s settings
+---|---|---
+`network.deniedDomains` or a `WebFetch(domain:...)` deny rule| Managed settings, `--settings`| `httpProxyPort` and `socksProxyPort`
+`network.strictAllowlist`| Managed settings, `--settings`, user settings| The proxy ports, `allowedDomains`, and `WebFetch(domain:...)` allow rules
+`filesystem.denyRead`, a `Read(...)` deny rule, or a `credentials.files` entry| Managed settings, `--settings`| An `allowRead`, `allowWrite`, `Edit(...)` allow, or `additionalDirectories` entry at or under a path that managed settings, `--settings`, or user settings deny reading, or a glob that could match one
+
+These locks change what sandboxed commands can reach. The WebFetch tool and Claude’s file tools still follow a repository’s rules and additional directories.
###
@@ -604,14 +752,7 @@
Custom proxy configuration
-For organizations requiring advanced network security, you can implement a custom proxy to:
-
- * Decrypt and inspect HTTPS traffic
- * Apply custom filtering rules
- * Log all network requests
- * Integrate with existing security infrastructure
-
-To point Claude Code at your proxy, set the proxy ports in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
+To inspect, filter, or log sandbox traffic with your own tooling, replace the built-in sandbox proxy with a proxy you run on the same machine. To route sandbox traffic through a corporate proxy elsewhere on your network, set `HTTPS_PROXY` instead, as the **Corporate proxy** entry under Network isolation describes. That way, Claude Code’s allowlist still applies. To direct sandboxed commands to your proxy, set the localhost ports it listens on in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
{
"sandbox": {
@@ -622,24 +763,203 @@
}
}
+If you set a port and also set `HTTPS_PROXY` or `HTTP_PROXY`, Claude Code doesn’t forward what sandboxed commands send to your proxy on to the proxy those variables name. To reach a corporate proxy, configure your own proxy to forward to it. Which files can set a port depends on your other sandbox settings. The first case that matches applies:
+
+ * **`allowManagedDomainsOnly` is on**: managed settings only
+ * **The sandbox isadmin-required, or a narrower network lock applies**: managed settings, `--settings`, and user settings
+ * **Otherwise** : any settings file
+
+Claude Code ignores a port set anywhere else. Before v2.1.285, any settings file could set a port.
+
+Once either port applies, your proxy is responsible for filtering everything sent to it. Claude Code’s own network controls, such as `allowedDomains`, `deniedDomains`, `strictAllowlist`, approval prompts, and the local-address check, stop applying to that traffic. A sandboxed command can connect to either proxy, so if you set only one port, Claude Code’s domain lists on the other proxy don’t limit what the command reaches through yours.
+
##
Troubleshooting
-Some commands fail inside the sandbox even though they work outside it. The fixes below cover the most common cases.
-
- * **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
- * **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
- * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>). If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
- * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
- * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself. If the same git command fails often, add it to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
- * **0-byte read-only files appear at`.claude` settings paths, and “Yes, and don’t ask again” doesn’t save**: on Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind them read-only again on every start, so a settings write such as saving a permission choice fails where one sits. Run `claude doctor` to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names up to three of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
- * **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
+Some commands fail inside the sandbox even though they work outside it. Find the heading that matches your symptom or error message. If your organization’s sandbox is admin-required, Claude Code ignores the settings these fixes name in a project’s settings files, so save them in `~/.claude/settings.json`, where they apply in every project. If a fix still has no effect, your organization’s managed settings may set that key. A fix that adds an `excludedCommands` pattern removes the sandbox from the commands the pattern matches. See what an excluded command can do.
+
+###
+
+
+
+Commands fail with a host-not-allowed error
+
+Many CLI tools need to reach specific hosts. Approve the host when prompted, or add it to [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>). If your organization locks the allowlist with `allowManagedDomainsOnly`, there’s no prompt, so ask your administrator to add the host.
+
+###
+
+
+
+`jest` hangs or fails
+
+`watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
+
+###
+
+
+
+Go-based CLIs fail TLS verification on macOS
+
+Tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. To run these tools outside the sandbox, add a pattern for each tool, such as `gh *`, to `excludedCommands`. The tool then runs with your full access and its stored credentials. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
+
+###
+
+
+
+`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS
+
+The sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Claude Code ignores this key in project settings. Enabling `allowAppleEvents` removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add a pattern such as `open *` to `excludedCommands`. Each `open` call then goes through the permission flow, and `open` can launch any file or app, including one Claude wrote.
+
+###
+
+
+
+`docker` commands fail
+
+`docker` is incompatible with the sandbox. Take the `docker` commands you need out of the sandbox with an `excludedCommands` pattern such as `docker compose *`. Run commands outside the sandbox with `excludedCommands` explains what an excluded `docker` command can reach. A narrower pattern takes fewer commands out of the sandbox.
+
+###
+
+
+
+`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard
+
+The `pbcopy`, `xclip`, and `wl-copy` clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
+
+###
+
+
+
+A git command fails with `unable to unlink old`
+
+`git merge`, `git checkout`, and similar commands fail with `unable to unlink old` when they need to replace a file the sandbox denies writes to. On Linux and WSL2 the error ends with `Read-only file system`. The file can be in one of these places:
+
+ * Under a protected path such as `.claude/skills`
+ * Under one of your `denyWrite` entries
+ * Outside the directories the sandbox lets commands write to at all
+
+After the failure, Claude may offer to rerun the command outside the sandbox. Approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself.
+
+###
+
+
+
+Bubblewrap fails to start inside a container
+
+In an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since the setting exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+
+###
+
+
+
+0-byte read-only files appear at `.claude` settings paths, and “Yes, and don’t ask again” doesn’t save
+
+On Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind the placeholders read-only again on every start, so a settings write such as saving a permission choice fails at a path where a placeholder remains. Run `claude doctor` in your terminal to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names some of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
+
+###
+
+
+
+`git` over SSH fails with the sandbox on
+
+On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote fail inside the sandbox even when the host is allowed. On Linux and WSL2, they work once the host is allowed. Claude Code tunnels git’s SSH connection through the sandbox proxy, and the macOS tunnel can’t authenticate to that proxy. On Linux and WSL2, check these if the connection still fails:
+
+ * **The host is allowed on port 22** : an `allowedDomains` entry with no port, such as `"git.example.com"`, covers it
+ * **Your corporate proxy permits port 22** : if your network requires an upstream proxy, the tunnel goes through it too
+ * **The key is readable as a file** : the sandbox can block the `ssh-agent` socket, and a `denyRead` or `credentials` entry for `~/.ssh` hides your key files
+
+On macOS, switch the remote to HTTPS, which needs HTTPS credentials such as a personal access token:
+
+ git remote set-url origin https://git.example.com/example-org/example-repo.git
+
+If you have to keep the SSH remote, take git’s network commands out of the sandbox with `excludedCommands`:
+
+ {
+ "sandbox": {
+ "excludedCommands": ["git fetch *", "git pull *", "git push *"]
+ }
+ }
+
+These entries match `git push origin main`. A call that adds a `cd`, uses `git -C`, or contains a command substitution stays sandboxed. The excluded git commands can reach any host, not only the ones in `allowedDomains`. Plain `ssh`, `scp`, and `rsync` over SSH fail for the reason the database client entry gives.
+
+###
+
+
+
+A database client or other non-HTTP tool fails to reach an allowed host
+
+A tool that ignores the proxy environment variables can’t connect from inside the sandbox, even to a host in `allowedDomains`. A sandboxed command has no direct route to the network, so a tool that opens its own connection fails. Most database drivers, plain `ssh`, and tools that use UDP behave this way. The failure looks like a network or name resolution error:
+
+ * **macOS** : `Operation not permitted`, or a name resolution error such as `Could not resolve host`
+ * **Linux and WSL2** : `Network is unreachable`, or a name resolution error such as `Temporary failure in name resolution`
+
+A tool that uses the proxy fails differently when its host isn’t allowed. You get a network prompt, or the tool receives a `403` response from the proxy. To let the tool connect, run the command that needs it outside the sandbox with `excludedCommands`. This example excludes one script and adds an [ask rule](</docs/en/permissions>) so that you approve each run:
+
+ {
+ "sandbox": {
+ "excludedCommands": ["python scripts/load_orders.py *"]
+ },
+ "permissions": {
+ "ask": ["Bash(python scripts/load_orders.py *)"]
+ }
+ }
+
+The script runs with your full access, and Claude can edit a script that’s inside your working directory, so review it when the prompt appears.
+
+###
+
+
+
+A command fails to reach a server on localhost
+
+By default, a sandboxed command can’t connect directly to a server that’s running on your machine outside the sandbox, such as a dev server or a database in a container. What you can change depends on your platform:
+
+ * **macOS** : set [`network.allowLocalBinding`](</docs/en/settings-reference#sandbox-network-allowlocalbinding>) to `true`. Sandboxed commands can then listen on network ports and connect to any port on localhost, which includes every other service listening there. A localhost service that doesn’t require authentication, such as a debugger, can then act for the command outside the sandbox, and a command that listens on a non-loopback address accepts connections from other machines
+ * **Linux and WSL2** : a sandboxed command’s `localhost` is private to that command. The command can listen on a port and reach servers it started itself. A direct connection to `localhost` or `127.0.0.1` doesn’t reach servers on the host, and `allowLocalBinding` has no effect. Run the command that needs the host’s server outside the sandbox with `excludedCommands`, where it has no filesystem or network limits. For connections that go through the sandbox proxy, see Hostnames that resolve to local addresses
+
+This example turns the setting on for macOS:
+
+ {
+ "sandbox": {
+ "network": {
+ "allowLocalBinding": true
+ }
+ }
+ }
+
+An `allowedDomains` entry for `localhost` applies to connections that go through the proxy, so it doesn’t change a direct connection. Claude Code sets `NO_PROXY` for sandboxed commands so that they connect to `localhost` directly instead of through the proxy. The entry also exposes every port on your machine’s localhost to a command that does use the proxy. For a development hostname that points at `127.0.0.1`, see An allowed hostname is refused with `resolved to a loopback address`.
+
+###
+
+
+
+An allowed hostname is refused with `resolved to a loopback address`
+
+The sandbox proxy refuses an allowed hostname that resolves to a local address, which affects development names such as `myapp.test` that point at `127.0.0.1`. The command sees a `403` response whose body names the kind of address, such as `Connection to myapp.test blocked: resolved to a loopback address`. Add the IP address the name resolves to alongside the hostname in `allowedDomains`, each with the port your server listens on:
+
+ {
+ "sandbox": {
+ "network": {
+ "allowedDomains": ["myapp.test:3000", "127.0.0.1:3000"]
+ }
+ }
+ }
+
+An IP address entry with no port lets sandboxed commands reach every service listening on that address. Before v2.1.284, the proxy connected to whatever address an allowed hostname resolved to.
+
+###
+
+
+
+`/sandbox` fails with `Sandbox settings are overridden by a higher-priority configuration`
+
+`/sandbox` prints `Error: Sandbox settings are overridden by a higher-priority configuration and cannot be changed locally.` instead of opening its panel when a higher [settings level](</docs/en/settings#settings-precedence>) sets `sandbox.enabled`, `sandbox.autoAllowBashIfSandboxed`, or `sandbox.allowUnsandboxedCommands`. The panel saves your choices to `.claude/settings.local.json`, and a value saved there can’t override those levels. Managed settings and `--settings` rank above local settings. To see which of them this session loaded, run `/status` and read the `Setting sources` line:
+
+ * **`Command line arguments`** : if you started Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>), check whether the file or JSON you passed sets one of those keys. If it does, change the value there, or start Claude Code again without those keys.
+ * **`Enterprise managed settings`** : your organization’s managed settings are loaded. If they set one of those keys, you can’t change that key from `/sandbox` or from any settings file you control, so ask your administrator.
##
@@ -661,31 +981,20 @@
* **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
- * **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
+ * **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
###
-Platform and tool compatibility
-
- * **Platform support** : supports macOS, Linux, and WSL2. WSL1 and native Windows are not supported.
- * **Performance overhead** : minimal, but some filesystem operations may be slightly slower.
- * **Tool compatibility** : some tools that require specific system access patterns may need configuration adjustments, or may need to be run outside the sandbox.
-
-###
-
-
-
Scope
-The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
-
- * **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
+The sandbox isolates shell commands and their child processes. What runs outside the sandbox lists the tools and helper processes it doesn’t cover. Computer use and subagents relate to the sandbox as follows:
+
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
- * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
+ * **Mods** : a [mod](</docs/en/plugins/mods/overview>) is a plugin that runs its own code inside Claude Code, and a process that a mod starts runs outside the sandbox. See [What a mod can reach](</docs/en/plugins/mods/overview#what-a-mod-can-reach>).
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -430,6 +430,7 @@
* **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the per-user temp directory that `$TMPDIR` points to
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
+ * **Read block** : with [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) on, sandboxed commands also lose read access to your home directory and the other directories that hold user files, apart from the paths that [Sandboxed commands under the block](</docs/en/settings-reference#sandboxed-commands-under-the-block>) lists. That section also says when this part of the block doesn’t apply.
* **Blocked access** : cannot modify files outside the working directory, added directories, and the per-user temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
@@ -446,7 +447,7 @@
* **In your working directory and the directories above it** : the `.claude` settings files, the `.claude/skills`, `.claude/agents`, `.claude/commands`, and `.claude/hooks` directories, `.mcp.json`, and the files Claude Code runs on its own, such as `.claude/workflows` and `.claude/scheduled_tasks.json`
* **In your working directory only** : shell startup files such as `.bashrc` and `.zshrc`, `.gitconfig`, the `.vscode` and `.idea` directories, and `hooks` and `config` inside `.git`
- * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus `config` and `hooks` there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
+ * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus existing `config` and `hooks` entries there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see Troubleshooting.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -36,7 +36,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, a [per-user temp directory](</docs/en/env-vars>), and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings. To change the sandbox for one session without writing to a settings file, start Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>). For example, this command starts a sandboxed session in which Claude can’t retry a blocked command outside the sandbox:
@@ -139,7 +139,7 @@
Temporary directories
-The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` when it is set, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. If your shell leaves `$TMPDIR` unset or empty, an unsandboxed command that references `$TMPDIR` receives your [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>) override, or the operating system’s temp directory when you haven’t set one or the override is a long path, so the variable doesn’t expand to an empty string. To pass temporary files between the two, write them under the working directory instead.
+A per-user temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` when it is set, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. If your shell leaves `$TMPDIR` unset or empty, an unsandboxed command that references `$TMPDIR` receives your [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>) override, or the operating system’s temp directory when you haven’t set one or the override is a long path, so the variable doesn’t expand to an empty string. To pass temporary files between the two, write them under the working directory instead.
##
@@ -147,7 +147,7 @@
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write to the current working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write to the current working directory, the per-user temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -251,7 +251,7 @@
Two other things change:
- * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the session one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
+ * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the per-user temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the per-user one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
* [`autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
###
@@ -428,9 +428,9 @@
The sandboxed Bash tool restricts file system access to specific directories:
- * **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the session temp directory that `$TMPDIR` points to
+ * **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the per-user temp directory that `$TMPDIR` points to
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
- * **Blocked access** : cannot modify files outside the working directory, added directories, and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
+ * **Blocked access** : cannot modify files outside the working directory, added directories, and the per-user temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -110,7 +110,7 @@
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-Auto-allow mode works independently of your permission mode setting, except in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) and, in auto mode, for a command that carries per-command allowed domains. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+Auto-allow mode works independently of your permission mode setting, with three exceptions: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), an auto mode command that carries per-command allowed domains, and [server-side classifier review](</docs/en/permission-modes#how-the-classifier-evaluates-actions>) of sandboxed commands in auto mode. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
####
@@ -260,7 +260,7 @@
Protect credentials
-The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The file protection is part of the filesystem layer, so it doesn’t apply if you disable filesystem isolation; the environment variable protection still does. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
+The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The file protection is part of the filesystem layer, so it doesn’t apply if you disable filesystem isolation; the environment variable protection still does. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
{
"sandbox": {
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -139,7 +139,7 @@
Temporary directories
-The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead.
+The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` when it is set, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. If your shell leaves `$TMPDIR` unset or empty, an unsandboxed command that references `$TMPDIR` receives your [`CLAUDE_CODE_TMPDIR`](</docs/en/env-vars>) override, or the operating system’s temp directory when you haven’t set one or the override is a long path, so the variable doesn’t expand to an empty string. To pass temporary files between the two, write them under the working directory instead.
##
@@ -251,7 +251,7 @@
Two other things change:
- * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the session one. On Linux the variable is often unset in the parent shell, so it can expand empty inside sandboxed commands; Claude Code tells Claude through its Bash tool guidance to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
+ * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the session one. On Linux the variable is often unset in the parent shell. The Bash tool guidance tells Claude to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
* [`autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
###
@@ -631,10 +631,10 @@
* **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
* **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
- * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
- * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
- * **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
- * **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>), which writes to the clipboard from the Claude Code process rather than from a sandboxed command. Alternatively, add `pbcopy *`, `wl-copy *`, or `xclip *` to `excludedCommands` to run the command outside the sandbox.
+ * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>). If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
+ * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+ * **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+ * **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>). `/copy` writes to the clipboard from the Claude Code process rather than from a sandboxed command. When Claude pipes text to one of these tools, adding the tool to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>) doesn’t take that call out of the sandbox on its own.
* **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself. If the same git command fails often, add it to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **0-byte read-only files appear at`.claude` settings paths, and “Yes, and don’t ask again” doesn’t save**: on Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind them read-only again on every start, so a settings write such as saving a permission choice fails where one sits. Run `claude doctor` to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names up to three of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -446,7 +446,7 @@
* **In your working directory and the directories above it** : the `.claude` settings files, the `.claude/skills`, `.claude/agents`, `.claude/commands`, and `.claude/hooks` directories, `.mcp.json`, and the files Claude Code runs on its own, such as `.claude/workflows` and `.claude/scheduled_tasks.json`
* **In your working directory only** : shell startup files such as `.bashrc` and `.zshrc`, `.gitconfig`, the `.vscode` and `.idea` directories, and `hooks` and `config` inside `.git`
- * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus `config` and `hooks` there when they already exist, even when the `config` directory belongs to your project rather than to git. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
+ * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus `config` and `hooks` there when a `HEAD` sits beside them. A file named `config` is denied even with no `HEAD`. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
* **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see Troubleshooting.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,4 +1,4 @@
-The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash command and its child processes.
+The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash, PowerShell, or Monitor command and its child processes.
To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>). To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>).
@@ -36,7 +36,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`.The first time a command needs a new network domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself for the classifier to review with it.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings. To change the sandbox for one session without writing to a settings file, start Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>). For example, this command starts a sandboxed session in which Claude can’t retry a blocked command outside the sandbox:
@@ -110,7 +110,7 @@
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+Auto-allow mode works independently of your permission mode setting, except in [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) and, in auto mode, for a command that carries per-command allowed domains. Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
####
@@ -166,7 +166,7 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
+This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the rule with the narrower path applies:
Example rules| Result
---|---
@@ -459,7 +459,9 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch(domain:...)` allow rules, as described in Permission rules.
+ * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), Claude instead names the hosts a command needs on the command itself, per Per-command allowed domains.
+ * **Approval choices** : if you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions.
+ * **Pre-allowed domains** : pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch(domain:...)` allow rules, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
@@ -474,6 +476,14 @@
+Per-command allowed domains in auto mode
+
+In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) with sandboxing on, Claude names the hosts a command needs on the command itself instead of triggering a network approval for each connection. Each Bash, PowerShell, or [Monitor](</docs/en/tools-reference#monitor-tool>) command that runs in the sandbox can carry a list of hosts beyond the sandbox’s allowlist: a domain such as `registry.npmjs.org`, a wildcard such as `*.pythonhosted.org`, or an IP address, each with an optional `:port`. The classifier reviews the hosts together with the command. Requires Claude Code v2.1.271 or later. An approved list opens those hosts for that one command alone, for as long as it runs. Nothing is added to your session’s allowed hosts or your settings; the next command names its own hosts. A command that carries hosts goes to the classifier instead of being approved by a permission rule or the sandbox’s auto-allow mode. If an [ask rule](</docs/en/permissions#manage-permissions>) forces a prompt for the command, the permission dialog in your terminal lists the hosts beside it, and approving there covers both. A per-command list widens only what the sandbox denies by default. [`deniedDomains`](</docs/en/settings-reference#sandbox-network-denieddomains>) entries still block. When [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) or [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) locks the allowlist, Claude Code refuses per-command lists. While per-command lists apply, Claude Code refuses a connection to a host that no approved command listed, without a prompt or a classifier check. The refusal names the host in the command’s result, and Claude re-runs the command with the host added.
+
+####
+
+
+
IPv6 addresses in domain lists
The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. When you choose “Yes, and don’t ask again” at the network approval prompt for an IPv6 address, Claude Code saves the `WebFetch(domain:...)` rule with the address bracketed, so the rule keeps matching the address in future sessions. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
@@ -514,7 +524,7 @@
Permission rules and sandboxing control different things:
* **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to every tool: Bash, Read, Edit, WebFetch, MCP, and others, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains.
- * **Sandboxing** provides OS-level enforcement that restricts what Bash commands can access at the filesystem and network level. It applies only to Bash commands and their child processes.
+ * **Sandboxing** provides OS-level enforcement that restricts what shell commands can access at the filesystem and network level. It applies only to Bash, PowerShell, and [Monitor](</docs/en/tools-reference#monitor-tool>) commands and their child processes.
The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
@@ -546,7 +556,7 @@
[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply
-The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>). For a table of common permission mode and sandbox pairings with the flags that start each one, see [Common setups](</docs/en/permission-modes#common-setups>).
+The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined, with the exceptions listed under Sandbox modes. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>). For a table of common permission mode and sandbox pairings with the flags that start each one, see [Common setups](</docs/en/permission-modes#common-setups>).
##
@@ -562,7 +572,7 @@
Enforce sandboxing with managed settings
-To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on Claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
+To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
{
"sandbox": {
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -38,7 +38,9 @@
Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
-When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
+When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings. To change the sandbox for one session without writing to a settings file, start Claude Code with [`--settings`](</docs/en/settings#change-a-setting-for-one-session>). For example, this command starts a sandboxed session in which Claude can’t retry a blocked command outside the sandbox:
+
+ claude --settings '{"sandbox": {"enabled": true, "allowUnsandboxedCommands": false}}'
By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -625,6 +625,7 @@
* **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>), which writes to the clipboard from the Claude Code process rather than from a sandboxed command. Alternatively, add `pbcopy *`, `wl-copy *`, or `xclip *` to `excludedCommands` to run the command outside the sandbox.
* **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself. If the same git command fails often, add it to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+ * **0-byte read-only files appear at`.claude` settings paths, and “Yes, and don’t ask again” doesn’t save**: on Linux and WSL2, the sandbox holds a write denial on a file that doesn’t exist yet by creating a 0-byte read-only placeholder there while a sandboxed command runs. The sandbox removes the placeholder afterward. If a session is killed before that cleanup runs, for example by SIGKILL, the placeholders stay behind. Later sessions bind them read-only again on every start, so a settings write such as saving a permission choice fails where one sits. Run `claude doctor` to list the leftover placeholder files. The [`Stale sandbox mask files left by a killed session`](</docs/en/errors#stale-sandbox-mask-files-left-by-a-killed-session>) warning names up to three of them and counts the rest. Delete each file with `rm` while no other Claude Code session is running in that project. Before v2.1.257, Claude Code left the same placeholders behind without flagging them.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -684,5 +684,5 @@
* [Sandbox environments](</docs/en/sandbox-environments>): compare the built-in sandbox with dev containers, containers, and VMs
* [Security](</docs/en/security>): comprehensive security features and best practices
* [Permissions](</docs/en/permissions>): permission configuration and access control
- * [Settings reference](</docs/en/settings-reference>): every settings key
+ * [All settings](</docs/en/settings-reference>): every settings key
* [CLI reference](</docs/en/cli-reference>): command-line options
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -124,7 +124,12 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow. In Manual mode you get a confirmation prompt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier evaluates the underlying command. While [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on, a retry that needs approval to run outside the sandbox prompts you instead. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow. In Manual mode you get a confirmation prompt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier evaluates the underlying command. While [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on, a retry that needs approval to run outside the sandbox prompts you instead. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). With the escape hatch disabled, Claude Code ignores the `dangerouslyDisableSandbox` parameter, and every command Claude runs must run sandboxed unless you’ve listed it in `excludedCommands`. The `/sandbox` **Overrides** tab shows this setting as **Strict sandbox mode**. Strict sandbox mode applies to the commands Claude runs. Commands you type yourself at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) run outside the sandbox unless the session is one of these:
+
+ * **A[background session](</docs/en/agent-view>)**: strict sandbox mode covers shell-mode commands too
+ * **A Linux session with[`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars#variables>) set**: every command runs sandboxed, shell-mode commands included
+
+Before v2.1.260, strict sandbox mode sandboxed shell-mode commands in every session.
####
@@ -568,9 +573,9 @@
The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
* **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution
- * **`allowUnsandboxedCommands: false`** : the `dangerouslyDisableSandbox` escape hatch is ignored, so commands that fail under the sandbox cannot be retried outside it
-
-Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
+ * **`allowUnsandboxedCommands: false`** : Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can’t retry it unsandboxed
+
+Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. This configuration sandboxes the commands Claude runs. A developer can still type a command at the [`!` shell-mode prompt](</docs/en/interactive-mode#shell-mode-with-prefix>) and run it outside the sandbox, with the same access they already have in any terminal outside Claude Code. See The unsandboxed retry escape hatch for the sessions where typed commands run sandboxed. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
###
@@ -617,7 +622,8 @@
* **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
* **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
- * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself or, if the same git command fails often, add that command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+ * **`pbcopy`, `xclip`, or `wl-copy` doesn’t update the clipboard**: these clipboard utilities can fail to reach the system clipboard from inside the sandbox, in which case the text piped to them doesn’t arrive. To put Claude’s output on your clipboard, ask Claude to print it in its response, then run [`/copy`](</docs/en/commands>), which writes to the clipboard from the Claude Code process rather than from a sandboxed command. Alternatively, add `pbcopy *`, `wl-copy *`, or `xclip *` to `excludedCommands` to run the command outside the sandbox.
+ * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself. If the same git command fails often, add it to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -101,7 +101,7 @@
Auto-allow mode
-When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
+When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode. Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
@@ -124,7 +124,7 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow. In Manual mode you get a confirmation prompt. In [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>), the classifier evaluates the underlying command. While [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) is on, a retry that needs approval to run outside the sandbox prompts you instead. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
####
@@ -179,7 +179,7 @@
}
}
-If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
+If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule. To deny sandboxed commands read access to home directories and mounted volumes while keeping the working directories readable, set [`permissions.blockReadsOutsideWorkingDirectories`](</docs/en/settings-reference#permissions-blockreadsoutsideworkingdirectories>) instead of writing path rules.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -276,7 +276,7 @@
* **Project or local settings** : Claude Code applies none of their `credentials` entries. Requires Claude Code v2.1.246 or later.
* **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions, but drops its environment variable `mask` entries.
-There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+There is no built-in credential deny list, so only the files and variables you list are restricted. `sandbox.credentials` affects sandboxed Bash commands only. To strip credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
###
@@ -664,7 +664,7 @@
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
- * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses.
+ * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -292,7 +292,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`.
{
"sandbox": {
@@ -315,7 +315,7 @@
* **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
* **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-`claude doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+`claude doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When your administrator delivers `mask` entries, `network.tlsTerminate`, or `credentials.allowPlaintextInject` through server-managed settings, they count as [settings that need approval](</docs/en/server-managed-settings#security-approval-dialogs>). When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
* `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
* `onExtractNoMatch` controls what happens when the pattern matches nothing:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -36,7 +36,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory, any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir` or `/add-dir`, and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write to the working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
@@ -140,7 +140,7 @@
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory, any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir` or `/add-dir`, and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write to the current working directory, the session temp directory, and any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir`, `/add-dir`, or `permissions.additionalDirectories`. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -421,7 +421,7 @@
The sandboxed Bash tool restricts file system access to specific directories:
- * **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir` or `/add-dir`, plus the session temp directory that `$TMPDIR` points to
+ * **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir`, `/add-dir`, or [`permissions.additionalDirectories`](</docs/en/settings-reference#permissions-additionaldirectories>), plus the session temp directory that `$TMPDIR` points to
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
* **Blocked access** : cannot modify files outside the working directory, added directories, and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -36,7 +36,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory, any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir` or `/add-dir`, and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that can’t run sandboxed fall back to the regular permission flow. Claude Code titles their permission prompt “Bash command (unsandboxed)” instead of “Bash command”, so you can tell which commands ran outside the sandbox. To widen or narrow what the sandbox allows, see Configure sandboxing.If sandboxed commands fail with `Operation not permitted` inside a container, see the Bubblewrap entry under Troubleshooting.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
@@ -124,7 +124,7 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. Claude Code reports sandbox violations in the blocked command’s result, naming the path or host the sandbox denied, so Claude sees what the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: Claude analyzes the violation and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
####
@@ -140,7 +140,7 @@
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory, any [directories you’ve added](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>) with `--add-dir` or `/add-dir`, and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -315,7 +315,7 @@
* **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
* **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+`claude doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. This check requires Claude Code v2.1.229 or later. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
* `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
* `onExtractNoMatch` controls what happens when the pattern matches nothing:
@@ -421,9 +421,9 @@
The sandboxed Bash tool restricts file system access to specific directories:
- * **Default write behavior** : read and write access to the current working directory and its subdirectories, plus the session temp directory that `$TMPDIR` points to
+ * **Default write behavior** : read and write access to the current working directory and its subdirectories, any directories you’ve added with `--add-dir` or `/add-dir`, plus the session temp directory that `$TMPDIR` points to
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
- * **Blocked access** : cannot modify files outside the current working directory and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
+ * **Blocked access** : cannot modify files outside the working directory, added directories, and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
@@ -474,7 +474,7 @@
* **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing.
* **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist.
-Run `/doctor` to list the affected entries. The `Sandbox network domain entries have unreliable spellings` warning names each one. Rewrite them in the bracketed form to clear it. The warning also names entries whose spelling is unreliable for other reasons, such as `@`, path or query characters, or wildcards inside brackets.
+Run `claude doctor` in your terminal to find the affected entries: the `Sandbox network domain entries have unreliable spellings` warning names up to three of them and counts the rest. Rewrite each one in the bracketed form to clear the warning. The warning also names entries whose spelling is unreliable for other reasons, such as `@`, path or query characters, or wildcards inside brackets.
###
@@ -482,7 +482,7 @@
OS-level enforcement
-The sandboxed Bash tool leverages operating system security primitives:
+The sandboxed Bash tool uses operating system security primitives:
* **macOS** : uses Seatbelt for sandbox enforcement
* **Linux** : uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
@@ -618,7 +618,7 @@
* **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
* **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself or, if the same git command fails often, add that command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
- * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+ * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap can’t mount a fresh `/proc` filesystem, so sandboxed commands fail with a `bwrap` error such as `Can't mount proc on /newroot/proc: Operation not permitted`. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
@@ -639,7 +639,7 @@
Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
- * **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
+ * **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -151,7 +151,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When the same filesystem array is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are merged: paths from every scope are combined, not replaced. When you edit these lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Path prefixes control how paths are resolved:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When you define the same filesystem array in multiple [settings scopes](</docs/en/settings#settings-precedence>), Claude Code merges them, combining paths from every scope rather than replacing one scope’s array with another’s. If you exclude a source with [`--setting-sources`](</docs/en/cli-reference>) on the CLI or [`settingSources`](</docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources>) in the Agent SDK, Claude Code ignores its `sandbox.filesystem` entries, its `Edit` permission rules, and its `Read` deny rules when building the sandbox configuration. Requires Claude Code v2.1.246 or later. When you edit these filesystem lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Path prefixes control how paths are resolved:
Prefix| Meaning| Example
---|---|---
@@ -271,7 +271,12 @@
}
}
-Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings-reference#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings-reference#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings. Claude Code merges the `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) the session loads. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. When you exclude a settings source:
+
+ * **Project or local settings** : Claude Code applies none of their `credentials` entries. Requires Claude Code v2.1.246 or later.
+ * **User settings** : Claude Code still applies the `deny` entries in `~/.claude/settings.json` and keeps its file `mask` entries as restrictions, but drops its environment variable `mask` entries.
+
+There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
###
@@ -310,7 +315,7 @@
* **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
* **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so Claude Code honors it only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. Claude Code ignores `mask` entries in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. In those files it also ignores `network.tlsTerminate` and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), the setting that lets the proxy inject credentials into unencrypted requests. If you exclude user settings, Claude Code drops the environment variable `mask` entries in `~/.claude/settings.json` too. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
* `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
* `onExtractNoMatch` controls what happens when the pattern matches nothing:
@@ -369,7 +374,7 @@
* **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, a stand-in whose secret is replaced with a placeholder value, and the sandbox proxy substitutes the real value on egress.
* **macOS** : sandboxed commands can’t read the listed file at all. Claude Code builds no sentinel copy and substitutes nothing on egress, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. Unlike a `deny` entry, the read block holds even when you disable filesystem isolation.
-On every platform, the [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) requirement, `injectHosts`, and the settings-source restriction work the same way as for masked environment variables. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
+On every platform, Claude Code applies the [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) requirement and `injectHosts` the same way as for masked environment variables, and ignores repository settings the same way. If you exclude user settings, Claude Code keeps the file `mask` entries in `~/.claude/settings.json` as restrictions, but the entries no longer authorize the proxy to substitute the real value. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
{
"sandbox": {
@@ -573,7 +578,7 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope the session loads, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -447,12 +447,14 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch` allow rules, as described in Permission rules.
+ * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch(domain:...)` allow rules, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
+
+In a `WebFetch(domain:...)` rule, the sandbox honors two wildcard forms: a leading `*.`, such as `*.example.com`, and a bare `*`. The bare `*` form requires Claude Code v2.1.186 or later. A wildcard in any other position, such as `WebFetch(domain:example.*)`, still matches fetches but has no effect on sandboxed commands.
The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
@@ -512,11 +514,11 @@
`sandbox.filesystem.disabled`| Turns the filesystem layer off entirely while keeping network isolation
`Edit` allow rules| Grant write access to specific paths, the same way `sandbox.filesystem.allowWrite` does
`Read` and `Edit` deny rules| Block access to specific files or directories
-`WebFetch` allow and deny rules| Control domain access
+`WebFetch(domain:...)` allow and deny rules| Control domain access
Sandbox `allowedDomains`| Controls which domains Bash commands can reach
Sandbox `deniedDomains`| Blocks specific domains even when a broader `allowedDomains` wildcard would otherwise permit them
-Paths from both `sandbox.filesystem` settings and permission rules are merged together into the final sandbox configuration. The [claude-code repository’s examples directory](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
+Paths and domains from both sandbox settings and permission rules are merged into the final sandbox configuration. The [claude-code repository’s examples directory](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
###
Show diff (226 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -21,7 +21,7 @@
This opens the sandbox panel with three tabs, plus a Dependencies tab on Linux when the optional seccomp filter is missing:
* **Mode** : choose how sandboxed commands are approved, covered in the next step
- * **Overrides** : choose whether commands that fail under the sandbox can fall back to running unsandboxed. This is the [`allowUnsandboxedCommands`](</docs/en/settings#sandbox-settings>) setting
+ * **Overrides** : choose whether commands that fail under the sandbox can fall back to running unsandboxed. This is the [`allowUnsandboxedCommands`](</docs/en/settings-reference#sandbox-allowunsandboxedcommands>) setting
* **Config** : view the resolved sandbox settings
If the panel shows only a Dependencies tab, a required package is missing. Install it as described in Set up Linux and WSL2, restart Claude Code, and run `/sandbox` again.
@@ -38,9 +38,9 @@
Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
-When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
-
-By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings-reference#sandbox-enabled>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
+
+By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings-reference#sandbox-failifunavailable>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
###
@@ -85,7 +85,7 @@
WSL2 notes
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings#sandbox-settings>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`; to keep them out of the sandbox entirely, add the command to [`excludedCommands`](</docs/en/settings#sandbox-settings>).
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings-reference#sandbox-network-allowunixsockets>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`; to keep them out of the sandbox entirely, add the command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
###
@@ -124,7 +124,7 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings-reference#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
####
@@ -140,7 +140,7 @@
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings-reference#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -159,13 +159,13 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
+This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings-reference#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
Example rules| Result
---|---
`"denyRead": ["~/"]` with `"allowRead": ["~/projects"]`| `~/projects` is readable and the rest of the home directory stays blocked. The narrower allow re-opens that part of the denied region
`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. The deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
-`"allowRead": ["~/"]` with `"denyRead": ["~/**/.env"]`| Every `.env` under the home directory stays blocked and the rest is readable. A [wildcard deny](</docs/en/settings#sandbox-path-prefixes>) holds inside a wider allow the same way an exact path does
+`"allowRead": ["~/"]` with `"denyRead": ["~/**/.env"]`| Every `.env` under the home directory stays blocked and the rest is readable. A [wildcard deny](</docs/en/settings-reference#sandbox-path-prefixes>) holds inside a wider allow the same way an exact path does
The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
@@ -224,7 +224,7 @@
`"mode": "deny"`| Yes| Nothing: the read block is part of the filesystem layer
`"mode": "mask"`, applied as a mask| No| Masking itself: the sentinel copy and proxy on Linux and WSL2, the sandbox’s own read rules on macOS
`"mode": "mask"`, fallen back to `deny` at setup| No| Nothing, same as `deny`. List a path that can’t be masked, such as a directory, as an explicit `deny` entry, which pins the key
-`"mode": "mask"`, [degraded to `deny` by validation](</docs/en/settings#invalid-entries-in-managed-settings>)| Yes, like an explicit `deny`| Nothing, same as `deny`
+`"mode": "mask"`, [degraded to `deny` by validation](</docs/en/managed-settings#invalid-entries-in-managed-settings>)| Yes, like an explicit `deny`| Nothing, same as `deny`
A fallback happens when the sandbox starts, after Claude Code has already read the settings the pin check runs on, so a fallen-back entry never pins. Validation rewrites an invalid entry to `deny` while settings load, so a degraded entry pins like one you wrote as `deny`.
@@ -245,7 +245,7 @@
Two other things change:
* Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the session one. On Linux the variable is often unset in the parent shell, so it can expand empty inside sandboxed commands; Claude Code tells Claude through its Bash tool guidance to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
- * [`autoAllowBashIfSandboxed`](</docs/en/settings#sandbox-settings>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
+ * [`autoAllowBashIfSandboxed`](</docs/en/settings-reference#sandbox-autoallowbashifsandboxed>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
###
@@ -271,7 +271,7 @@
}
}
-Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings-reference#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
###
@@ -287,7 +287,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`.
{
"sandbox": {
@@ -310,7 +310,7 @@
* **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
* **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
-`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings-reference#sandbox-credentials-allowplaintextinject>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
* `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
* `onExtractNoMatch` controls what happens when the pattern matches nothing:
@@ -319,7 +319,7 @@
* `error` stops sandbox setup until you fix the configuration
* `decode: "jwt"`: for a variable holding a JSON Web Token (JWT). Claude Code verifies the value is a JWT and replaces it with a structurally valid fake token, so code inside the sandbox that decodes the token keeps working. Add `maskClaims` to list top-level payload claims to mask individually instead of replacing the whole token; the other claims stay readable. When the value doesn’t verify as a JWT, or no listed claim matches, Claude Code passes the variable through unmasked with a warning. `decode` can’t be combined with `extract`.
-See the [`credentials.envVars[]` rows in the settings reference](</docs/en/settings#sandbox-settings>) for the full field list.
+See the [`credentials.envVars[]` rows in the settings reference](</docs/en/settings-reference#sandbox-settings>) for the full field list.
####
@@ -327,7 +327,7 @@
Re-sign AWS requests
-AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential lives in variables with other names, group them yourself with [`credentials.awsPairs`](</docs/en/settings#sandbox-settings>), which requires Claude Code v2.1.224 or later. This example adds the pairing to a configuration that already masks `MY_KEY_ID`, `MY_SECRET_KEY`, and `MY_SESSION_TOKEN` whole-value, as in the masking configuration above:
+AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential lives in variables with other names, group them yourself with [`credentials.awsPairs`](</docs/en/settings-reference#sandbox-credentials-awspairs>), which requires Claude Code v2.1.224 or later. This example adds the pairing to a configuration that already masks `MY_KEY_ID`, `MY_SECRET_KEY`, and `MY_SESSION_TOKEN` whole-value, as in the masking configuration above:
{
"sandbox": {
@@ -350,7 +350,7 @@
* The proxy re-signs requests on the hosts listed in the access key ID entry’s `injectHosts`.
* Naming any of the conventional variables in a pair replaces the automatic pairing.
-Like `mask` entries, `awsPairs` is honored only from user settings, managed settings, and the `--settings` CLI flag. Three AWS request forms carry signatures the proxy can’t recompute. When such a request is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature; requests signed with unmasked credentials are never affected. The [`credentials.sigv4`](</docs/en/settings#sandbox-settings>) setting, which requires Claude Code v2.1.224 or later, relaxes this per form: setting a form’s key to `passthrough` forwards the request with its placeholder-derived signature, so the calling tool receives AWS’s own rejection response instead of a proxy error. Like `awsPairs`, `sigv4` is honored only from user settings, managed settings, and the `--settings` CLI flag.
+Like `mask` entries, `awsPairs` is honored only from user settings, managed settings, and the `--settings` CLI flag. Three AWS request forms carry signatures the proxy can’t recompute. When such a request is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature; requests signed with unmasked credentials are never affected. The [`credentials.sigv4`](</docs/en/settings-reference#sandbox-credentials-sigv4>) setting, which requires Claude Code v2.1.224 or later, relaxes this per form: setting a form’s key to `passthrough` forwards the request with its placeholder-derived signature, so the calling tool receives AWS’s own rejection response instead of a proxy error. Like `awsPairs`, `sigv4` is honored only from user settings, managed settings, and the `--settings` CLI flag.
Request form| `sigv4` key| Why the proxy can’t re-sign it
---|---|---
@@ -369,7 +369,7 @@
* **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, a stand-in whose secret is replaced with a placeholder value, and the sandbox proxy substitutes the real value on egress.
* **macOS** : sandboxed commands can’t read the listed file at all. Claude Code builds no sentinel copy and substitutes nothing on egress, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. Unlike a `deny` entry, the read block holds even when you disable filesystem isolation.
-On every platform, the [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) requirement, `injectHosts`, and the settings-source restriction work the same way as for masked environment variables. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
+On every platform, the [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) requirement, `injectHosts`, and the settings-source restriction work the same way as for masked environment variables. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
{
"sandbox": {
@@ -447,14 +447,14 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch` allow rules, as described in Permission rules.
- * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
- * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
+ * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings-reference#sandbox-network-alloweddomains>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch` allow rules, as described in Permission rules.
+ * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings-reference#sandbox-network-strictallowlist>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
+ * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
-The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
+The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
####
@@ -548,7 +548,7 @@
Enforce sandboxing with managed settings
-To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/settings#settings-files>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on Claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
+To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/managed-settings#delivery-mechanisms>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on Claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
{
"sandbox": {
@@ -571,7 +571,7 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings-reference#sandbox-network-allowmanageddomainsonly>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
###
@@ -586,7 +586,7 @@
* Log all network requests
* Integrate with existing security infrastructure
-To point Claude Code at your proxy, set the proxy ports in [sandbox settings](</docs/en/settings#sandbox-settings>):
+To point Claude Code at your proxy, set the proxy ports in [sandbox settings](</docs/en/settings-reference#sandbox-settings>):
{
"sandbox": {
@@ -607,11 +607,11 @@
* **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
* **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
- * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings#sandbox-settings>) to `true` instead.
- * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings#sandbox-settings>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
+ * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings-reference#sandbox-enableweakernetworkisolation>) to `true` instead.
+ * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings-reference#sandbox-allowappleevents>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
- * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself or, if the same git command fails often, add that command to [`excludedCommands`](</docs/en/settings#sandbox-settings>).
- * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+ * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself or, if the same git command fails often, add that command to [`excludedCommands`](</docs/en/settings-reference#sandbox-excludedcommands>).
+ * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings-reference#sandbox-enableweakernestedsandbox>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
@@ -628,7 +628,7 @@
Security limitations
- * **Network filtering** : the sandbox restricts which domains processes can connect to. By default the built-in proxy does not terminate or inspect TLS on outbound traffic, so the contents of encrypted connections are not examined. The experimental [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) setting terminates TLS at the proxy for `mask` credential substitution but does not add content filtering. You are responsible for ensuring that only trusted domains are allowed in your policy.
+ * **Network filtering** : the sandbox restricts which domains processes can connect to. By default the built-in proxy does not terminate or inspect TLS on outbound traffic, so the contents of encrypted connections are not examined. The experimental [`network.tlsTerminate`](</docs/en/settings-reference#sandbox-network-tlsterminate>) setting terminates TLS at the proxy for `mask` credential substitution but does not add content filtering. You are responsible for ensuring that only trusted domains are allowed in your policy.
Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
@@ -671,5 +671,5 @@
* [Sandbox environments](</docs/en/sandbox-environments>): compare the built-in sandbox with dev containers, containers, and VMs
* [Security](</docs/en/security>): comprehensive security features and best practices
* [Permissions](</docs/en/permissions>): permission configuration and access control
- * [Settings](</docs/en/settings>): complete configuration reference
+ * [Settings reference](</docs/en/settings-reference>): every settings key
* [CLI reference](</docs/en/cli-reference>): command-line options
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -164,7 +164,8 @@
Example rules| Result
---|---
`"denyRead": ["~/"]` with `"allowRead": ["~/projects"]`| `~/projects` is readable and the rest of the home directory stays blocked. The narrower allow re-opens that part of the denied region
-`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. An exact deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
+`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. The deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
+`"allowRead": ["~/"]` with `"denyRead": ["~/**/.env"]`| Every `.env` under the home directory stays blocked and the rest is readable. A [wildcard deny](</docs/en/settings#sandbox-path-prefixes>) holds inside a wider allow the same way an exact path does
The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
@@ -446,7 +447,7 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. When you’re prompted, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
+ * **Domain restrictions** : Claude Code pre-allows no domains by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. If you choose Yes when prompted, Claude Code allows the host for the rest of the current session and doesn’t prompt again for later connections to the same host. If you choose “Yes, and don’t ask again”, Claude Code saves a `WebFetch(domain:...)` allow rule to your [local settings](</docs/en/permissions#permission-system>), so the host stays allowed in future sessions. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. Claude Code also pre-allows domains from `WebFetch` allow rules, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
@@ -461,7 +462,7 @@
IPv6 addresses in domain lists
-The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
+The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. When you choose “Yes, and don’t ask again” at the network approval prompt for an IPv6 address, Claude Code saves the `WebFetch(domain:...)` rule with the address bracketed, so the rule keeps matching the address in future sessions. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
* **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing.
* **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -104,7 +104,7 @@
When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
- * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still go through the regular permission flow
+ * `rm` or `rmdir` commands that target a [critical path](</docs/en/permission-modes#critical-paths>) still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
@@ -449,6 +449,7 @@
* **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. When you’re prompted, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
+ * **Corporate proxy** : when your network requires outbound traffic to go through a corporate proxy, set `HTTPS_PROXY`, `HTTP_PROXY`, and `NO_PROXY` as [proxy configuration](</docs/en/network-config#proxy-configuration>) describes, in the `env` block of your settings so that [background agents](</docs/en/network-config#set-network-variables-in-settings-not-the-shell>) get them too, or in the environment you launch Claude Code from. Claude Code enforces the domain allowlist and then tunnels allowed connections through that upstream proxy.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
@@ -528,9 +529,9 @@
---|---|---
`/sandbox`| What a Bash command can access once it runs| The sandbox boundary itself, in auto-allow mode
[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
-`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>), removing `/` or your home directory, and the [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still prompt
-
-The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>).
+`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; the [actions no mode auto-approves](</docs/en/permission-modes#actions-no-mode-auto-approves>) still apply
+
+The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>). For a table of common permission mode and sandbox pairings with the flags that start each one, see [Common setups](</docs/en/permission-modes#common-setups>).
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -36,7 +36,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
@@ -101,14 +101,14 @@
Auto-allow mode
-When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
+When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in Manual mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even in Manual mode, where the file edit tools would prompt.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
####
@@ -124,7 +124,7 @@
The unsandboxed retry escape hatch
-Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in Manual mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
####
@@ -446,7 +446,7 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval. Choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
+ * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval, or in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) sends the request to the classifier. When you’re prompted, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -104,11 +104,11 @@
When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
- * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later
+ * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still go through the regular permission flow
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals. Bash commands outside the [built-in read-only set](</docs/en/permissions#read-only-commands>) prompt for approval even with auto-allow enabled, or go to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on; in v2.1.212 through v2.1.217 they always prompted. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals; see [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>) for how Claude Code gates commands while you plan. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
####
@@ -286,7 +286,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. The proxy injects only on connections the domain allowlist admits, so each `injectHosts` destination must also be reachable through `network.allowedDomains`.
{
"sandbox": {
@@ -304,7 +304,12 @@
}
}
-Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+Spell an IPv6 destination differently in the two lists, because each list has its own matcher:
+
+ * **`network.allowedDomains`** : the bracketed form domain lists use, such as `"[::1]"`. The proxy checks this list to admit the connection.
+ * **`injectHosts`** : the bare address in its canonical compressed form, such as `"::1"` or `"2001:db8::1"`. The proxy matches each entry against the connection’s bare destination address, ignoring ports, so a bracketed, zone-ID, or differently compressed spelling never matches and the proxy never injects the credential there.
+
+`/doctor` flags `injectHosts` entries that can never match with the warning `Sandbox credential injectHosts entries can never match their destination`. Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
* `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
* `onExtractNoMatch` controls what happens when the pattern matches nothing:
@@ -449,6 +454,19 @@
The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
+####
+
+
+
+IPv6 addresses in domain lists
+
+The sandbox’s domain lists are `allowedDomains`, `deniedDomains`, and the `WebFetch(domain:...)` rules that feed them. To match an IPv6 address in any of them, write the literal in brackets: `"[::1]"` matches that address on every port, and `"[::1]:443"` matches it on port 443 only. Write the port as a number from 1 to 65535 with no leading zeros. The bracketed form requires Claude Code v2.1.229 or later. Before v2.1.229, when the text after an unbracketed entry’s last colon was a port number, Claude Code read it as one, so `::1:443` named the address `::1` on port 443. An unbracketed entry with two or more colons is ambiguous: `::1:443` is both a complete IPv6 address and an address followed by a port. Claude Code enforces ambiguous spellings conservatively instead of guessing which reading you meant:
+
+ * **Deny lists** : Claude Code denies every reading the entry parses as, so whichever reading you meant is blocked. For an entry with no parseable reading, Claude Code blocks nothing.
+ * **Allow lists** : Claude Code never allows more than you wrote. It rewrites an ambiguous entry to its host-and-port reading when that reading parses cleanly, and may drop the entry entirely rather than widen the allowlist.
+
+Run `/doctor` to list the affected entries. The `Sandbox network domain entries have unreliable spellings` warning names each one. Rewrite them in the bracketed form to clear it. The warning also names entries whose spelling is unreliable for other reasons, such as `@`, path or query characters, or wildcards inside brackets.
+
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -461,7 +461,7 @@
* **Linux** : uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
* **WSL2** : uses bubblewrap, same as Linux
-WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These OS-level restrictions ensure that all child processes spawned by Claude Code’s commands inherit the same security boundaries. These same primitives are available as the standalone [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package, which the [Sandbox environments](</docs/en/sandbox-environments#sandbox-runtime>) page covers as a separate approach for wrapping the entire Claude Code process.
+WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These same primitives are available as the standalone [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package, which the [Sandbox environments](</docs/en/sandbox-environments#sandbox-runtime>) page covers as a separate approach for wrapping the entire Claude Code process.
##
@@ -489,7 +489,7 @@
`sandbox.filesystem.allowWrite`| Grants subprocess write access to paths outside the working directory
`sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`| Block subprocess access to specific paths
`sandbox.filesystem.allowRead`| Re-allows reading specific paths within a `denyRead` region
-`sandbox.filesystem.disabled`| Turns the filesystem layer off entirely while keeping network isolation; requires Claude Code v2.1.216 or later
+`sandbox.filesystem.disabled`| Turns the filesystem layer off entirely while keeping network isolation
`Edit` allow rules| Grant write access to specific paths, the same way `sandbox.filesystem.allowWrite` does
`Read` and `Edit` deny rules| Block access to specific files or directories
`WebFetch` allow and deny rules| Control domain access
Show diff (111 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -93,16 +93,46 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : when a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
+Claude Code offers two sandbox modes. In both, the sandbox enforces the same filesystem and network restrictions; the difference is only in whether sandboxed commands are auto-approved or require explicit permission.
+
+####
+
+
+
+Auto-allow mode
+
+When a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
-
Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals. Bash commands outside the [built-in read-only set](</docs/en/permissions#read-only-commands>) prompt for approval even with auto-allow enabled, or go to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on; in v2.1.212 through v2.1.217 they always prompted. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+
+####
+
+
+
+Regular permissions mode
+
+All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals.
+
+####
+
+
+
+The unsandboxed retry escape hatch
+
+Some commands can’t run inside the sandbox at all, such as tools that are incompatible with it or that need a host you haven’t allowed. When a command fails after the sandbox denied it access, Claude Code appends the violation details to the failed command’s output, so Claude sees which file path or network host the sandbox blocked. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+
+####
+
+
+
+Temporary directories
+
+The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead.
##
@@ -121,7 +151,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When the same filesystem array is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are merged: paths from every scope are combined, not replaced. Path prefixes control how paths are resolved:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When the same filesystem array is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are merged: paths from every scope are combined, not replaced. When you edit these lists during a session, Claude Code [applies the change to the running session](</docs/en/settings#when-edits-take-effect>), so the next sandboxed command runs under the new paths. Path prefixes control how paths are resolved:
Prefix| Meaning| Example
---|---|---
@@ -129,7 +159,7 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
+This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. For how Claude Code treats a trailing slash or a wildcard in these paths, see [Sandbox path prefixes](</docs/en/settings#sandbox-path-prefixes>). You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
Example rules| Result
---|---
@@ -392,6 +422,21 @@
+Protected paths
+
+Inside the directories that sandboxed commands can write to, the sandbox still denies writes to the files Claude Code loads configuration and code from. A command that could edit those files could grant itself permissions, or add a hook or MCP server that Claude Code runs outside the sandbox. The permission system has its own [protected paths](</docs/en/permission-modes#protected-paths>), which control what Claude Code approves before a tool runs; the sandbox’s list applies to a command that is already running. It covers four groups of paths:
+
+ * **In your working directory and the directories above it** : the `.claude` settings files, the `.claude/skills`, `.claude/agents`, `.claude/commands`, and `.claude/hooks` directories, `.mcp.json`, and the files Claude Code runs on its own, such as `.claude/workflows` and `.claude/scheduled_tasks.json`
+ * **In your working directory only** : shell startup files such as `.bashrc` and `.zshrc`, `.gitconfig`, the `.vscode` and `.idea` directories, and `hooks` and `config` inside `.git`
+ * **Files that would turn your working directory into a bare git repository** : `HEAD`, `objects`, and `refs` at the top level, plus `config` and `hooks` there when they already exist, even when the `config` directory belongs to your project rather than to git. On Linux and WSL2, the sandbox deletes a top-level `HEAD` file or `objects` or `refs` directory that appears while a sandboxed command is running
+ * **In`~/.claude`, or the directory `CLAUDE_CONFIG_DIR` points to**: most of its contents, plus `~/.claude.json` and the `.credentials.json` credential store
+
+If a symlink appears at a protected settings file’s path during the session, the sandbox also denies writes to the file it points to, starting with the next command. There is no way to exempt one of these paths: an `allowWrite` entry or an `Edit` allow rule that covers the path doesn’t lift the protection. The only way to turn the protection off is `filesystem.disabled`, which turns off filesystem isolation for every path. To see most of these paths resolved for your machine, run `/sandbox` and open the **Config** tab, which lists them under **Denied within allowed** , mixed in with your own `denyWrite` entries. If `git merge` or `git checkout` fails with `unable to unlink old` on one of these paths, see Troubleshooting.
+
+###
+
+
+
Network isolation
Network access is controlled through a proxy server running outside the sandbox:
@@ -545,6 +590,7 @@
* **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings#sandbox-settings>) to `true` instead.
* **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings#sandbox-settings>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
+ * **A git command fails with`unable to unlink old`**: `git merge`, `git checkout`, and similar commands fail this way when they need to replace a file the sandbox denies writes to, whether that file is under a protected path such as `.claude/skills`, under one of your `denyWrite` entries, or outside the directories the sandbox lets commands write to at all. On Linux and WSL2 the error ends with `Read-only file system`. After the failure, Claude may offer to rerun the command outside the sandbox; approve that retry, or run the git command yourself in another terminal. If you’ve set `allowUnsandboxedCommands` to `false`, Claude can’t offer the retry, so run the command yourself or, if the same git command fails often, add that command to [`excludedCommands`](</docs/en/settings#sandbox-settings>).
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
@@ -570,10 +616,6 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
- * **Settings files protected** : the sandbox automatically denies write access to the files a sandboxed command could otherwise edit its own policy through, unless you disable filesystem isolation, which turns these deny rules off. The protected set:
- * Claude Code’s `settings.json` files at every scope, and the managed settings directory
- * `.mcp.json` at the project root, and at the root of each directory added with [`--add-dir` or `/add-dir`](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>)
- * The target of any symlink that appears at a protected settings file path after startup, added to the deny list for the next command so a linked settings file can’t be edited through the link. Before v2.1.210, the deny rules didn’t resolve symlinks
###
Show diff (103 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -85,7 +85,7 @@
WSL2 notes
-Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, sandboxed commands cannot launch Windows binaries such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/`. WSL hands these off to the Windows host over a Unix socket, which the sandbox blocks. If a command needs to invoke a Windows binary, add it to [`excludedCommands`](</docs/en/settings#sandbox-settings>) so it runs outside the sandbox.
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, WSL hands a launch of a Windows binary such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/` to the Windows host over a Unix socket, so whether a sandboxed command can launch one follows the sandbox’s [Unix-socket settings](</docs/en/settings#sandbox-settings>): the optional seccomp filter has to be installed to block the socket in the first place. To allow these launches, set `allowAllUnixSockets`; to keep them out of the sandbox entirely, add the command to [`excludedCommands`](</docs/en/settings#sandbox-settings>).
###
@@ -256,7 +256,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. Requests that authenticate with a signature derived from the credential, rather than the credential itself, need re-signing at the proxy; Re-sign AWS requests covers how that works for AWS. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
{
"sandbox": {
@@ -274,7 +274,53 @@
}
}
-Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence.
+Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence. Masking replaces the variable’s entire value by default, which suits a bare token. Optional entry fields, which require Claude Code v2.1.224 or later, handle values with structure:
+
+ * `extract`: a regular expression Claude Code applies across the value, replacing only the text captured by group 1 of each match, so a tool that parses the value, such as a `DATABASE_URL` connection string, still works inside the sandbox. The pattern must contain at least one capturing group.
+ * `onExtractNoMatch` controls what happens when the pattern matches nothing:
+ * `warn`, the default, warns and passes the variable through unmasked
+ * `deny` unsets the variable inside the sandbox
+ * `error` stops sandbox setup until you fix the configuration
+ * `decode: "jwt"`: for a variable holding a JSON Web Token (JWT). Claude Code verifies the value is a JWT and replaces it with a structurally valid fake token, so code inside the sandbox that decodes the token keeps working. Add `maskClaims` to list top-level payload claims to mask individually instead of replacing the whole token; the other claims stay readable. When the value doesn’t verify as a JWT, or no listed claim matches, Claude Code passes the variable through unmasked with a warning. `decode` can’t be combined with `extract`.
+
+See the [`credentials.envVars[]` rows in the settings reference](</docs/en/settings#sandbox-settings>) for the full field list.
+
+####
+
+
+
+Re-sign AWS requests
+
+AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. Claude Code links the conventional `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` variables into one credential automatically when you mask their whole values. If your AWS credential lives in variables with other names, group them yourself with [`credentials.awsPairs`](</docs/en/settings#sandbox-settings>), which requires Claude Code v2.1.224 or later. This example adds the pairing to a configuration that already masks `MY_KEY_ID`, `MY_SECRET_KEY`, and `MY_SESSION_TOKEN` whole-value, as in the masking configuration above:
+
+ {
+ "sandbox": {
+ "credentials": {
+ "awsPairs": [
+ {
+ "accessKeyIdVar": "MY_KEY_ID",
+ "secretAccessKeyVar": "MY_SECRET_KEY",
+ "sessionTokenVar": "MY_SESSION_TOKEN"
+ }
+ ]
+ }
+ }
+ }
+
+Each entry follows these rules:
+
+ * `accessKeyIdVar` and `secretAccessKeyVar` name the masked `envVars` entries holding the access key ID and the secret key. The optional `sessionTokenVar` names the entry holding the session token for temporary credentials; when set, the proxy sends the real token as `x-amz-security-token` on re-signed requests.
+ * Each named variable must be a `mask` entry that masks its entire value, without `extract` or `decode`.
+ * The proxy re-signs requests on the hosts listed in the access key ID entry’s `injectHosts`.
+ * Naming any of the conventional variables in a pair replaces the automatic pairing.
+
+Like `mask` entries, `awsPairs` is honored only from user settings, managed settings, and the `--settings` CLI flag. Three AWS request forms carry signatures the proxy can’t recompute. When such a request is signed with a masked pair’s placeholder, the proxy fails it rather than forward a broken signature; requests signed with unmasked credentials are never affected. The [`credentials.sigv4`](</docs/en/settings#sandbox-settings>) setting, which requires Claude Code v2.1.224 or later, relaxes this per form: setting a form’s key to `passthrough` forwards the request with its placeholder-derived signature, so the calling tool receives AWS’s own rejection response instead of a proxy error. Like `awsPairs`, `sigv4` is honored only from user settings, managed settings, and the `--settings` CLI flag.
+
+Request form| `sigv4` key| Why the proxy can’t re-sign it
+---|---|---
+aws-chunked streaming uploads| `streaming`| Per-chunk signatures chain off the seed signature, so re-signing would require rewriting the body
+Presigned URLs| `presigned`| The signature lives in the URL itself, with no `Authorization` header
+SigV4A asymmetric signatures| `sigv4a`| There is no shared-key HMAC to recompute
####
@@ -309,14 +355,14 @@
}
}
-To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command: on Linux and WSL2 the output shows a sentinel value in place of the token, and on macOS the read fails instead. On Linux and WSL2, the `extract` pattern is what keeps the rest of `hosts.yml` readable. Claude Code applies the regular expression across the whole file and replaces only the text captured by group 1 of each match, so `gh` still parses its config and only the token is a placeholder. Use `extract` for any structured file that tools parse, such as `.netrc`, JSON, or YAML; the pattern must contain at least one capturing group. Without `extract`, Claude Code replaces the entire file content with one sentinel value, which suits a file that holds a single bare secret and nothing else. Two optional fields refine how `extract` behaves. Both apply only when `mode` is `mask` and `extract` is set. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so these fields, and the no-match outcomes below, take effect there only when filesystem isolation is off:
-
- * `onExtractNoMatch` controls what happens when the regex matches nothing in the file:
+To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command: on Linux and WSL2 the output shows a sentinel value in place of the token, and on macOS the read fails instead. On Linux and WSL2, the `extract` pattern is what keeps the rest of `hosts.yml` readable. Claude Code applies the regular expression across the whole file and replaces only the text captured by group 1 of each match, so `gh` still parses its config and only the token is a placeholder. Use `extract` for any structured file that tools parse, such as `.netrc`, JSON, or YAML; the pattern must contain at least one capturing group. Without `extract`, Claude Code replaces the entire file content with one sentinel value, which suits a file that holds a single bare secret and nothing else. For a file that holds a JSON Web Token (JWT), set `decode: "jwt"` instead of, or together with, `extract`. `decode` requires Claude Code v2.1.224 or later. Claude Code finds JWT candidates with a built-in pattern, or with your `extract` pattern when set, verifies each candidate is a JWT, and replaces it with a structurally valid fake token, so code that decodes the token inside the sandbox keeps working. Add `maskClaims` to mask only the named top-level payload claims inside each verified token and leave the other claims readable. When no candidate verifies, or no named claim matches, the `onExtractNoMatch` field below governs the outcome, as it does for a pattern that matches nothing. Two optional fields refine how matching behaves. Both apply only when `mode` is `mask` and `extract` or `decode` is set. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so these fields, and the no-match outcomes below, take effect there only when filesystem isolation is off:
+
+ * `onExtractNoMatch` controls what happens when matching finds nothing to mask in the file:
* `warn`, the default, warns and skips the entry, so sandboxed commands can read the real file unmasked. The default suits credentials that may be legitimately absent; if the secret might be present but the pattern might miss it, use `deny`
* `deny` makes the file unreadable instead
* `error` stops sandbox setup until you fix the configuration
Claude Code treats `deny` as `error` whenever the read block wouldn’t be enforced: when you disable filesystem isolation, and when a `filesystem.allowRead` entry from any settings source re-opens the file’s path.
- * `maskDuplicates` also replaces verbatim copies of each captured credential value found outside the regex matches, for a secret repeated where the regex doesn’t reach. It matches raw substrings, so a short or common value would be replaced everywhere it appears; reserve it for long, high-entropy secrets. Default: false.
+ * `maskDuplicates` also replaces verbatim copies of each masked credential value, an `extract` capture or a `decode`-verified token, found outside the matched spans, for a secret repeated where matching doesn’t reach. It matches raw substrings, so a short or common value would be replaced everywhere it appears; reserve it for long, high-entropy secrets. Default: false.
`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text. Write directories as explicit `deny` entries instead; the table under Which settings can disable it covers whether each form pins `filesystem.disabled` and how it behaves with filesystem isolation off.
@@ -419,7 +465,7 @@
---|---|---
`/sandbox`| What a Bash command can access once it runs| The sandbox boundary itself, in auto-allow mode
[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
-`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>), and removing `/` or your home directory still prompt
+`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>), removing `/` or your home directory, and the [cross-session messaging safeguards](</docs/en/permission-modes#skip-all-checks-with-bypasspermissions-mode>) still prompt
The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -148,7 +148,7 @@
}
}
-The `.` in `allowRead` resolves to the project root because this configuration lives in project settings. If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
+If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
###
@@ -340,7 +340,7 @@
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
-You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level, so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools. To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
+To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
###
@@ -350,7 +350,7 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
+ * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval. Choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
* **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
@@ -500,7 +500,6 @@
* **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings#sandbox-settings>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
- * **Seccomp filter on Linux** : the seccomp filter is required to block Unix domain sockets. The Dependencies tab in `/sandbox` appears only when a dependency is missing; if you don’t see the tab after a restart, the filter is already installed. If the filter is missing, run `npm install -g @anthropic-ai/sandbox-runtime` to install the helper, then restart Claude Code so the startup dependency check detects it.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
Show diff (158 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -100,7 +100,7 @@
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories unless you disable filesystem isolation. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Unless you disable filesystem isolation, Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, so while filesystem isolation is on, sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals. Bash commands outside the [built-in read-only set](</docs/en/permissions#read-only-commands>) prompt for approval even with auto-allow enabled, or go to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on; in v2.1.212 through v2.1.217 they always prompted. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
@@ -183,20 +183,38 @@
Because turning filesystem isolation off widens what sandboxed commands can do, Claude Code honors `filesystem.disabled` from these settings sources only:
* User settings, managed settings, and the `--settings` CLI flag can set it. Project settings in `.claude/settings.json` and `.claude/settings.local.json` can’t, so a checked-out project can’t switch filesystem isolation off.
- * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
+ * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
* When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
+Whether a managed `credentials.files` entry pins `filesystem.disabled`, locking the key to managed settings so developers can’t turn filesystem isolation off, depends on the entry’s `mode` and what happens to the entry when the sandbox starts:
+
+Managed entry| Pins `filesystem.disabled`| What protects the file when isolation is off
+---|---|---
+`"mode": "deny"`| Yes| Nothing: the read block is part of the filesystem layer
+`"mode": "mask"`, applied as a mask| No| Masking itself: the sentinel copy and proxy on Linux and WSL2, the sandbox’s own read rules on macOS
+`"mode": "mask"`, fallen back to `deny` at setup| No| Nothing, same as `deny`. List a path that can’t be masked, such as a directory, as an explicit `deny` entry, which pins the key
+`"mode": "mask"`, [degraded to `deny` by validation](</docs/en/settings#invalid-entries-in-managed-settings>)| Yes, like an explicit `deny`| Nothing, same as `deny`
+
+A fallback happens when the sandbox starts, after Claude Code has already read the settings the pin check runs on, so a fallen-back entry never pins. Validation rewrites an invalid entry to `deny` while settings load, so a degraded entry pins like one you wrote as `deny`.
+
####
-What changes when isolation is off
-
-Turning the filesystem layer off also lifts its read protections and stops overriding `$TMPDIR`, while sandboxed commands stay auto-allowed:
-
- * The read protections from `filesystem.denyRead` and `credentials.files` don’t apply to sandboxed commands, because the filesystem layer enforces both. `credentials.envVars` deny and mask entries still apply, since environment variable scrubbing is independent of the filesystem layer.
- * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, since every temp directory is writable.
- * [`autoAllowBashIfSandboxed`](</docs/en/settings#sandbox-settings>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to keep prompting for sandboxed commands.
+What changes when filesystem isolation is off
+
+Setting `filesystem.disabled` lifts the protections the filesystem layer itself enforces. Protections that other layers enforce keep applying:
+
+Protection| With filesystem isolation off
+---|---
+`filesystem.denyRead` and `credentials.files` `deny` read blocks| Not enforced. The filesystem layer applies both
+`credentials.envVars` `deny` and `mask` entries| Enforced. Environment variable scrubbing is independent of the filesystem layer
+`credentials.files` `mask` entries applied as masks| Enforced: masking is independent of the filesystem layer. An entry that fell back to `deny` is not enforced, like any `deny` entry
+
+Two other things change:
+
+ * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, because every temp directory is writable and Claude Code no longer redirects commands to the session one. On Linux the variable is often unset in the parent shell, so it can expand empty inside sandboxed commands; Claude Code tells Claude through its Bash tool guidance to create scratch directories with `mktemp -d` instead of relying on `$TMPDIR`.
+ * [`autoAllowBashIfSandboxed`](</docs/en/settings#sandbox-settings>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to prompt for sandboxed commands.
###
@@ -222,7 +240,15 @@
}
}
-File entries support only `"mode": "deny"`. Environment variable entries also accept `"mode": "mask"`, described below. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+Environment variable entries and file entries also accept `"mode": "mask"`, described under Mask credentials. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+
+###
+
+
+
+Mask credentials
+
+Masking goes further than a `deny` entry under Protect credentials. Instead of blocking a credential, Claude Code shows sandboxed commands a placeholder, the sentinel, and the sandbox proxy swaps in the real value on outbound requests to hosts you allow. For files, the substitution is Linux and WSL2 behavior; macOS blocks the file instead.
####
@@ -230,7 +256,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. When a request leaves the sandbox for one of the credential’s `injectHosts`, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails closed: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. Each `mask` entry can list `injectHosts`, the hosts the real value is allowed to reach. When a request leaves the sandbox for one of them, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails without exposing anything: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. Substitution covers headers and request bodies. AWS requests carry SigV4 signatures over the request contents, so mask `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` together. The proxy detects a SigV4 request by the access key’s sentinel and re-signs it after substituting the real values. Masking the secret alone leaves requests signed with the placeholder, which the proxy can’t detect, so they fail at AWS; Claude Code warns about this case at startup, but not when only the access key ID is masked. A detected request the proxy can’t re-sign, such as one missing its `x-amz-date` header, fails with a proxy error instead of reaching the server with a broken signature. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
{
"sandbox": {
@@ -248,7 +274,51 @@
}
}
-Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>) in a repository’s `.claude/settings.json` or `.claude/settings.local.json` are ignored. When the same variable is listed with `deny` in any scope, `deny` takes precedence.
+Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>), which lets the proxy inject credentials into unencrypted requests, are all ignored in a repository’s `.claude/settings.json` or `.claude/settings.local.json`. When the same variable is listed with `deny` in any scope, `deny` takes precedence.
+
+####
+
+
+
+Mask credential files
+
+File entries also accept `"mode": "mask"`, which requires Claude Code v2.1.221 or later. What a sandboxed command sees depends on the platform:
+
+ * **Linux and WSL2** : sandboxed commands read a sentinel copy of the file, a stand-in whose secret is replaced with a placeholder value, and the sandbox proxy substitutes the real value on egress.
+ * **macOS** : sandboxed commands can’t read the listed file at all. Claude Code builds no sentinel copy and substitutes nothing on egress, so tools that authenticate with the file don’t work inside the sandbox, the same effect as `deny`. Unlike a `deny` entry, the read block holds even when you disable filesystem isolation.
+
+On every platform, the [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) requirement, `injectHosts`, and the settings-source restriction work the same way as for masked environment variables. The example below masks a GitHub token stored in `~/.config/gh/hosts.yml`; the `extract` pattern, covered below, tells Claude Code which part of the file is the secret. On Linux and WSL2, sandboxed commands that read the file get a sentinel in place of the token, and the proxy substitutes the real token on requests to `api.github.com`:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "network": {
+ "tlsTerminate": {},
+ "allowedDomains": ["*.github.com"]
+ },
+ "credentials": {
+ "files": [
+ {
+ "path": "~/.config/gh/hosts.yml",
+ "mode": "mask",
+ "extract": "oauth_token:\\s*(\\S+)",
+ "injectHosts": ["api.github.com"]
+ }
+ ]
+ }
+ }
+ }
+
+To confirm the mask is active, ask Claude to run `cat ~/.config/gh/hosts.yml` in a sandboxed command: on Linux and WSL2 the output shows a sentinel value in place of the token, and on macOS the read fails instead. On Linux and WSL2, the `extract` pattern is what keeps the rest of `hosts.yml` readable. Claude Code applies the regular expression across the whole file and replaces only the text captured by group 1 of each match, so `gh` still parses its config and only the token is a placeholder. Use `extract` for any structured file that tools parse, such as `.netrc`, JSON, or YAML; the pattern must contain at least one capturing group. Without `extract`, Claude Code replaces the entire file content with one sentinel value, which suits a file that holds a single bare secret and nothing else. Two optional fields refine how `extract` behaves. Both apply only when `mode` is `mask` and `extract` is set. On macOS, Claude Code applies `mask` entries as `deny` before the pattern runs whenever filesystem isolation is on, so these fields, and the no-match outcomes below, take effect there only when filesystem isolation is off:
+
+ * `onExtractNoMatch` controls what happens when the regex matches nothing in the file:
+ * `warn`, the default, warns and skips the entry, so sandboxed commands can read the real file unmasked. The default suits credentials that may be legitimately absent; if the secret might be present but the pattern might miss it, use `deny`
+ * `deny` makes the file unreadable instead
+ * `error` stops sandbox setup until you fix the configuration
+Claude Code treats `deny` as `error` whenever the read block wouldn’t be enforced: when you disable filesystem isolation, and when a `filesystem.allowRead` entry from any settings source re-opens the file’s path.
+ * `maskDuplicates` also replaces verbatim copies of each captured credential value found outside the regex matches, for a secret repeated where the regex doesn’t reach. It matches raw substrings, so a short or common value would be replaced everywhere it appears; reserve it for long, high-entropy secrets. Default: false.
+
+`mask` applies to a single file, so list each credential file individually. Claude Code falls back to `deny` for a `mask` entry it can’t mask safely: a directory path, a glob pattern, a file larger than 8 MiB, or a file that isn’t UTF-8 text. Write directories as explicit `deny` entries instead; the table under Which settings can disable it covers whether each form pins `filesystem.disabled` and how it behaves with filesystem isolation off.
##
@@ -390,7 +460,7 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry with `"mode": "deny"`, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. Whether a `mask` entry pins the key depends on how it resolves; the table under Which settings can disable it covers the four cases. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
###
@@ -455,7 +525,10 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
- * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command can’t modify its own policy unless you disable filesystem isolation, which turns these deny rules off. The deny rules resolve symlinks: when a symlink appears at a protected settings file path after startup, the sandbox adds its target to the deny list for the next command, so a linked settings file can’t be edited through the link. Before v2.1.210, the deny rules didn’t resolve symlinks.
+ * **Settings files protected** : the sandbox automatically denies write access to the files a sandboxed command could otherwise edit its own policy through, unless you disable filesystem isolation, which turns these deny rules off. The protected set:
+ * Claude Code’s `settings.json` files at every scope, and the managed settings directory
+ * `.mcp.json` at the project root, and at the root of each directory added with [`--add-dir` or `/add-dir`](</docs/en/permissions#additional-directories-grant-file-access-not-configuration>)
+ * The target of any symlink that appears at a protected settings file path after startup, added to the deny list for the next command so a linked settings file can’t be edited through the link. Before v2.1.210, the deny rules didn’t resolve symlinks
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -38,7 +38,7 @@
Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
-Selecting a mode in the panel writes to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
+When you select a mode in the panel, Claude Code saves it to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
@@ -93,7 +93,7 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
+Claude Code offers two sandbox modes: **Auto-allow mode** : when a command can be sandboxed, Claude Code runs it inside the sandbox and approves it automatically, without asking your permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -38,7 +38,7 @@
Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
-Selecting a mode in the panel writes to your project’s local settings at `.claude/settings.local.json`, which apply to the current project and are not checked into git. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
+Selecting a mode in the panel writes to your project’s local settings at `.claude/settings.local.json`, which apply to the current project. Claude Code adds that file to your global gitignore when it saves a setting there. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -281,6 +281,7 @@
Network access is controlled through a proxy server running outside the sandbox:
* **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
+ * **Strict allowlist** : if you set [`strictAllowlist`](</docs/en/settings#sandbox-settings>) to `true` in user, managed, or CLI `--settings` settings, Claude Code denies sandboxed commands access to any host outside the allowlist instead of prompting. The allowlist is the same one the sandbox otherwise prompts against: `allowedDomains` plus domains from `WebFetch(domain:...)` allow rules, or only the managed settings entries when `allowManagedDomainsOnly` is set. Claude Code enforces this for sandboxed commands only; in-process tools such as `WebFetch` still follow their permission rules. Setting it in a repository’s `.claude/settings.json` or `.claude/settings.local.json` has no effect. Requires Claude Code v2.1.219 or later.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -96,13 +96,13 @@
Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
- * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt
+ * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt, or a classifier check in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>); the classifier routing requires Claude Code v2.1.218 or later
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories unless you disable filesystem isolation. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
-Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, only [read-only commands](</docs/en/permissions#read-only-commands>) run without prompting; any other Bash command prompts for approval even with auto-allow enabled. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
+Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, auto-allow doesn’t widen approvals. Bash commands outside the [built-in read-only set](</docs/en/permissions#read-only-commands>) prompt for approval even with auto-allow enabled, or go to the classifier when [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is available and `useAutoModeDuringPlan` is on; in v2.1.212 through v2.1.217 they always prompted. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
##
Show diff (114 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -100,7 +100,7 @@
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
-**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories unless you disable filesystem isolation. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, only [read-only commands](</docs/en/permissions#read-only-commands>) run without prompting; any other Bash command prompts for approval even with auto-allow enabled. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
@@ -154,9 +154,57 @@
+Disable filesystem isolation
+
+Set `sandbox.filesystem.disabled` to `true` to skip filesystem isolation while keeping network isolation. The example below turns off filesystem isolation while keeping an allowlist of network domains:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "filesystem": {
+ "disabled": true
+ },
+ "network": {
+ "allowedDomains": ["github.com", "*.npmjs.org"]
+ }
+ }
+ }
+
+The sandbox has two independent layers: filesystem isolation controls which paths sandboxed commands can read and write, and network isolation controls which domains they can reach. With the filesystem layer off, sandboxed commands get unrestricted read and write access to the host filesystem, while their network egress stays confined to your allowed domains. Turn the layer off when you sandbox to control where commands connect rather than what they write. The setting is off by default and applies on the platforms where the sandbox runs: macOS, Linux, and WSL2. Requires Claude Code v2.1.216 or later.
+
+With filesystem isolation off and commands auto-allowed, a sandboxed command can write files that later commands run or read, such as shell startup files, executables on `$PATH`, or `~/.claude/settings.json`, and use them to widen its own access on the next run. Set `filesystem.disabled` to `true` only for workloads you trust not to escalate their own access. Locking network domains with `allowManagedDomainsOnly` narrows the risk but doesn’t remove it, since that lock applies only to commands running inside the sandbox.
+
+####
+
+
+
+Which settings can disable it
+
+Because turning filesystem isolation off widens what sandboxed commands can do, Claude Code honors `filesystem.disabled` from these settings sources only:
+
+ * User settings, managed settings, and the `--settings` CLI flag can set it. Project settings in `.claude/settings.json` and `.claude/settings.local.json` can’t, so a checked-out project can’t switch filesystem isolation off.
+ * When managed settings configure `sandbox.filesystem` at all, or list any `sandbox.credentials.files` entry, only managed settings can set the key. This keeps administrator-deployed filesystem restrictions in force; to relax such a deployment, set `"disabled": true` in managed settings.
+ * When [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) is set, Claude Code ignores `filesystem.disabled` from every source, including managed settings, and keeps filesystem isolation on.
+
+####
+
+
+
+What changes when isolation is off
+
+Turning the filesystem layer off also lifts its read protections and stops overriding `$TMPDIR`, while sandboxed commands stay auto-allowed:
+
+ * The read protections from `filesystem.denyRead` and `credentials.files` don’t apply to sandboxed commands, because the filesystem layer enforces both. `credentials.envVars` deny and mask entries still apply, since environment variable scrubbing is independent of the filesystem layer.
+ * Sandboxed commands inherit your shell’s `$TMPDIR` instead of the session temp directory, since every temp directory is writable.
+ * [`autoAllowBashIfSandboxed`](</docs/en/settings#sandbox-settings>) still defaults to `true`, so sandboxed commands keep running without prompts. Set it to `false` to keep prompting for sandboxed commands.
+
+###
+
+
+
Protect credentials
-The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
+The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The file protection is part of the filesystem layer, so it doesn’t apply if you disable filesystem isolation; the environment variable protection still does. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
{
"sandbox": {
@@ -222,7 +270,7 @@
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
-You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level, so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools.
+You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level, so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools. To skip filesystem isolation entirely while keeping network isolation, set `sandbox.filesystem.disabled`.
###
@@ -279,6 +327,7 @@
`sandbox.filesystem.allowWrite`| Grants subprocess write access to paths outside the working directory
`sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`| Block subprocess access to specific paths
`sandbox.filesystem.allowRead`| Re-allows reading specific paths within a `denyRead` region
+`sandbox.filesystem.disabled`| Turns the filesystem layer off entirely while keeping network isolation; requires Claude Code v2.1.216 or later
`Edit` allow rules| Grant write access to specific paths, the same way `sandbox.filesystem.allowWrite` does
`Read` and `Edit` deny rules| Block access to specific files or directories
`WebFetch` allow and deny rules| Control domain access
@@ -340,7 +389,7 @@
Keep developers from widening the policy
-For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
+For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). When managed settings configure `sandbox.filesystem` or list any `sandbox.credentials.files` entry, only managed settings can set `filesystem.disabled`, so developers can’t switch off administrator-deployed filesystem restrictions. `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
###
@@ -405,7 +454,7 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
- * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command cannot modify its own policy. In v2.1.210 and later, the deny rules resolve symlinks: when a symlink appears at a protected settings file path after startup, the sandbox adds its target to the deny list for the next command, so a linked settings file can’t be edited through the link.
+ * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command can’t modify its own policy unless you disable filesystem isolation, which turns these deny rules off. The deny rules resolve symlinks: when a symlink appears at a protected settings file path after startup, the sandbox adds its target to the deny list for the next command, so a linked settings file can’t be edited through the link. Before v2.1.210, the deny rules didn’t resolve symlinks.
###
@@ -430,7 +479,7 @@
* **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
-Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
+Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, whether from a permissive policy or from disabling the filesystem layer, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -269,7 +269,7 @@
Permission rules and sandboxing control different things:
- * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to all tools: Bash, Read, Edit, WebFetch, MCP, and others.
+ * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to every tool: Bash, Read, Edit, WebFetch, MCP, and others, except that a deny or ask rule can’t block [`EndConversation`](</docs/en/tools-reference#endconversation-tool-behavior>) while any other tool remains.
* **Sandboxing** provides OS-level enforcement that restricts what Bash commands can access at the filesystem and network level. It applies only to Bash commands and their child processes.
The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -98,11 +98,11 @@
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
- * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow
+ * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow. In [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>), the rule isn’t skipped: it prompts for sandboxed commands too, including read-only ones. Before v2.1.212, the skip applied in plan mode as well
**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
-Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed Bash commands will run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
+Auto-allow mode works independently of your permission mode setting, with one exception: [plan mode](</docs/en/permission-modes#analyze-before-you-edit-with-plan-mode>). Even if you’re not in “accept edits” mode, sandboxed Bash commands run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries execute without prompting, even when file edit tools would normally require approval.In plan mode, only [read-only commands](</docs/en/permissions#read-only-commands>) run without prompting; any other Bash command prompts for approval even with auto-allow enabled. Before v2.1.212, auto-allow ran sandboxed commands without a prompt in plan mode too.
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -18,7 +18,7 @@
/sandbox
-This opens the sandbox panel with three tabs:
+This opens the sandbox panel with three tabs, plus a Dependencies tab on Linux when the optional seccomp filter is missing:
* **Mode** : choose how sandboxed commands are approved, covered in the next step
* **Overrides** : choose whether commands that fail under the sandbox can fall back to running unsandboxed. This is the [`allowUnsandboxedCommands`](</docs/en/settings#sandbox-settings>) setting
@@ -63,11 +63,11 @@
sudo dnf install bubblewrap socat
-After installing, the Dependencies tab in `/sandbox` shows whether `ripgrep`, `bubblewrap`, `socat`, and the seccomp filter are available on your platform. Ripgrep is bundled with the native Claude Code binary. The seccomp filter is optional and adds Unix domain socket blocking. Install it with `npm install -g @anthropic-ai/sandbox-runtime` if it is missing. When a required dependency is missing, the Dependencies tab is the only tab shown until you install it. The dependency check runs at startup, so restart Claude Code after installing packages for `/sandbox` to detect them.
+When a dependency is missing, the Dependencies tab in `/sandbox` lists which of `ripgrep`, `bubblewrap`, `socat`, and the seccomp filter your platform lacks. If you don’t see the tab after installing and restarting Claude Code, all dependencies are present. Ripgrep is bundled with the native Claude Code binary. The seccomp filter is optional and adds Unix domain socket blocking. Install it with `npm install -g @anthropic-ai/sandbox-runtime` if it is missing. When a required dependency is missing, the Dependencies tab is the only tab shown until you install it. When only the optional seccomp filter is missing, the Dependencies tab appears alongside the other tabs. The dependency check runs at startup, so restart Claude Code after installing packages for `/sandbox` to detect them.
Ubuntu 24.04 and later: allow bubblewrap to create user namespaces
-On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation.To check whether your environment enforces this restriction, including inside WSL2, run `sysctl kernel.apparmor_restrict_unprivileged_userns`. If the key does not exist or returns `0`, skip this step. If it returns `1`, add an AppArmor profile that grants `bwrap` this capability:
+On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation.To check whether your environment enforces this restriction, including inside WSL2, run `sysctl kernel.apparmor_restrict_unprivileged_userns`. If the command returns `0`, skip this step. If it prints a `No such file or directory` error, the key doesn’t exist and you can skip this step. If it returns `1`, add an AppArmor profile that grants `bwrap` this capability:
sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
abi <abi/4.0>,
@@ -232,8 +232,8 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely.
- * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` from managed settings are honored.
+ * **Domain restrictions** : no domains are pre-allowed by default. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely. `WebFetch` allow rules also pre-allow domains, as described in Permission rules.
+ * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` and `WebFetch(domain:...)` allow rules from managed settings are honored.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
@@ -380,7 +380,7 @@
* **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings#sandbox-settings>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
- * **Seccomp filter on Linux** : the seccomp filter is required to block Unix domain sockets. The Dependencies tab in `/sandbox` shows whether it is available. If it is missing, run `npm install -g @anthropic-ai/sandbox-runtime` to install the helper.
+ * **Seccomp filter on Linux** : the seccomp filter is required to block Unix domain sockets. The Dependencies tab in `/sandbox` appears only when a dependency is missing; if you don’t see the tab after a restart, the filter is already installed. If the filter is missing, run `npm install -g @anthropic-ai/sandbox-runtime` to install the helper, then restart Claude Code so the startup dependency check detects it.
* **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
@@ -405,7 +405,7 @@
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
* **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
- * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command cannot modify its own policy.
+ * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command cannot modify its own policy. In v2.1.210 and later, the deny rules resolve symlinks: when a symlink appears at a protected settings file path after startup, the sandbox adds its target to the deny list for the next command, so a linked settings file can’t be edited through the link.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -129,7 +129,14 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
+This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. When read rules overlap, the more specific path wins:
+
+Example rules| Result
+---|---
+`"denyRead": ["~/"]` with `"allowRead": ["~/projects"]`| `~/projects` is readable and the rest of the home directory stays blocked. The narrower allow re-opens that part of the denied region
+`"allowRead": ["~/"]` with `"denyRead": ["~/.env"]`| `~/.env` stays blocked and the rest of the home directory is readable. An exact deny holds inside a wider allow, so a broad allow can’t silently re-expose a secret
+
+The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
{
"sandbox": {
@@ -292,7 +299,7 @@
---|---|---
`/sandbox`| What a Bash command can access once it runs| The sandbox boundary itself, in auto-allow mode
[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
-`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>) and removing `/` or your home directory still prompt
+`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>), connector tools [your organization set to `ask`](</docs/en/mcp#organization-controls-on-connector-tools>), MCP tools marked [`requiresUserInteraction`](</docs/en/mcp#require-approval-for-a-specific-tool>), and removing `/` or your home directory still prompt
The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -93,14 +93,14 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and prompts you for any command those rules do not already allow. Even in auto-allow mode, the following still apply:
+Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and gates any command those rules do not already allow, with a prompt in default mode or the classifier in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>). Even in auto-allow mode, the following still apply:
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt
* Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
* A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow
-**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow and requires your approval. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow: in default mode you get a confirmation prompt; in [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) the classifier evaluates the underlying command instead of prompting you. To be prompted on every unsandboxed retry even in auto mode, add an [ask rule](</docs/en/permissions#match-by-input-parameter>) for `Bash(dangerouslyDisableSandbox:true)`. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed Bash commands will run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -175,7 +175,7 @@
Mask environment variables
-`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. When a request leaves the sandbox for one of the credential’s `injectHosts`, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates HTTPS itself. Without it, masking fails closed: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup and in `/doctor`. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. When a request leaves the sandbox for one of the credential’s `injectHosts`, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates TLS itself. Without it, masking fails closed: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
{
"sandbox": {
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -149,7 +149,7 @@
Protect credentials
-The `sandbox.credentials` setting declares credential files and environment variables that sandboxed commands must not access. Listed file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and listed environment variables are unset before each sandboxed command runs. The dedicated `credentials` block keeps credential rules grouped with the environment variables to unset and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
+The `sandbox.credentials` setting declares credential files and environment variables to protect from sandboxed commands. Each entry names a file path or an environment variable and a `mode`. The dedicated `credentials` block keeps credential rules grouped together and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. For entries with `"mode": "deny"`, file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and environment variables are unset before each sandboxed command runs. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
{
"sandbox": {
@@ -167,7 +167,33 @@
}
}
-Each entry carries `"mode": "deny"`, which is the only supported value. The explicit `mode` field keeps the schema forward-compatible with future modes. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. Because the only mode is `deny`, any scope can add restrictions but none can remove them. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+File entries support only `"mode": "deny"`. Environment variable entries also accept `"mode": "mask"`, described below. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and `deny` entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. A `deny` entry only ever narrows access, so any scope can add one, but no scope can remove one that another scope added. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+
+####
+
+
+
+Mask environment variables
+
+`"mode": "mask"` protects a credential while keeping the tools that authenticate with it working. `deny` removes the variable entirely, which also breaks tools that need it, such as `gh` or `npm`. Requires Claude Code v2.1.199 or later. With `mask`, the sandboxed command sees a per-session sentinel value instead of the real one. When a request leaves the sandbox for one of the credential’s `injectHosts`, the sandbox proxy replaces the sentinel with the real value. The command and anything it logs never hold the real credential, but its requests still authenticate. The proxy substitutes the credential inside request contents, so it has to see them. Set [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) so the proxy terminates HTTPS itself. Without it, masking fails closed: the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication fails. Claude Code reports this misconfiguration at startup and in `/doctor`. The example below masks two tokens. `GH_TOKEN` is substituted only on requests to `api.github.com`, while `NPM_TOKEN` has no `injectHosts` and is substituted on requests to every host in `network.allowedDomains`. Each `injectHosts` entry must itself be covered by `network.allowedDomains`.
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "network": {
+ "tlsTerminate": {},
+ "allowedDomains": ["*.github.com", "registry.npmjs.org"]
+ },
+ "credentials": {
+ "envVars": [
+ { "name": "GH_TOKEN", "mode": "mask", "injectHosts": ["api.github.com"] },
+ { "name": "NPM_TOKEN", "mode": "mask" }
+ ]
+ }
+ }
+ }
+
+Unlike `deny`, masking authorizes the proxy to send your real credential to the listed hosts, so it is honored only from settings you or your administrator control: user settings, managed settings, and the `--settings` CLI flag. `mask` entries, `network.tlsTerminate`, and [`credentials.allowPlaintextInject`](</docs/en/settings#sandbox-settings>) in a repository’s `.claude/settings.json` or `.claude/settings.local.json` are ignored. When the same variable is listed with `deny` in any scope, `deny` takes precedence.
##
@@ -204,7 +230,7 @@
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
-The built-in proxy enforces the allowlist based on the requested hostname and does not terminate or inspect TLS traffic. See Security limitations for the implications of this design, and Custom proxy configuration if your threat model requires TLS inspection.
+The built-in proxy enforces the allowlist based on the requested hostname and, by default, does not terminate or inspect TLS traffic. The experimental [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) setting, available in Claude Code v2.1.199 and later, makes the built-in proxy terminate TLS itself, which `mask` credential entries require. See Security limitations for the implications of the default, and Custom proxy configuration if your threat model requires TLS inspection.
###
@@ -364,7 +390,7 @@
Security limitations
- * **Network filtering** : the network filtering system operates by restricting the domains that processes are allowed to connect to. The built-in proxy does not terminate or perform TLS inspection on outbound traffic, so the contents of encrypted connections are not examined. You are responsible for ensuring that only trusted domains are allowed in your policy.
+ * **Network filtering** : the sandbox restricts which domains processes can connect to. By default the built-in proxy does not terminate or inspect TLS on outbound traffic, so the contents of encrypted connections are not examined. The experimental [`network.tlsTerminate`](</docs/en/settings#sandbox-settings>) setting terminates TLS at the proxy for `mask` credential substitution but does not add content filtering. You are responsible for ensuring that only trusted domains are allowed in your policy.
Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
@@ -394,7 +420,7 @@
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
- * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses.
+ * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset or mask specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,9 +1,4 @@
-The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash command and its child processes. This page covers how to:
-
- * Enable the sandbox and choose how sandboxed commands are approved
- * Configure which paths and network domains commands can reach
- * Combine sandboxing with permission rules and permission modes
- * Enforce sandboxing across an organization with managed settings
+The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash command and its child processes.
To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>). To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -148,6 +148,32 @@
The `.` in `allowRead` resolves to the project root because this configuration lives in project settings. If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
+###
+
+
+
+Protect credentials
+
+The `sandbox.credentials` setting declares credential files and environment variables that sandboxed commands must not access. Listed file paths are denied for reads inside the sandbox, the same restriction that `filesystem.denyRead` applies, and listed environment variables are unset before each sandboxed command runs. The dedicated `credentials` block keeps credential rules grouped with the environment variables to unset and separate from general filesystem rules. Requires Claude Code v2.1.187 or later. The example below blocks reads of the AWS credentials file and the SSH directory and removes `GITHUB_TOKEN` and `NPM_TOKEN` from the environment of sandboxed commands:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "credentials": {
+ "files": [
+ { "path": "~/.aws/credentials", "mode": "deny" },
+ { "path": "~/.ssh", "mode": "deny" }
+ ],
+ "envVars": [
+ { "name": "GITHUB_TOKEN", "mode": "deny" },
+ { "name": "NPM_TOKEN", "mode": "deny" }
+ ]
+ }
+ }
+ }
+
+Each entry carries `"mode": "deny"`, which is the only supported value. The explicit `mode` field keeps the schema forward-compatible with future modes. File paths follow the same [prefix rules](</docs/en/settings#sandbox-path-prefixes>) as `sandbox.filesystem.*` settings, and entries from every [settings scope](</docs/en/settings#settings-precedence>) are merged. Because the only mode is `deny`, any scope can add restrictions but none can remove them. There is no built-in credential deny list, so only the files and variables you list are restricted. The setting affects sandboxed Bash commands only. To strip Anthropic and cloud provider credentials from all subprocesses regardless of sandboxing, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+
##
@@ -163,7 +189,7 @@
The sandboxed Bash tool restricts file system access to specific directories:
* **Default write behavior** : read and write access to the current working directory and its subdirectories, plus the session temp directory that `$TMPDIR` points to
- * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Add them to `denyRead` to block them.
+ * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Use `sandbox.credentials` to block reads of these files and unset secret environment variables, or add the paths to `denyRead`.
* **Blocked access** : cannot modify files outside the current working directory and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
@@ -178,7 +204,7 @@
Network access is controlled through a proxy server running outside the sandbox:
- * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt.
+ * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. As of v2.1.191, choosing Yes allows the host for the rest of the current session, so later connections to the same host do not prompt again. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt entirely.
* **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` from managed settings are honored.
* **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
@@ -278,7 +304,7 @@
* **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution
* **`allowUnsandboxedCommands: false`** : the `dangerouslyDisableSandbox` escape hatch is ignored, so commands that fail under the sandbox cannot be retried outside it
-Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `denyRead` entries for credential directories such as `~/.aws` and `~/.ssh`, which the default read policy still allows. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
+Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `sandbox.credentials` entries for credential directories such as `~/.aws` and `~/.ssh` and for secret environment variables, since the default read policy still allows them. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
###
@@ -373,7 +399,7 @@
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
- * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. To strip Anthropic and cloud provider credentials from subprocesses, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+ * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. Use `sandbox.credentials` to unset specific variables for sandboxed commands, or set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>) to strip Anthropic and cloud provider credentials from all subprocesses.
* **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -323,6 +323,7 @@
* **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
* **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
* **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings#sandbox-settings>) to `true` instead.
+ * **`open`, `osascript`, or browser-based auth flows fail with error `-600` on macOS**: the sandbox blocks Apple Events by default. Set [`allowAppleEvents`](</docs/en/settings#sandbox-settings>) to `true` in your user, managed, or CLI settings to allow them. Project settings are ignored for this key. Enabling it removes code-execution isolation, since sandboxed commands can then launch other applications unsandboxed with no user prompt and send AppleScript commands to running applications, subject to the macOS automation-consent prompt (TCC). Alternatively, add the command to `excludedCommands` to run it outside the sandbox.
* **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
* **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
* **Seccomp filter on Linux** : the seccomp filter is required to block Unix domain sockets. The Dependencies tab in `/sandbox` shows whether it is available. If it is missing, run `npm install -g @anthropic-ai/sandbox-runtime` to install the helper.
@@ -349,6 +350,7 @@
* **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
* **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
* **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
+ * **Apple Events on macOS** : the macOS sandbox blocks Apple Events by default. The `allowAppleEvents` setting lifts this restriction so tools such as `open` and `osascript` work, but it removes code-execution isolation: sandboxed commands can launch other applications unsandboxed with no user prompt, and can send AppleScript commands to running applications, subject to the per-app macOS automation-consent prompt (TCC). It is only honored from user, managed, or CLI settings. Project settings cannot enable it.
* **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command cannot modify its own policy.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -41,7 +41,7 @@
Run a Bash command
-Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory and the session temp directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
Selecting a mode in the panel writes to your project’s local settings at `.claude/settings.local.json`, which apply to the current project and are not checked into git. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
@@ -102,9 +102,10 @@
* Explicit [deny rules](</docs/en/permissions>) are always respected
* `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt
- * [Ask rules](</docs/en/permissions>) apply to commands that fall back to the regular permission flow
-
-**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow and requires your approval. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+ * Content-scoped [ask rules](</docs/en/permissions>) like `Bash(git push *)` still force a prompt even for sandboxed commands
+ * A bare `Bash` ask rule, or the equivalent `Bash(*)` form, is skipped for commands that run sandboxed; it still applies to commands that fall back to the regular permission flow
+
+**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. The session temp directory is writable inside the sandbox by default, alongside the working directory. Claude Code sets `$TMPDIR` to this directory for sandboxed commands, so tools that write temporary files work without extra configuration. Unsandboxed commands inherit your shell’s `$TMPDIR` unchanged, which means sandboxed and unsandboxed commands resolve `$TMPDIR` to different directories. To pass temporary files between the two, write them under the working directory instead. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow and requires your approval. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed Bash commands will run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
@@ -114,7 +115,7 @@
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can only write to the current working directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside the project directory, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can write only to the current working directory and the session temp directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside those directories, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -161,9 +162,9 @@
The sandboxed Bash tool restricts file system access to specific directories:
- * **Default write behavior** : read and write access to the current working directory and its subdirectories
+ * **Default write behavior** : read and write access to the current working directory and its subdirectories, plus the session temp directory that `$TMPDIR` points to
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Add them to `denyRead` to block them.
- * **Blocked access** : cannot modify files outside the current working directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
+ * **Blocked access** : cannot modify files outside the current working directory and session temp directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
* **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
@@ -244,7 +245,7 @@
---|---|---
`/sandbox`| What a Bash command can access once it runs| The sandbox boundary itself, in auto-allow mode
[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
-`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only removing `/` or your home directory still prompts
+`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only explicit [ask rules](</docs/en/permissions#manage-permissions>) and removing `/` or your home directory still prompt
The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,9 +1,3 @@
-> ## Documentation Index
->
-> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt>
->
-> Use this file to discover all available pages before exploring further.
-
The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash command and its child processes. This page covers how to:
* Enable the sandbox and choose how sandboxed commands are approved
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -170,6 +170,7 @@
* **Default write behavior** : read and write access to the current working directory and its subdirectories
* **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Add them to `denyRead` to block them.
* **Blocked access** : cannot modify files outside the current working directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
+ * **Git worktrees** : when the working directory is a [linked git worktree](</docs/en/worktrees>), the sandbox also allows writes to the main repository’s shared `.git` directory so commands such as `git commit` can update refs and the index. Writes to `hooks/` and `config` inside that directory remain denied.
* **Configurable** : define custom allowed and denied paths through settings
You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level, so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools.
Show diff (642 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -4,98 +4,67 @@
>
> Use this file to discover all available pages before exploring further.
-##
-
-
-
-Overview
-
-Claude Code features native sandboxing to provide a more secure environment for agent execution while reducing the need for constant permission prompts. Instead of asking permission for each bash command, sandboxing creates defined boundaries upfront where Claude Code can work more freely with reduced risk. The sandboxed bash tool uses OS-level primitives to enforce both filesystem and network isolation.
-
-##
-
-
-
-Why sandboxing matters
-
-Traditional permission-based security requires constant user approval for bash commands. While this provides control, it can lead to:
-
- * **Approval fatigue** : Repeatedly clicking “approve” can cause users to pay less attention to what they’re approving
- * **Reduced productivity** : Constant interruptions slow down development workflows
- * **Limited autonomy** : Claude Code cannot work as efficiently when waiting for approvals
-
-Sandboxing addresses these challenges by:
-
- 1. **Defining clear boundaries** : Specify exactly which directories and network hosts Claude Code can access
- 2. **Reducing permission prompts** : Safe commands within the sandbox don’t require approval
- 3. **Maintaining security** : Attempts to access resources outside the sandbox trigger immediate notifications
- 4. **Enabling autonomy** : Claude Code can run more independently within defined limits
-
-Effective sandboxing requires **both** filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When configuring sandboxing it is important to ensure that your configured settings do not create bypasses in these systems.
-
-##
-
-
-
-How it works
-
-###
-
-
-
-Filesystem isolation
-
-The sandboxed bash tool restricts file system access to specific directories:
-
- * **Default writes behavior** : Read and write access to the current working directory and its subdirectories
- * **Default read behavior** : Read access to the entire computer, except certain denied directories
- * **Blocked access** : Cannot modify files outside the current working directory without explicit permission
- * **Configurable** : Define custom allowed and denied paths through settings
-
-You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level (Seatbelt on macOS, bubblewrap on Linux), so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools.
-
-###
-
-
-
-Network isolation
-
-Network access is controlled through a proxy server running outside the sandbox:
-
- * **Domain restrictions** : Only approved domains can be accessed
- * **User confirmation** : New domain requests trigger permission prompts (unless [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is enabled, which blocks non-allowed domains automatically)
- * **Custom proxy support** : Advanced users can implement custom rules on outgoing traffic
- * **Comprehensive coverage** : Restrictions apply to all scripts, programs, and subprocesses spawned by commands
-
-The built-in proxy enforces the allowlist based on the requested hostname and does not terminate or inspect TLS traffic. See Security limitations for the implications of this design, and Custom proxy configuration if your threat model requires TLS inspection.
-
-###
-
-
-
-OS-level enforcement
-
-The sandboxed bash tool leverages operating system security primitives:
-
- * **macOS** : Uses Seatbelt for sandbox enforcement
- * **Linux** : Uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
- * **WSL2** : Uses bubblewrap, same as Linux
-
-WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These OS-level restrictions ensure that all child processes spawned by Claude Code’s commands inherit the same security boundaries.
-
-##
-
-
-
-Getting started
-
-###
-
-
-
-Prerequisites
-
-On **macOS** , sandboxing works out of the box using the built-in Seatbelt framework. On **Linux and WSL2** , install the required packages first:
+The Bash sandbox lets Claude run most shell commands without stopping to ask permission. Instead of approving each command, you define which files and network domains commands can touch, and the operating system enforces that boundary for every Bash command and its child processes. This page covers how to:
+
+ * Enable the sandbox and choose how sandboxed commands are approved
+ * Configure which paths and network domains commands can reach
+ * Combine sandboxing with permission rules and permission modes
+ * Enforce sandboxing across an organization with managed settings
+
+To compare other isolation approaches such as dev containers, custom containers, and virtual machines, see [Sandbox environments](</docs/en/sandbox-environments>). To reduce permission prompts for tools other than Bash, see [permission modes](</docs/en/permission-modes>).
+
+##
+
+
+
+Get started
+
+The sandbox is built into Claude Code and runs on macOS, Linux, and WSL2. Native Windows is not supported. On Windows, run Claude Code inside a WSL2 distribution. On macOS, there is nothing to install: sandboxing uses the built-in Seatbelt framework. On Linux and WSL2, the sandbox relies on two packages, covered in Set up Linux and WSL2. Even if you haven’t installed them yet, you can start with `/sandbox`, because its panel shows whether anything is missing.
+
+1
+
+Run /sandbox
+
+Start a Claude Code session and run the `/sandbox` command:
+
+ /sandbox
+
+This opens the sandbox panel with three tabs:
+
+ * **Mode** : choose how sandboxed commands are approved, covered in the next step
+ * **Overrides** : choose whether commands that fail under the sandbox can fall back to running unsandboxed. This is the [`allowUnsandboxedCommands`](</docs/en/settings#sandbox-settings>) setting
+ * **Config** : view the resolved sandbox settings
+
+If the panel shows only a Dependencies tab, a required package is missing. Install it as described in Set up Linux and WSL2, restart Claude Code, and run `/sandbox` again.
+
+2
+
+Choose a mode
+
+On the Mode tab, select auto-allow or regular permissions. Auto-allow runs sandboxed commands without prompting, and regular permissions keeps the regular permission prompts even when commands are sandboxed. See Sandbox modes for which commands still prompt in auto-allow mode.
+
+3
+
+Run a Bash command
+
+Ask Claude to run a command, such as a build or a test suite. By default, commands inside the sandbox can write only to the working directory. The first time a command needs a new network domain, Claude Code prompts for approval.Commands that cannot run sandboxed fall back to the regular permission flow. To widen or narrow these boundaries, see Configure sandboxing.
+
+Selecting a mode in the panel writes to your project’s local settings at `.claude/settings.local.json`, which apply to the current project and are not checked into git. To enable the sandbox across all of your projects, set [`sandbox.enabled`](</docs/en/settings#sandbox-settings>) to `true` in your user settings at `~/.claude/settings.json`. To enforce sandboxing for every developer in an organization, use managed settings.
+
+By default, if the sandbox cannot start because dependencies are missing or the platform is unsupported, Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+
+###
+
+
+
+Set up Linux and WSL2
+
+On Linux and WSL2, the sandbox relies on two packages:
+
+ * [`bubblewrap`](<https://github.com/containers/bubblewrap>): the unprivileged sandboxing tool that enforces filesystem isolation
+ * [`socat`](<http://www.dest-unreach.org/socat/>): the relay used to route network traffic through the sandbox proxy
+
+Install them with your distribution’s package manager:
* Ubuntu/Debian
@@ -105,7 +74,11 @@
sudo dnf install bubblewrap socat
-On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation. Add an AppArmor profile that grants `bwrap` this capability:
+After installing, the Dependencies tab in `/sandbox` shows whether `ripgrep`, `bubblewrap`, `socat`, and the seccomp filter are available on your platform. Ripgrep is bundled with the native Claude Code binary. The seccomp filter is optional and adds Unix domain socket blocking. Install it with `npm install -g @anthropic-ai/sandbox-runtime` if it is missing. When a required dependency is missing, the Dependencies tab is the only tab shown until you install it. The dependency check runs at startup, so restart Claude Code after installing packages for `/sandbox` to detect them.
+
+Ubuntu 24.04 and later: allow bubblewrap to create user namespaces
+
+On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation.To check whether your environment enforces this restriction, including inside WSL2, run `sysctl kernel.apparmor_restrict_unprivileged_userns`. If the key does not exist or returns `0`, skip this step. If it returns `1`, add an AppArmor profile that grants `bwrap` this capability:
sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
abi <abi/4.0>,
@@ -121,19 +94,9 @@
sudo systemctl reload apparmor
-WSL1 does not support sandboxing because it lacks the required Linux namespace primitives. If you see `Sandboxing requires WSL2`, upgrade your distribution to WSL2 or run Claude Code without sandboxing. On WSL2, sandboxed commands cannot launch Windows binaries such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/`. WSL hands these off to the Windows host over a Unix socket, which the sandbox blocks. If a command needs to invoke a Windows binary, add it to [`excludedCommands`](</docs/en/settings#sandbox-settings>) so it runs outside the sandbox.
-
-###
-
-
-
-Enable sandboxing
-
-You can enable sandboxing by running the `/sandbox` command:
-
- /sandbox
-
-This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies or unsupported platform), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+WSL2 notes
+
+Check your WSL version with `wsl -l -v` from PowerShell. If you see `Sandboxing requires WSL2`, your distribution is running WSL1. Upgrade it to WSL2 or run Claude Code without sandboxing.On WSL2, sandboxed commands cannot launch Windows binaries such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/`. WSL hands these off to the Windows host over a Unix socket, which the sandbox blocks. If a command needs to invoke a Windows binary, add it to [`excludedCommands`](</docs/en/settings#sandbox-settings>) so it runs outside the sandbox.
###
@@ -141,25 +104,23 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
-
-Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed bash commands will run automatically when auto-allow is enabled. This means bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
-
-###
+Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed, such as those needing network access to non-allowed hosts, fall back to the regular permission flow, where Claude Code checks your [permission rules](</docs/en/permissions>) and prompts you for any command those rules do not already allow. Even in auto-allow mode, the following still apply:
+
+ * Explicit [deny rules](</docs/en/permissions>) are always respected
+ * `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt
+ * [Ask rules](</docs/en/permissions>) apply to commands that fall back to the regular permission flow
+
+**Regular permissions mode** : All Bash commands go through the regular permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission. Some commands cannot run inside the sandbox at all, such as tools that are incompatible with it or that need a host you have not allowed. Rather than failing the task or requiring you to turn sandboxing off, Claude Code includes an escape hatch: when a command fails because of sandbox restrictions, Claude analyzes the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. The retried command runs outside the sandbox, so it goes through the regular permission flow and requires your approval. You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, which the `/sandbox` Overrides tab shows as **Strict sandbox mode** , the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+
+Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed Bash commands will run automatically when auto-allow is enabled. This means Bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
+
+##
Configure sandboxing
-Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for complete configuration reference.
-
-####
-
-
-
-Granting subprocess write access to specific paths
-
-By default, sandboxed commands can only write to the current working directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside the project directory, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for the complete configuration reference. By default, sandboxed commands can only write to the current working directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside the project directory, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
{
"sandbox": {
@@ -170,7 +131,7 @@
}
}
-These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When `allowWrite` (or `denyWrite`/`denyRead`/`allowRead`) is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are **merged** , meaning paths from every scope are combined, not replaced. For example, if managed settings allow writes to `/opt/company-tools` and a user adds `~/.kube` in their personal settings, both paths are included in the final sandbox configuration. This means users and projects can extend the list without duplicating or overriding paths set by higher-priority scopes. Path prefixes control how paths are resolved:
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When the same filesystem array is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are merged: paths from every scope are combined, not replaced. Path prefixes control how paths are resolved:
Prefix| Meaning| Example
---|---|---
@@ -178,7 +139,7 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-The older `//path` prefix for absolute paths still works. If you previously used single-slash `/path` expecting project-relative resolution, switch to `./path`. This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is an absolute path. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`. These are merged with any paths from `Edit(...)` and `Read(...)` permission rules. To re-allow reading specific paths within a denied region, use `sandbox.filesystem.allowRead`, which takes precedence over `denyRead`. When `allowManagedReadPathsOnly` is enabled in managed settings, only managed `allowRead` entries are respected; user, project, and local `allowRead` entries are ignored. `denyRead` still merges from all sources. For example, to block reading from the entire home directory while still allowing reads from the current project, add this to your project’s `.claude/settings.json`:
+This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is absolute. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`, and re-allow specific paths within a denied region using `sandbox.filesystem.allowRead`. The example below blocks reading from the entire home directory while still allowing reads from the current project. Place it in your project’s `.claude/settings.json`, because the relative path `.` resolves to the project root only when the configuration lives in project settings:
{
"sandbox": {
@@ -192,115 +153,144 @@
The `.` in `allowRead` resolves to the project root because this configuration lives in project settings. If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
-Not all commands are compatible with sandboxing out of the box. Some notes that may help you make the most out of the sandbox:
-
- * Many CLI tools require accessing certain hosts. As you use these tools, they will request permission to access certain hosts. Granting permission will allow them to access these hosts now and in the future, enabling them to safely execute inside the sandbox.
- * `watchman` is incompatible with running in the sandbox. If you’re running `jest`, consider using `jest --no-watchman`
- * `docker` is incompatible with running in the sandbox. Consider specifying `docker *` in `excludedCommands` to force it to run outside of the sandbox.
-
-Claude Code includes an intentional escape hatch mechanism that allows commands to run outside the sandbox when necessary. When a command fails due to sandbox restrictions (such as network connectivity issues or incompatible tools), Claude is prompted to analyze the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. Commands that use this parameter go through the normal Claude Code permissions flow requiring user permission to execute. This allows Claude Code to handle edge cases where certain tools or network operations cannot function within sandbox constraints.You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
-
-##
-
-
-
-Security benefits
-
-###
-
-
-
-Protection against prompt injection
-
-Even if an attacker successfully manipulates Claude Code’s behavior through prompt injection, the sandbox ensures your system remains secure: **Filesystem protection:**
-
- * Cannot modify critical config files such as `~/.bashrc`
- * Cannot modify system-level files in `/bin/`
- * Cannot read files that are denied in your [Claude permission settings](</docs/en/permissions#manage-permissions>)
-
-**Network protection:**
-
- * Cannot exfiltrate data to attacker-controlled servers
- * Cannot download malicious scripts from unauthorized domains
- * Cannot make unexpected API calls to unapproved services
- * Cannot contact any domains not explicitly allowed
-
-**Monitoring and control:**
-
- * All access attempts outside the sandbox are blocked at the OS level
- * You receive immediate notifications when boundaries are tested
- * You can choose to deny, allow once, or permanently update your configuration
-
-###
-
-
-
-Reduced attack surface
-
-Sandboxing limits the potential damage from:
-
- * **Malicious dependencies** : NPM packages or other dependencies with harmful code
- * **Compromised scripts** : Build scripts or tools with security vulnerabilities
- * **Social engineering** : Attacks that trick users into running dangerous commands
- * **Prompt injection** : Attacks that trick Claude into running dangerous commands
-
-###
-
-
-
-Transparent operation
-
-When Claude Code attempts to access network resources outside the sandbox:
-
- 1. The operation is blocked at the OS level
- 2. You receive an immediate notification
- 3. You can choose to:
- * Deny the request
- * Allow it once
- * Update your sandbox configuration to permanently allow it
-
-##
-
-
-
-Security Limitations
-
- * Network Sandboxing Limitations: The network filtering system operates by restricting the domains that processes are allowed to connect to. The built-in proxy does not terminate or perform TLS inspection on outbound traffic, so the contents of encrypted connections are not examined. You are responsible for ensuring that only trusted domains are allowed in your policy.
-
-Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
-
- * Privilege Escalation via Unix Sockets: The `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, if it is used to allow access to `/var/run/docker.sock` this would effectively grant access to the host system through exploiting the docker socket. Users are encouraged to carefully consider any unix sockets that they allow through the sandbox.
- * Filesystem Permission Escalation: Overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files (`.bashrc`, `.zshrc`) can lead to code execution in different security contexts when other users or system processes access these files.
- * Linux Sandbox Strength: The Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside of Docker environments without privileged namespaces. This option considerably weakens security and should only be used in cases where additional isolation is otherwise enforced.
-
-##
-
-
-
-How sandboxing relates to permissions
-
-Sandboxing and [permissions](</docs/en/permissions>) are complementary security layers that work together:
-
- * **Permissions** control which tools Claude Code can use and are evaluated before any tool runs. They apply to all tools: Bash, Read, Edit, WebFetch, MCP, and others.
+##
+
+
+
+How sandboxing works
+
+###
+
+
+
+Filesystem isolation
+
+The sandboxed Bash tool restricts file system access to specific directories:
+
+ * **Default write behavior** : read and write access to the current working directory and its subdirectories
+ * **Default read behavior** : read access to the entire computer, except certain denied directories. Note that this default still allows reading credential files such as `~/.aws/credentials` and `~/.ssh/`. Add them to `denyRead` to block them.
+ * **Blocked access** : cannot modify files outside the current working directory without explicit permission, including shell configuration files such as `~/.bashrc` and system binaries in `/bin/`
+ * **Configurable** : define custom allowed and denied paths through settings
+
+You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level, so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools.
+
+###
+
+
+
+Network isolation
+
+Network access is controlled through a proxy server running outside the sandbox:
+
+ * **Domain restrictions** : no domains are pre-allowed. The first time a command needs a new domain, Claude Code prompts for approval. Pre-allow domains with [`allowedDomains`](</docs/en/settings#sandbox-settings>) to avoid the prompt.
+ * **Managed lockdown** : if [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is set in managed settings, non-allowed domains are blocked automatically instead of prompting, and only `allowedDomains` from managed settings are honored.
+ * **Custom proxy support** : advanced users can implement custom rules on outgoing traffic
+ * **Comprehensive coverage** : restrictions apply to all scripts, programs, and subprocesses spawned by commands
+
+The built-in proxy enforces the allowlist based on the requested hostname and does not terminate or inspect TLS traffic. See Security limitations for the implications of this design, and Custom proxy configuration if your threat model requires TLS inspection.
+
+###
+
+
+
+OS-level enforcement
+
+The sandboxed Bash tool leverages operating system security primitives:
+
+ * **macOS** : uses Seatbelt for sandbox enforcement
+ * **Linux** : uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
+ * **WSL2** : uses bubblewrap, same as Linux
+
+WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These OS-level restrictions ensure that all child processes spawned by Claude Code’s commands inherit the same security boundaries. These same primitives are available as the standalone [`@anthropic-ai/sandbox-runtime`](<https://github.com/anthropic-experimental/sandbox-runtime>) package, which the [Sandbox environments](</docs/en/sandbox-environments#sandbox-runtime>) page covers as a separate approach for wrapping the entire Claude Code process.
+
+##
+
+
+
+How sandboxing relates to permissions and permission modes
+
+Sandboxing, [permission rules](</docs/en/permissions>), and [permission modes](</docs/en/permission-modes>) are complementary layers. The sections below cover how the sandbox interacts with each.
+
+###
+
+
+
+Permission rules
+
+Permission rules and sandboxing control different things:
+
+ * **Permission rules** control which tools Claude Code can use and are evaluated before any tool runs. They apply to all tools: Bash, Read, Edit, WebFetch, MCP, and others.
* **Sandboxing** provides OS-level enforcement that restricts what Bash commands can access at the filesystem and network level. It applies only to Bash commands and their child processes.
-Filesystem and network restrictions are configured through both sandbox settings and permission rules:
-
- * Use `sandbox.filesystem.allowWrite` to grant subprocess write access to paths outside the working directory
- * Use `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead` to block subprocess access to specific paths
- * Use `sandbox.filesystem.allowRead` to re-allow reading specific paths within a `denyRead` region
- * Use `Read` and `Edit` deny rules to block access to specific files or directories
- * Use `WebFetch` allow/deny rules to control domain access
- * Use sandbox `allowedDomains` to control which domains Bash commands can reach
- * Use sandbox `deniedDomains` to block specific domains even when a broader `allowedDomains` wildcard would otherwise permit them
-
-Paths from both `sandbox.filesystem` settings and permission rules are merged together into the final sandbox configuration. This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
-
-##
-
-
-
-Advanced usage
+The two layers also differ in how they are enforced. Claude Code evaluates permission decisions before a command runs, based on the command string and, in auto mode, a separate classifier’s judgment about whether the command is safe. The operating system enforces the sandbox boundary on the running process, so it holds regardless of what the model chose to run and even if an allowed command does more than its name suggests. Filesystem and network restrictions are configured through both sandbox settings and permission rules:
+
+Setting or rule| What it does
+---|---
+`sandbox.filesystem.allowWrite`| Grants subprocess write access to paths outside the working directory
+`sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`| Block subprocess access to specific paths
+`sandbox.filesystem.allowRead`| Re-allows reading specific paths within a `denyRead` region
+`Edit` allow rules| Grant write access to specific paths, the same way `sandbox.filesystem.allowWrite` does
+`Read` and `Edit` deny rules| Block access to specific files or directories
+`WebFetch` allow and deny rules| Control domain access
+Sandbox `allowedDomains`| Controls which domains Bash commands can reach
+Sandbox `deniedDomains`| Blocks specific domains even when a broader `allowedDomains` wildcard would otherwise permit them
+
+Paths from both `sandbox.filesystem` settings and permission rules are merged together into the final sandbox configuration. The [claude-code repository’s examples directory](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
+
+###
+
+
+
+Permission modes
+
+`/sandbox` is not a [permission mode](</docs/en/permission-modes>). Permission modes decide whether a tool call runs and whether you are prompted first, while the sandbox restricts what a Bash command can access once it runs. They differ in what they control and what replaces the per-action prompt:
+
+| What it controls| What replaces the prompt
+---|---|---
+`/sandbox`| What a Bash command can access once it runs| The sandbox boundary itself, in auto-allow mode
+[Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>)| Whether each tool call runs| A classifier that reviews actions
+`--dangerously-skip-permissions`| Whether each tool call runs| Nothing. [Protected path](</docs/en/permission-modes#protected-paths>) checks are also skipped; only removing `/` or your home directory still prompts
+
+The sandbox’s auto-allow mode is separate from [auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>): auto-allow approves Bash commands because the sandbox boundary contains them, while auto mode uses a classifier to review actions. The two work independently and can be combined. To choose an isolation boundary for unattended runs, see [Sandbox environments](</docs/en/sandbox-environments#how-isolation-relates-to-permission-modes>).
+
+##
+
+
+
+Configure the sandbox for your organization
+
+Administrators can require sandboxing for every user, keep developers from widening the policy, and route sandbox traffic through a corporate proxy.
+
+###
+
+
+
+Enforce sandboxing with managed settings
+
+To require the sandbox for every developer, deliver the `sandbox` keys through [managed settings](</docs/en/settings#settings-files>), either as a file managed by your MDM or through [server-managed settings](</docs/en/server-managed-settings>) on Claude.ai. The following managed settings configuration enables the sandbox, refuses to start Claude Code if the sandbox cannot initialize, and prevents the model from retrying commands outside the sandbox:
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "failIfUnavailable": true,
+ "allowUnsandboxedCommands": false
+ }
+ }
+
+The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
+
+ * **`failIfUnavailable`** : a missing dependency such as bubblewrap on Linux blocks Claude Code from starting rather than showing a warning and falling back to unsandboxed execution
+ * **`allowUnsandboxedCommands: false`** : the `dangerouslyDisableSandbox` escape hatch is ignored, so commands that fail under the sandbox cannot be retried outside it
+
+Two additions are worth considering alongside them. Add `excludedCommands` for any organization-approved tools that must run without isolation. Add `denyRead` entries for credential directories such as `~/.aws` and `~/.ssh`, which the default read policy still allows. The sandbox does not run on native Windows, so if your fleet includes Windows hosts, scope this configuration to macOS and Linux or have those users run Claude Code inside WSL2 or a container.
+
+###
+
+
+
+Keep developers from widening the policy
+
+For boolean keys such as `enabled` and `failIfUnavailable`, Claude Code uses the managed value and ignores anything a developer sets locally. For array keys such as `excludedCommands` and `allowRead`, Claude Code merges entries from every scope, so a developer can append entries that widen the policy. Set `allowManagedReadPathsOnly` to `true` in managed settings so that only `allowRead` entries from managed settings are honored. User, project, and local `allowRead` entries are ignored. This prevents developers from widening read access beyond the organization-approved paths. To lock network domains to the managed values the same way, set [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>). `excludedCommands` has no equivalent managed-only lockdown, so a developer can always append entries that run additional commands outside the sandbox. Keep the managed list narrow.
###
@@ -314,6 +304,8 @@
* Apply custom filtering rules
* Log all network requests
* Integrate with existing security infrastructure
+
+To point Claude Code at your proxy, set the proxy ports in [sandbox settings](</docs/en/settings#sandbox-settings>):
{
"sandbox": {
@@ -324,41 +316,21 @@
}
}
-###
-
-
-
-Integration with existing security tools
-
-The sandboxed bash tool works alongside:
-
- * **Permission rules** : Combine with [permission settings](</docs/en/permissions>) for defense-in-depth
- * **Development containers** : Use with [dev containers](</docs/en/devcontainer>) for additional isolation
- * **Enterprise policies** : Enforce sandbox configurations through [managed settings](</docs/en/settings#settings-precedence>)
-
-##
-
-
-
-Best practices
-
- 1. **Start restrictive** : Begin with minimal permissions and expand as needed
- 2. **Monitor logs** : Review sandbox violation attempts to understand Claude Code’s needs
- 3. **Use environment-specific configs** : Different sandbox rules for development vs. production contexts
- 4. **Combine with permissions** : Use sandboxing alongside IAM policies for comprehensive security
- 5. **Test configurations** : Verify your sandbox settings don’t block legitimate workflows
-
-##
-
-
-
-Open source
-
-The sandbox runtime is available as an open source npm package for use in your own agent projects. This enables the broader AI agent community to build safer, more secure autonomous systems. This can also be used to sandbox other programs you may wish to run. For example, to sandbox an MCP server you could run:
-
- npx @anthropic-ai/sandbox-runtime <command-to-sandbox>
-
-For implementation details and source code, visit the [GitHub repository](<https://github.com/anthropic-experimental/sandbox-runtime>).
+##
+
+
+
+Troubleshooting
+
+Some commands fail inside the sandbox even though they work outside it. The fixes below cover the most common cases.
+
+ * **Commands fail with a host-not-allowed error** : many CLI tools need to reach specific hosts. Granting permission when prompted adds the host to your allowed list so the tool runs inside the sandbox in future.
+ * **`jest` hangs or fails**: `watchman` is incompatible with the sandbox. Run `jest --no-watchman` instead.
+ * **Go-based CLIs fail TLS verification on macOS** : tools such as `gh`, `gcloud`, and `terraform` may fail TLS verification under Seatbelt. List these tools in `excludedCommands` to run them outside the sandbox. If you are using `httpProxyPort` with a MITM proxy and custom CA, set [`enableWeakerNetworkIsolation`](</docs/en/settings#sandbox-settings>) to `true` instead.
+ * **`docker` commands fail**: `docker` is incompatible with the sandbox. Add `docker *` to `excludedCommands` to run it outside the sandbox.
+ * **Bubblewrap fails to start inside a container** : in an unprivileged container, bubblewrap cannot mount a fresh `/proc` filesystem. Set [`enableWeakerNestedSandbox`](</docs/en/settings#sandbox-settings>) to `true` so the inner sandbox bind-mounts the container’s existing `/proc` instead. Only use this setting when the outer container already provides the isolation boundary you need, since it exposes process information to sandboxed commands that a fresh `/proc` mount would hide.
+ * **Seccomp filter on Linux** : the seccomp filter is required to block Unix domain sockets. The Dependencies tab in `/sandbox` shows whether it is available. If it is missing, run `npm install -g @anthropic-ai/sandbox-runtime` to install the helper.
+ * **`--dangerously-skip-permissions` fails as root**: this flag is blocked when running as root or via sudo on Linux and macOS, because root access combined with no permission prompts can modify any file or service on the system. The check is skipped automatically inside a recognized sandbox. To run autonomously in a container, use the [dev container](</docs/en/devcontainer>) configuration, which runs Claude Code as a non-root user.
##
@@ -366,20 +338,47 @@
Limitations
- * **Performance overhead** : Minimal, but some filesystem operations may be slightly slower
- * **Compatibility** : Some tools that require specific system access patterns may need configuration adjustments, or may even need to be run outside of the sandbox
- * **Platform support** : Supports macOS, Linux, and WSL2. WSL1 is not supported. Native Windows support is planned.
-
-##
-
-
-
-What sandboxing does not cover
+Sandboxing reduces risk but is not a complete isolation boundary. Review the limitations below before relying on it as a hard security control.
+
+###
+
+
+
+Security limitations
+
+ * **Network filtering** : the network filtering system operates by restricting the domains that processes are allowed to connect to. The built-in proxy does not terminate or perform TLS inspection on outbound traffic, so the contents of encrypted connections are not examined. You are responsible for ensuring that only trusted domains are allowed in your policy.
+
+Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
+
+ * **Privilege escalation via Unix sockets** : the `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, allowing access to `/var/run/docker.sock` effectively grants access to the host system through the Docker socket. Consider carefully any Unix sockets that you allow through the sandbox.
+ * **Filesystem permission escalation** : overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files such as `.bashrc` or `.zshrc` can lead to code execution in different security contexts when other users or system processes access these files.
+ * **Linux sandbox strength** : the Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside Docker environments without privileged namespaces, or on Linux hosts where unprivileged user namespaces are disabled by sysctl. This option considerably weakens security and should only be used when additional isolation is otherwise enforced.
+ * **Settings files protected** : the sandbox automatically denies write access to Claude Code’s `settings.json` files at every scope and to the managed settings directory, so a sandboxed command cannot modify its own policy.
+
+###
+
+
+
+Platform and tool compatibility
+
+ * **Platform support** : supports macOS, Linux, and WSL2. WSL1 and native Windows are not supported.
+ * **Performance overhead** : minimal, but some filesystem operations may be slightly slower.
+ * **Tool compatibility** : some tools that require specific system access patterns may need configuration adjustments, or may need to be run outside the sandbox.
+
+###
+
+
+
+Scope
The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
* **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
+ * **Environment variables** : sandboxed Bash commands inherit the parent process environment by default, including any credentials set there. To strip Anthropic and cloud provider credentials from subprocesses, set [`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`](</docs/en/env-vars>).
+ * **Subagents** : [subagents](</docs/en/sub-agents>) run in the same process as the parent session and use the same sandbox configuration. Bash commands inside a subagent are sandboxed when sandboxing is enabled in the parent session.
+
+Effective sandboxing requires both filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When you widen the defaults, check that an `allowWrite` path, a broad `allowedDomains` entry, or an `excludedCommands` exception does not undo a restriction on the other side.
##
@@ -387,7 +386,8 @@
See also
- * [Security](</docs/en/security>) \- Comprehensive security features and best practices
- * [Permissions](</docs/en/permissions>) \- Permission configuration and access control
- * [Settings](</docs/en/settings>) \- Complete configuration reference
- * [CLI reference](</docs/en/cli-reference>) \- Command-line options
+ * [Sandbox environments](</docs/en/sandbox-environments>): compare the built-in sandbox with dev containers, containers, and VMs
+ * [Security](</docs/en/security>): comprehensive security features and best practices
+ * [Permissions](</docs/en/permissions>): permission configuration and access control
+ * [Settings](</docs/en/settings>): complete configuration reference
+ * [CLI reference](</docs/en/cli-reference>): command-line options
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -104,6 +104,22 @@
sudo apt-get install bubblewrap socat
sudo dnf install bubblewrap socat
+
+On Ubuntu 24.04 and later, the default AppArmor policy prevents bubblewrap from creating the user namespaces it needs for isolation. Add an AppArmor profile that grants `bwrap` this capability:
+
+ sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
+ abi <abi/4.0>,
+ include <tunables/global>
+
+ profile bwrap /usr/bin/bwrap flags=(unconfined) {
+ userns,
+ include if exists <local/bwrap>
+ }
+ EOF
+
+The profile applies only to `bwrap` itself, not to the commands it runs inside the sandbox. Reload AppArmor to apply it:
+
+ sudo systemctl reload apparmor
WSL1 does not support sandboxing because it lacks the required Linux namespace primitives. If you see `Sandboxing requires WSL2`, upgrade your distribution to WSL2 or run Claude Code without sandboxing. On WSL2, sandboxed commands cannot launch Windows binaries such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/`. WSL hands these off to the Windows host over a Unix socket, which the sandbox blocks. If a command needs to invoke a Windows binary, add it to [`excludedCommands`](</docs/en/settings#sandbox-settings>) so it runs outside the sandbox.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -1,3 +1,9 @@
+> ## Documentation Index
+>
+> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt>
+>
+> Use this file to discover all available pages before exploring further.
+
##
@@ -61,6 +67,8 @@
* **Custom proxy support** : Advanced users can implement custom rules on outgoing traffic
* **Comprehensive coverage** : Restrictions apply to all scripts, programs, and subprocesses spawned by commands
+The built-in proxy enforces the allowlist based on the requested hostname and does not terminate or inspect TLS traffic. See Security limitations for the implications of this design, and Custom proxy configuration if your threat model requires TLS inspection.
+
###
@@ -96,6 +104,8 @@
sudo apt-get install bubblewrap socat
sudo dnf install bubblewrap socat
+
+WSL1 does not support sandboxing because it lacks the required Linux namespace primitives. If you see `Sandboxing requires WSL2`, upgrade your distribution to WSL2 or run Claude Code without sandboxing. On WSL2, sandboxed commands cannot launch Windows binaries such as `cmd.exe`, `powershell.exe`, or anything under `/mnt/c/`. WSL hands these off to the Windows host over a Unix socket, which the sandbox blocks. If a command needs to invoke a Windows binary, add it to [`excludedCommands`](</docs/en/settings#sandbox-settings>) so it runs outside the sandbox.
###
@@ -239,9 +249,9 @@
Security Limitations
- * Network Sandboxing Limitations: The network filtering system operates by restricting the domains that processes are allowed to connect to. It does not otherwise inspect the traffic passing through the proxy and users are responsible for ensuring they only allow trusted domains in their policy.
-
-Users should be aware of potential risks that come from allowing broad domains like `github.com` that may allow for data exfiltration. Also, in some cases it may be possible to bypass the network filtering through [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>).
+ * Network Sandboxing Limitations: The network filtering system operates by restricting the domains that processes are allowed to connect to. The built-in proxy does not terminate or perform TLS inspection on outbound traffic, so the contents of encrypted connections are not examined. You are responsible for ensuring that only trusted domains are allowed in your policy.
+
+Allowing broad domains such as `github.com` can create paths for data exfiltration. Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLS, code running inside the sandbox can potentially use [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>) or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandbox. Stronger TLS-aware network isolation is an active area of development.
* Privilege Escalation via Unix Sockets: The `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, if it is used to allow access to `/var/run/docker.sock` this would effectively grant access to the host system through exploiting the docker socket. Users are encouraged to carefully consider any unix sockets that they allow through the sandbox.
* Filesystem Permission Escalation: Overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files (`.bashrc`, `.zshrc`) can lead to code execution in different security contexts when other users or system processes access these files.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -307,7 +307,7 @@
The sandboxed bash tool works alongside:
* **Permission rules** : Combine with [permission settings](</docs/en/permissions>) for defense-in-depth
- * **Development containers** : Use with [devcontainers](</docs/en/devcontainer>) for additional isolation
+ * **Development containers** : Use with [dev containers](</docs/en/devcontainer>) for additional isolation
* **Enterprise policies** : Enforce sandbox configurations through [managed settings](</docs/en/settings#settings-precedence>)
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -107,7 +107,7 @@
/sandbox
-This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies, unsupported platform, or platform restrictions), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
+This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies or unsupported platform), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
###
@@ -115,7 +115,7 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
+Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected, and `rm` or `rmdir` commands that target `/`, your home directory, or other critical system paths still trigger a permission prompt. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed bash commands will run automatically when auto-allow is enabled. This means bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -266,6 +266,7 @@
* Use `Read` and `Edit` deny rules to block access to specific files or directories
* Use `WebFetch` allow/deny rules to control domain access
* Use sandbox `allowedDomains` to control which domains Bash commands can reach
+ * Use sandbox `deniedDomains` to block specific domains even when a broader `allowedDomains` wildcard would otherwise permit them
Paths from both `sandbox.filesystem` settings and permission rules are merged together into the final sandbox configuration. This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -115,7 +115,7 @@
Sandbox modes
-Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit ask/deny rules you’ve configured are always respected. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
+Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit deny rules are always respected. Ask rules apply only to commands that fall back to the regular permission flow. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed bash commands will run automatically when auto-allow is enabled. This means bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
@@ -170,7 +170,7 @@
* Many CLI tools require accessing certain hosts. As you use these tools, they will request permission to access certain hosts. Granting permission will allow them to access these hosts now and in the future, enabling them to safely execute inside the sandbox.
* `watchman` is incompatible with running in the sandbox. If you’re running `jest`, consider using `jest --no-watchman`
- * `docker` is incompatible with running in the sandbox. Consider specifying `docker` in `excludedCommands` to force it to run outside of the sandbox.
+ * `docker` is incompatible with running in the sandbox. Consider specifying `docker *` in `excludedCommands` to force it to run outside of the sandbox.
Claude Code includes an intentional escape hatch mechanism that allows commands to run outside the sandbox when necessary. When a command fails due to sandbox restrictions (such as network connectivity issues or incompatible tools), Claude is prompted to analyze the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. Commands that use this parameter go through the normal Claude Code permissions flow requiring user permission to execute. This allows Claude Code to handle edge cases where certain tools or network operations cannot function within sandbox constraints.You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
@@ -352,7 +352,7 @@
The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
- * **Computer use** : when Claude opens apps and controls your screen on macOS, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
+ * **Computer use** : when Claude opens apps and controls your screen, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -152,7 +152,7 @@
`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
-The older `//path` prefix for absolute paths still works. If you previously used single-slash `/path` expecting project-relative resolution, switch to `./path`. This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is an absolute path. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`. These are merged with any paths from `Edit(...)` and `Read(...)` permission rules. To re-allow reading specific paths within a denied region, use `sandbox.filesystem.allowRead`, which takes precedence over `denyRead`. When `allowManagedReadPathsOnly` is enabled in managed settings, only managed `allowRead` entries are respected; user, project, and local `allowRead` entries are ignored. For example, to block reading from the entire home directory while still allowing reads from the current project, add this to your project’s `.claude/settings.json`:
+The older `//path` prefix for absolute paths still works. If you previously used single-slash `/path` expecting project-relative resolution, switch to `./path`. This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is an absolute path. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`. These are merged with any paths from `Edit(...)` and `Read(...)` permission rules. To re-allow reading specific paths within a denied region, use `sandbox.filesystem.allowRead`, which takes precedence over `denyRead`. When `allowManagedReadPathsOnly` is enabled in managed settings, only managed `allowRead` entries are respected; user, project, and local `allowRead` entries are ignored. `denyRead` still merges from all sources. For example, to block reading from the entire home directory while still allowing reads from the current project, add this to your project’s `.claude/settings.json`:
{
"sandbox": {
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -352,7 +352,7 @@
The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
* **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
- * **Computer use on Desktop** : when Claude opens apps and controls your screen on macOS, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use](</docs/en/desktop#let-claude-use-your-computer>).
+ * **Computer use** : when Claude opens apps and controls your screen on macOS, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use in the CLI](</docs/en/computer-use>) or [computer use in Desktop](</docs/en/desktop#let-claude-use-your-computer>).
##
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -93,20 +93,8 @@
* Fedora
-Report incorrect code
-
-Copy
-
-Ask AI
-
sudo apt-get install bubblewrap socat
-Report incorrect code
-
-Copy
-
-Ask AI
-
sudo dnf install bubblewrap socat
###
@@ -117,12 +105,6 @@
You can enable sandboxing by running the `/sandbox` command:
-Report incorrect code
-
-Copy
-
-Ask AI
-
/sandbox
This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies, unsupported platform, or platform restrictions), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
@@ -152,12 +134,6 @@
Granting subprocess write access to specific paths
By default, sandboxed commands can only write to the current working directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside the project directory, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"sandbox": {
@@ -177,12 +153,6 @@
`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
The older `//path` prefix for absolute paths still works. If you previously used single-slash `/path` expecting project-relative resolution, switch to `./path`. This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is an absolute path. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`. These are merged with any paths from `Edit(...)` and `Read(...)` permission rules. To re-allow reading specific paths within a denied region, use `sandbox.filesystem.allowRead`, which takes precedence over `denyRead`. When `allowManagedReadPathsOnly` is enabled in managed settings, only managed `allowRead` entries are respected; user, project, and local `allowRead` entries are ignored. For example, to block reading from the entire home directory while still allowing reads from the current project, add this to your project’s `.claude/settings.json`:
-
-Report incorrect code
-
-Copy
-
-Ask AI
{
"sandbox": {
@@ -318,12 +288,6 @@
* Log all network requests
* Integrate with existing security infrastructure
-Report incorrect code
-
-Copy
-
-Ask AI
-
{
"sandbox": {
"network": {
@@ -365,12 +329,6 @@
The sandbox runtime is available as an open source npm package for use in your own agent projects. This enables the broader AI agent community to build safer, more secure autonomous systems. This can also be used to sandbox other programs you may wish to run. For example, to sandbox an MCP server you could run:
-Report incorrect code
-
-Copy
-
-Ask AI
-
npx @anthropic-ai/sandbox-runtime <command-to-sandbox>
For implementation details and source code, visit the [GitHub repository](<https://github.com/anthropic-experimental/sandbox-runtime>).
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -125,7 +125,7 @@
/sandbox
-This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform.
+This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform. By default, if the sandbox cannot start (missing dependencies, unsupported platform, or platform restrictions), Claude Code shows a warning and runs commands without sandboxing. To make this a hard failure instead, set [`sandbox.failIfUnavailable`](</docs/en/settings#sandbox-settings>) to `true`. This is intended for managed deployments that require sandboxing as a security gate.
###
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -389,6 +389,17 @@
+What sandboxing does not cover
+
+The sandbox isolates Bash subprocesses. Other tools operate under different boundaries:
+
+ * **Built-in file tools** : Read, Edit, and Write use the permission system directly rather than running through the sandbox. See [permissions](</docs/en/permissions>).
+ * **Computer use on Desktop** : when Claude opens apps and controls your screen on macOS, it runs on your actual desktop rather than in an isolated environment. Per-app permission prompts gate each application. See [computer use](</docs/en/desktop#let-claude-use-your-computer>).
+
+##
+
+
+
See also
* [Security](</docs/en/security>) \- Comprehensive security features and best practices
Show diff (400 lines)
--- a/sandboxing.md
+++ b/sandboxing.md
@@ -0,0 +1,397 @@
+##
+
+
+
+Overview
+
+Claude Code features native sandboxing to provide a more secure environment for agent execution while reducing the need for constant permission prompts. Instead of asking permission for each bash command, sandboxing creates defined boundaries upfront where Claude Code can work more freely with reduced risk. The sandboxed bash tool uses OS-level primitives to enforce both filesystem and network isolation.
+
+##
+
+
+
+Why sandboxing matters
+
+Traditional permission-based security requires constant user approval for bash commands. While this provides control, it can lead to:
+
+ * **Approval fatigue** : Repeatedly clicking “approve” can cause users to pay less attention to what they’re approving
+ * **Reduced productivity** : Constant interruptions slow down development workflows
+ * **Limited autonomy** : Claude Code cannot work as efficiently when waiting for approvals
+
+Sandboxing addresses these challenges by:
+
+ 1. **Defining clear boundaries** : Specify exactly which directories and network hosts Claude Code can access
+ 2. **Reducing permission prompts** : Safe commands within the sandbox don’t require approval
+ 3. **Maintaining security** : Attempts to access resources outside the sandbox trigger immediate notifications
+ 4. **Enabling autonomy** : Claude Code can run more independently within defined limits
+
+Effective sandboxing requires **both** filesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys. Without filesystem isolation, a compromised agent could backdoor system resources to gain network access. When configuring sandboxing it is important to ensure that your configured settings do not create bypasses in these systems.
+
+##
+
+
+
+How it works
+
+###
+
+
+
+Filesystem isolation
+
+The sandboxed bash tool restricts file system access to specific directories:
+
+ * **Default writes behavior** : Read and write access to the current working directory and its subdirectories
+ * **Default read behavior** : Read access to the entire computer, except certain denied directories
+ * **Blocked access** : Cannot modify files outside the current working directory without explicit permission
+ * **Configurable** : Define custom allowed and denied paths through settings
+
+You can grant write access to additional paths using `sandbox.filesystem.allowWrite` in your settings. These restrictions are enforced at the OS level (Seatbelt on macOS, bubblewrap on Linux), so they apply to all subprocess commands, including tools like `kubectl`, `terraform`, and `npm`, not just Claude’s file tools.
+
+###
+
+
+
+Network isolation
+
+Network access is controlled through a proxy server running outside the sandbox:
+
+ * **Domain restrictions** : Only approved domains can be accessed
+ * **User confirmation** : New domain requests trigger permission prompts (unless [`allowManagedDomainsOnly`](</docs/en/settings#sandbox-settings>) is enabled, which blocks non-allowed domains automatically)
+ * **Custom proxy support** : Advanced users can implement custom rules on outgoing traffic
+ * **Comprehensive coverage** : Restrictions apply to all scripts, programs, and subprocesses spawned by commands
+
+###
+
+
+
+OS-level enforcement
+
+The sandboxed bash tool leverages operating system security primitives:
+
+ * **macOS** : Uses Seatbelt for sandbox enforcement
+ * **Linux** : Uses [bubblewrap](<https://github.com/containers/bubblewrap>) for isolation
+ * **WSL2** : Uses bubblewrap, same as Linux
+
+WSL1 is not supported because bubblewrap requires kernel features only available in WSL2. These OS-level restrictions ensure that all child processes spawned by Claude Code’s commands inherit the same security boundaries.
+
+##
+
+
+
+Getting started
+
+###
+
+
+
+Prerequisites
+
+On **macOS** , sandboxing works out of the box using the built-in Seatbelt framework. On **Linux and WSL2** , install the required packages first:
+
+ * Ubuntu/Debian
+
+ * Fedora
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ sudo apt-get install bubblewrap socat
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ sudo dnf install bubblewrap socat
+
+###
+
+
+
+Enable sandboxing
+
+You can enable sandboxing by running the `/sandbox` command:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ /sandbox
+
+This opens a menu where you can choose between sandbox modes. If required dependencies are missing (such as `bubblewrap` or `socat` on Linux), the menu displays installation instructions for your platform.
+
+###
+
+
+
+Sandbox modes
+
+Claude Code offers two sandbox modes: **Auto-allow mode** : Bash commands will attempt to run inside the sandbox and are automatically allowed without requiring permission. Commands that cannot be sandboxed (such as those needing network access to non-allowed hosts) fall back to the regular permission flow. Explicit ask/deny rules you’ve configured are always respected. **Regular permissions mode** : All bash commands go through the standard permission flow, even when sandboxed. This provides more control but requires more approvals. In both modes, the sandbox enforces the same filesystem and network restrictions. The difference is only in whether sandboxed commands are auto-approved or require explicit permission.
+
+Auto-allow mode works independently of your permission mode setting. Even if you’re not in “accept edits” mode, sandboxed bash commands will run automatically when auto-allow is enabled. This means bash commands that modify files within the sandbox boundaries will execute without prompting, even when file edit tools would normally require approval.
+
+###
+
+
+
+Configure sandboxing
+
+Customize sandbox behavior through your `settings.json` file. See [Settings](</docs/en/settings#sandbox-settings>) for complete configuration reference.
+
+####
+
+
+
+Granting subprocess write access to specific paths
+
+By default, sandboxed commands can only write to the current working directory. If subprocess commands like `kubectl`, `terraform`, or `npm` need to write outside the project directory, use `sandbox.filesystem.allowWrite` to grant access to specific paths:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "filesystem": {
+ "allowWrite": ["~/.kube", "/tmp/build"]
+ }
+ }
+ }
+
+These paths are enforced at the OS level, so all commands running inside the sandbox, including their child processes, respect them. This is the recommended approach when a tool needs write access to a specific location, rather than excluding the tool from the sandbox entirely with `excludedCommands`. When `allowWrite` (or `denyWrite`/`denyRead`/`allowRead`) is defined in multiple [settings scopes](</docs/en/settings#settings-precedence>), the arrays are **merged** , meaning paths from every scope are combined, not replaced. For example, if managed settings allow writes to `/opt/company-tools` and a user adds `~/.kube` in their personal settings, both paths are included in the final sandbox configuration. This means users and projects can extend the list without duplicating or overriding paths set by higher-priority scopes. Path prefixes control how paths are resolved:
+
+Prefix| Meaning| Example
+---|---|---
+`/`| Absolute path from filesystem root| `/tmp/build` stays `/tmp/build`
+`~/`| Relative to home directory| `~/.kube` becomes `$HOME/.kube`
+`./` or no prefix| Relative to the project root for project settings, or to `~/.claude` for user settings| `./output` in `.claude/settings.json` resolves to `<project-root>/output`
+
+The older `//path` prefix for absolute paths still works. If you previously used single-slash `/path` expecting project-relative resolution, switch to `./path`. This syntax differs from [Read and Edit permission rules](</docs/en/permissions#read-and-edit>), which use `//path` for absolute and `/path` for project-relative. Sandbox filesystem paths use standard conventions: `/tmp/build` is an absolute path. You can also deny write or read access using `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead`. These are merged with any paths from `Edit(...)` and `Read(...)` permission rules. To re-allow reading specific paths within a denied region, use `sandbox.filesystem.allowRead`, which takes precedence over `denyRead`. When `allowManagedReadPathsOnly` is enabled in managed settings, only managed `allowRead` entries are respected; user, project, and local `allowRead` entries are ignored. For example, to block reading from the entire home directory while still allowing reads from the current project, add this to your project’s `.claude/settings.json`:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "sandbox": {
+ "enabled": true,
+ "filesystem": {
+ "denyRead": ["~/"],
+ "allowRead": ["."]
+ }
+ }
+ }
+
+The `.` in `allowRead` resolves to the project root because this configuration lives in project settings. If you placed the same configuration in `~/.claude/settings.json`, `.` would resolve to `~/.claude` instead, and project files would remain blocked by the `denyRead` rule.
+
+Not all commands are compatible with sandboxing out of the box. Some notes that may help you make the most out of the sandbox:
+
+ * Many CLI tools require accessing certain hosts. As you use these tools, they will request permission to access certain hosts. Granting permission will allow them to access these hosts now and in the future, enabling them to safely execute inside the sandbox.
+ * `watchman` is incompatible with running in the sandbox. If you’re running `jest`, consider using `jest --no-watchman`
+ * `docker` is incompatible with running in the sandbox. Consider specifying `docker` in `excludedCommands` to force it to run outside of the sandbox.
+
+Claude Code includes an intentional escape hatch mechanism that allows commands to run outside the sandbox when necessary. When a command fails due to sandbox restrictions (such as network connectivity issues or incompatible tools), Claude is prompted to analyze the failure and may retry the command with the `dangerouslyDisableSandbox` parameter. Commands that use this parameter go through the normal Claude Code permissions flow requiring user permission to execute. This allows Claude Code to handle edge cases where certain tools or network operations cannot function within sandbox constraints.You can disable this escape hatch by setting `"allowUnsandboxedCommands": false` in your [sandbox settings](</docs/en/settings#sandbox-settings>). When disabled, the `dangerouslyDisableSandbox` parameter is completely ignored and all commands must run sandboxed or be explicitly listed in `excludedCommands`.
+
+##
+
+
+
+Security benefits
+
+###
+
+
+
+Protection against prompt injection
+
+Even if an attacker successfully manipulates Claude Code’s behavior through prompt injection, the sandbox ensures your system remains secure: **Filesystem protection:**
+
+ * Cannot modify critical config files such as `~/.bashrc`
+ * Cannot modify system-level files in `/bin/`
+ * Cannot read files that are denied in your [Claude permission settings](</docs/en/permissions#manage-permissions>)
+
+**Network protection:**
+
+ * Cannot exfiltrate data to attacker-controlled servers
+ * Cannot download malicious scripts from unauthorized domains
+ * Cannot make unexpected API calls to unapproved services
+ * Cannot contact any domains not explicitly allowed
+
+**Monitoring and control:**
+
+ * All access attempts outside the sandbox are blocked at the OS level
+ * You receive immediate notifications when boundaries are tested
+ * You can choose to deny, allow once, or permanently update your configuration
+
+###
+
+
+
+Reduced attack surface
+
+Sandboxing limits the potential damage from:
+
+ * **Malicious dependencies** : NPM packages or other dependencies with harmful code
+ * **Compromised scripts** : Build scripts or tools with security vulnerabilities
+ * **Social engineering** : Attacks that trick users into running dangerous commands
+ * **Prompt injection** : Attacks that trick Claude into running dangerous commands
+
+###
+
+
+
+Transparent operation
+
+When Claude Code attempts to access network resources outside the sandbox:
+
+ 1. The operation is blocked at the OS level
+ 2. You receive an immediate notification
+ 3. You can choose to:
+ * Deny the request
+ * Allow it once
+ * Update your sandbox configuration to permanently allow it
+
+##
+
+
+
+Security Limitations
+
+ * Network Sandboxing Limitations: The network filtering system operates by restricting the domains that processes are allowed to connect to. It does not otherwise inspect the traffic passing through the proxy and users are responsible for ensuring they only allow trusted domains in their policy.
+
+Users should be aware of potential risks that come from allowing broad domains like `github.com` that may allow for data exfiltration. Also, in some cases it may be possible to bypass the network filtering through [domain fronting](<https://en.wikipedia.org/wiki/Domain_fronting>).
+
+ * Privilege Escalation via Unix Sockets: The `allowUnixSockets` configuration can inadvertently grant access to powerful system services that could lead to sandbox bypasses. For example, if it is used to allow access to `/var/run/docker.sock` this would effectively grant access to the host system through exploiting the docker socket. Users are encouraged to carefully consider any unix sockets that they allow through the sandbox.
+ * Filesystem Permission Escalation: Overly broad filesystem write permissions can enable privilege escalation attacks. Allowing writes to directories containing executables in `$PATH`, system configuration directories, or user shell configuration files (`.bashrc`, `.zshrc`) can lead to code execution in different security contexts when other users or system processes access these files.
+ * Linux Sandbox Strength: The Linux implementation provides strong filesystem and network isolation but includes an `enableWeakerNestedSandbox` mode that enables it to work inside of Docker environments without privileged namespaces. This option considerably weakens security and should only be used in cases where additional isolation is otherwise enforced.
+
+##
+
+
+
+How sandboxing relates to permissions
+
+Sandboxing and [permissions](</docs/en/permissions>) are complementary security layers that work together:
+
+ * **Permissions** control which tools Claude Code can use and are evaluated before any tool runs. They apply to all tools: Bash, Read, Edit, WebFetch, MCP, and others.
+ * **Sandboxing** provides OS-level enforcement that restricts what Bash commands can access at the filesystem and network level. It applies only to Bash commands and their child processes.
+
+Filesystem and network restrictions are configured through both sandbox settings and permission rules:
+
+ * Use `sandbox.filesystem.allowWrite` to grant subprocess write access to paths outside the working directory
+ * Use `sandbox.filesystem.denyWrite` and `sandbox.filesystem.denyRead` to block subprocess access to specific paths
+ * Use `sandbox.filesystem.allowRead` to re-allow reading specific paths within a `denyRead` region
+ * Use `Read` and `Edit` deny rules to block access to specific files or directories
+ * Use `WebFetch` allow/deny rules to control domain access
+ * Use sandbox `allowedDomains` to control which domains Bash commands can reach
+
+Paths from both `sandbox.filesystem` settings and permission rules are merged together into the final sandbox configuration. This [repository](<https://github.com/anthropics/claude-code/tree/main/examples/settings>) includes starter settings configurations for common deployment scenarios, including sandbox-specific examples. Use these as starting points and adjust them to fit your needs.
+
+##
+
+
+
+Advanced usage
+
+###
+
+
+
+Custom proxy configuration
+
+For organizations requiring advanced network security, you can implement a custom proxy to:
+
+ * Decrypt and inspect HTTPS traffic
+ * Apply custom filtering rules
+ * Log all network requests
+ * Integrate with existing security infrastructure
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ {
+ "sandbox": {
+ "network": {
+ "httpProxyPort": 8080,
+ "socksProxyPort": 8081
+ }
+ }
+ }
+
+###
+
+
+
+Integration with existing security tools
+
+The sandboxed bash tool works alongside:
+
+ * **Permission rules** : Combine with [permission settings](</docs/en/permissions>) for defense-in-depth
+ * **Development containers** : Use with [devcontainers](</docs/en/devcontainer>) for additional isolation
+ * **Enterprise policies** : Enforce sandbox configurations through [managed settings](</docs/en/settings#settings-precedence>)
+
+##
+
+
+
+Best practices
+
+ 1. **Start restrictive** : Begin with minimal permissions and expand as needed
+ 2. **Monitor logs** : Review sandbox violation attempts to understand Claude Code’s needs
+ 3. **Use environment-specific configs** : Different sandbox rules for development vs. production contexts
+ 4. **Combine with permissions** : Use sandboxing alongside IAM policies for comprehensive security
+ 5. **Test configurations** : Verify your sandbox settings don’t block legitimate workflows
+
+##
+
+
+
+Open source
+
+The sandbox runtime is available as an open source npm package for use in your own agent projects. This enables the broader AI agent community to build safer, more secure autonomous systems. This can also be used to sandbox other programs you may wish to run. For example, to sandbox an MCP server you could run:
+
+Report incorrect code
+
+Copy
+
+Ask AI
+
+ npx @anthropic-ai/sandbox-runtime <command-to-sandbox>
+
+For implementation details and source code, visit the [GitHub repository](<https://github.com/anthropic-experimental/sandbox-runtime>).
+
+##
+
+
+
+Limitations
+
+ * **Performance overhead** : Minimal, but some filesystem operations may be slightly slower
+ * **Compatibility** : Some tools that require specific system access patterns may need configuration adjustments, or may even need to be run outside of the sandbox
+ * **Platform support** : Supports macOS, Linux, and WSL2. WSL1 is not supported. Native Windows support is planned.
+
+##
+
+
+
+See also
+
+ * [Security](</docs/en/security>) \- Comprehensive security features and best practices
+ * [Permissions](</docs/en/permissions>) \- Permission configuration and access control
+ * [Settings](</docs/en/settings>) \- Complete configuration reference
+ * [CLI reference](</docs/en/cli-reference>) \- Command-line options