Configure the sandboxed Bash tool changedsandboxing
Nearest release: v2.1.330, published 3 hours after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 20 Nov 2026 16:04 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 20 Nov 2026 16:07 UTC.
Upstream edited
Recorded here
Lines+26added
Lines−12removed
From line
559
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits69to this page, all time
#### Usernames and passwords in proxy variables
The whole hunk
from line 559, old and new numbered
/
from line 559
559559>
560560> If you set [`allowNestedUserNamespaces`](https://code.claude.com/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.
561561
562To 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.
562To 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.
563563
564564If `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`](#a-git-command-fails-with-unable-to-unlink-old).
565565
from line 567
567567
568568After 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`](https://code.claude.com/docs/en/commands).
569569
570A 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](#a-folder-named-objects-or-refs-disappears-after-a-command).
570When 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](#a-folder-named-objects-or-refs-disappears-after-a-command).
571571
572572#### Denied paths that pass through a symlink
573573
from line 649
649649
650650To 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.
651651
652#### Usernames and passwords in proxy variables
653
654If a command's `HTTPS_PROXY` or other proxy URL contains a username and password, check the username and host:
655
656* **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
657* **Any other username or host**: treat it as one of your own credentials
658
652659### OS-level enforcement
653660
654661The sandboxed Bash tool uses operating system security primitives:
from line 731
724731
725732The two keys beyond `enabled` control what happens when the sandbox cannot run a command:
726733
727* **`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
734* **`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
728735* **`allowUnsandboxedCommands: false`**: Claude Code ignores the `dangerouslyDisableSandbox` escape hatch, so when a command fails under the sandbox, Claude can't retry it unsandboxed
729736
730737Consider these additions alongside them:
from line 913
906913
907914### A folder named `objects` or `refs` disappears after a command
908915
909A top-level `objects` or `refs` folder that appeared during the session can be [deleted after a sandboxed command ends](#when-the-sandbox-deletes-head-objects-or-refs). 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.
916A top-level `objects` or `refs` folder that appeared during the session can be [renamed or deleted after a sandboxed command ends](#when-the-sandbox-deletes-head-objects-or-refs). It doesn't matter whether a command, Claude, or you created it.
910917
911Before v2.1.307, the folder was deleted even with something in it and no `HEAD`. On an earlier version, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code).
918Close 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:
912919
920* **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`.
921* **You find no such entry**: the folder was deleted, so create it again.
922
923To 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.
924
925Before v2.1.315, a folder could be deleted with its contents. On an earlier version, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code).
926
913927### Bubblewrap fails to start inside a container
914928
915929In an unprivileged container, [bubblewrap](#os-level-enforcement) 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`](https://code.claude.com/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.
from line 954
940954
941955On 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.
942956
943A placeholder stays behind in cases such as these:
957A placeholder can stay behind in cases such as these:
944958
945959* The session is killed before that cleanup runs, for example by SIGKILL
946* The session exits while a sandboxed command is still running, such as a background command
960* The session exits while a sandboxed command is still running
947961
948962Later 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.
949963
from line 965
951965
952966### `git` over SSH fails with the sandbox on
953967
954On 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](#network-isolation), and the macOS tunnel can't authenticate to that proxy.
968On macOS, `git fetch`, `git pull`, and `git push` against an SSH remote can fail inside the sandbox even when the host is allowed.
955969
956On Linux and WSL2, check these if the connection still fails:
970On Linux and WSL2, they work once the host is allowed. If the connection still fails, check these:
957971
958972* **The host is allowed on port 22**: an `allowedDomains` entry with no port, such as `"git.example.com"`, covers it
959* **Your corporate proxy permits port 22**: if your network requires an upstream proxy, the tunnel goes through it too
973* **Your corporate proxy permits port 22**: if your network requires an upstream proxy, the connection goes through it too
960974* **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
961975
962976On macOS, switch the remote to HTTPS, which needs HTTPS credentials such as a personal access token:
No line in this hunk matches that.