Sandbox isolation for agents
What boundaries does a sandbox create?
Anthropic explains sandbox isolation in terms of two boundaries: the filesystem and the network. The filesystem boundary determines which directories an agent can access or modify. The network boundary restricts which servers it can connect to.
According to Anthropic, an effective sandbox requires both boundaries. Without network isolation, a compromised agent can exfiltrate sensitive files. Without filesystem isolation, it can escape the sandbox and gain network access.
Claude Code uses a sandbox enforced by the operating system for shell commands. This boundary applies to Bash, PowerShell, and Monitor commands and the processes they launch. The files and network domains that commands can access are determined by settings. Subprocesses launched by a command are also subject to the same boundaries.
Command access in Claude Code
According to Anthropic, the sandbox is disabled by default in Claude Code. Running /sandbox in a session opens the sandbox panel. The panel has Mode, Overrides, and Config tabs. Mode determines how commands inside the sandbox are approved. Overrides concerns whether commands that fail under the sandbox can be run again outside it. Config shows the resolved sandbox settings.
The sandbox can also be enabled by setting sandbox.enabled to true in a settings file. The mode selected in the panel is saved to the project's local settings. The sandbox.enabled value in user settings can enable the sandbox for all projects. Claude Code also offers managed settings to enforce the sandbox across an organization.
The same filesystem and network restrictions apply in both Claude Code sandbox modes. The modes differ in how commands inside the sandbox are approved. In Auto-allow mode, commands inside the sandbox are approved automatically. In Regular permissions mode, normal permission prompts continue even when the command is inside the sandbox.
Auto-allow does not eliminate every prompt. A command that matches a Bash deny rule is still blocked. rm or rmdir commands detected as targeting a critical path go through the normal permission flow. Content-dependent ask rules such as Bash(git push ) also prompt for commands inside the sandbox.
File read and write scope
By default, commands in the Claude Code sandbox can write to the working directory, the user-specific temporary directory, and added directories. Some protected paths within a directory open to write access remain closed to writing. The default read scope is broader: commands can read most of the machine, including credential files.
The sandbox.filesystem.allowWrite, sandbox.filesystem.denyWrite, and sandbox.filesystem.denyRead fields are used for file access. sandbox.filesystem.allowRead can reopen specific paths within an area where reading is denied. When read rules conflict, the rule covering the narrower path applies.
Claude Code enforces write rules inside the sandbox at the operating system level. These rules also apply to subprocesses launched by the command. When filesystem lists are changed during a session, the new paths apply to the next sandbox command. If the same filesystem array is defined in different settings scopes, Claude Code merges the paths.
Some paths are closed to writing by commands inside the sandbox even if they are in the working directory. Examples listed by Anthropic include Claude Code settings files, .claude/skills, .claude/agents, .mcp.json, and certain shell startup files in the working directory. The sandbox enforces this protection while the command runs. The permission system makes a separate assessment before the tool runs.
Network and credentials
A command in the Claude Code sandbox has no direct network path to the outside. Connections pass through a proxy running on the machine. The proxy checks each host against the allowed domains. The allowed domains list is initially empty. The permission mode determines what happens for other hosts.
Filesystem and network isolation are independent layers in Claude Code. When sandbox.filesystem.disabled is true, filesystem isolation is disabled while network isolation remains in place. In this case, commands inside the sandbox gain unrestricted read and write access to the host filesystem; network traffic remains limited to allowed domains. Anthropic notes that, in this case, a command can modify files that subsequent commands will execute or read.
The sandbox.credentials setting defines files and environment variables to protect from commands inside the sandbox. The deny mode in a file entry prevents reading inside the sandbox. For an environment variable, the same mode removes the variable from the environment before each sandbox command runs. File protection is part of the filesystem layer. Environment variable protection applies even when that layer is disabled.
Claude Code does not have a built-in credential deny list. This setting restricts only the files and variables listed. In addition, sandbox.credentials affects only Bash commands inside the sandbox. File tools and other processes running outside the sandbox are not covered in the same way.
Trust and permissions in Chainabit CLI
Chainabit CLI defines the permission mode, folder trust, and operating system sandbox as separate boundaries. The permission mode manages approvals. Folder trust and the operating system sandbox determine which local tools can be used. A mode does not grant access to another account or workspace.
In Chainabit CLI, local tools run only in a trusted folder and follow the permission mode. Programs run only inside the operating system sandbox. Chainabit verifies that the sandbox is active in the running process before using it. Local programs are unavailable on systems where the sandbox is not present. chainabit doctor reports the local execution status and the sandbox in use.
In Plan mode, local tools only read files and no changes are made. In Ask before edits mode, local tools can also read files; every change requires user approval. In Auto approve mode, Chao can edit files in trusted folders and run routine sandbox programs without asking. Security and permission rules also apply in this mode.
In Plan, Ask before edits, and Auto approve modes, deletions, running interpreters, and changes to configuration executed by other tools do not occur without asking. Network access from a program also requires permission. Chainabit defines an exception for Auto approve on macOS: programs can access certain developer registries and configured destinations through a local filter. The filter does not access private or local addresses.
Folder trust is hierarchical. A trusted folder also covers folders beneath it; trusting a subfolder does not grant trust to its parent folder. Trust does not override other permissions. The permission mode, security rules, and sandbox continue to apply. When trust is revoked, that decision takes effect on the next request, and pending file changes are not made.
According to Chainabit, some areas are closed to local tools and programs run by Chao, even in trusted folders. These include .env variants identified by name, .ssh, .aws, .gnupg, .kube, .git, private keys, and certificates. Chainabit configuration, trust records, and conversations are also among the protected areas.
Boundaries and operations outside the scope
The Claude Code sandbox covers shell commands. According to Anthropic, the built-in Read, Edit, Write, WebFetch, and WebSearch tools run outside the sandbox and follow their own permission rules. A denyRead entry does not stop the Read tool; allowedDomains does not restrict WebFetch access either. Local MCP servers, command hooks, and some helper processes also run outside the sandbox with the user's full access.
In Claude Code, commands that match excludedCommands run outside the sandbox. The sandbox's filesystem restrictions and network proxy do not apply to these commands. When a command inside the sandbox fails, Claude may also ask for permission to run the command again outside the sandbox. Setting allowUnsandboxedCommands to false disables this retry path; commands that match excludedCommands remain separate.
According to Anthropic, when the platform does not support the sandbox or the initial dependency check fails, Claude Code runs commands without the sandbox by default. If sandbox.failIfUnavailable is set to true, it exits at startup in this case. On Linux and WSL2, bubblewrap is used for filesystem isolation, and socat is used to route network traffic through the proxy.
Chainabit notes that a program assigned to its own session may continue running when trust is revoked. A hard link in a visible folder that was created earlier and points to a restricted file can also be read by programs. File tools, however, reject files with more than one link. Local programs are unavailable on Linux and Windows because there is no program sandbox. File tools continue to work in trusted folders.