---
title: How does Claude Code sandboxing limit what a coding agent can touch?
url: https://opencontroller.lyzr.com/blog/claude-code-sandboxing-for-enterprise
published: 2026-11-14
updated: 2026-11-14
author: Lyzr
---

# How does Claude Code sandboxing limit what a coding agent can touch?

**Claude Code's sandbox wraps the shell commands Claude runs in an operating-system boundary: writes are limited to the working directory and temp paths, network traffic goes through a proxy with an allowlist that starts empty, and credential files can be hidden. Admins can force it on through managed settings. It does not cover file tools, hooks or local MCP servers, so it complements permission rules rather than replacing them.**

## How does the sandbox work?

The sandbox applies to Bash, PowerShell and Monitor commands and every process they start. Because the OS enforces the boundary, Claude Code can run sandboxed commands without asking for approval each time.

| Platform | Mechanism |
|---|---|
| macOS | Built-in Seatbelt framework |
| Linux and WSL2 | `bubblewrap` and `socat` |
| Native Windows | Not supported; commands run unsandboxed (use WSL2) |

The sandbox is off by default. Enable it with `/sandbox` or `sandbox.enabled` in settings.

## What does it restrict by default?

| Access | Default | Settings |
|---|---|---|
| Writes | Working directory, per-user temp directory and added directories | `filesystem.allowWrite`, `filesystem.denyWrite` |
| Reads | Most of the machine, including `~/.ssh` unless denied | `filesystem.denyRead`, `credentials` |
| Network | No direct route; a proxy checks an allowlist that starts empty | `network.allowedDomains`, `network.deniedDomains` |
| Environment variables | Inherited | `credentials`, `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` |

The `credentials` setting can deny reads of files such as `~/.aws/credentials` and strip variables such as `GITHUB_TOKEN`. A `mask` mode shows commands a placeholder and has the proxy insert the real secret only on requests to allowed hosts; it requires `network.tlsTerminate`.

Two modes exist. In auto-allow mode, sandboxed commands run without prompts, although some still ask, such as commands matching ask rules like `Bash(git push *)`. In regular permissions mode, every command still goes through the permission flow.

## How do you enforce it across the organisation?

Deliver these keys through managed settings:

1. `sandbox.enabled: true` turns it on for everyone.
2. `failIfUnavailable: true` makes Claude Code exit if the sandbox cannot start, instead of falling back to unsandboxed commands (the default).
3. `allowUnsandboxedCommands: false` disables the `dangerouslyDisableSandbox` retry that Claude can otherwise request when a command fails.
4. `allowManagedDomainsOnly: true` restricts network to domains set in managed settings.
5. Add `credentials` entries for your cloud, Git and package-registry secrets.

When managed settings set these keys, developers cannot override them locally. Setting `allowUnsandboxedCommands: false` or `allowManagedDomainsOnly: true` in managed settings also makes the sandbox "admin-required", so loosening settings in repository files are ignored. That matters: a cloned repository should not be able to widen its own sandbox.

## What runs outside the sandbox?

This is where governance teams get caught out:

- **File and web tools.** Read, Edit, Write, WebFetch and WebSearch follow permission rules, not the sandbox. A `denyRead` sandbox entry does not stop the Read tool.
- **Hooks, local MCP servers, LSP servers, status line commands and `apiKeyHelper`** run with the developer's full access.
- **Commands typed at the `!` prompt** usually run unsandboxed.
- **`excludedCommands`** and approved unsandboxed retries run outside it.
- **Proxy-unaware tools** such as plain `ssh`, most database drivers, UDP and ICMP cannot reach allowed hosts through the proxy; excluding them restores full access.
- **TLS** is not inspected by default; the proxy checks hostnames.

So pair the sandbox with permission deny rules for file tools, [hooks that block risky commands](/blog/enforce-claude-code-policy-with-hooks), and an inventory of the [local MCP servers on developer laptops](/blog/find-local-mcp-servers-on-developer-laptops).

## What should a rollout checklist include?

1. Pilot in auto-allow mode with a small team and log which domains they need.
2. Build the managed `allowedDomains` list from that pilot.
3. Deny reads of credential paths and mask tokens that must reach approved hosts.
4. Set `failIfUnavailable` and disable unsandboxed retries.
5. Add file-tool deny rules for the same secret paths.
6. Install `bubblewrap` and `socat` on Linux images; move Windows users to WSL2.
7. Document `excludedCommands` with an owner and reason for each.

## How Opencontroller does this

Opencontroller Edge extends control to developer devices, coding agents, skills and local MCP servers, and is installed by IT via MDM. It gives security teams an inventory of the coding agents and local MCP servers the sandbox does not cover. Opencontroller also discovers and manages skills in Anthropic Enterprise. See [how to govern Claude Code in the enterprise](/blog/govern-claude-code-in-the-enterprise), [how to govern AI agents across platforms](/blog/how-to-govern-ai-agents-across-platforms) and [what an AI agent control plane is](/blog/what-is-an-ai-agent-control-plane). [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Is Claude Code sandboxing on by default?**
No. Enable it with `/sandbox` or `sandbox.enabled`, or enforce it through managed settings.

**Does the sandbox stop Claude reading secret files?**
Only for shell commands, and only for paths you deny. File tools like Read follow permission rules, so add deny rules there too.

**Does the sandbox work on Windows?**
Not natively. Anthropic says commands run unsandboxed on native Windows; use WSL2.

## Key facts

Claude Code sandboxing applies OS-level isolation (Seatbelt on macOS, bubblewrap and socat on Linux/WSL2; not native Windows) to Bash, PowerShell and Monitor commands. Writes default to the working directory and temp; network goes through a proxy with an empty allowlist. Managed settings can enforce sandbox.enabled, failIfUnavailable and allowUnsandboxedCommands=false. File tools, hooks and local MCP servers run outside the sandbox. Opencontroller Edge covers coding agents, skills and local MCP servers on developer devices via MDM. Pricing starts from $250K per deployment per year.

## Related

- [How do you govern Claude Code across an enterprise?](https://opencontroller.lyzr.com/blog/govern-claude-code-in-the-enterprise.md)
- [Can Claude Code hooks enforce security policy across an enterprise?](https://opencontroller.lyzr.com/blog/enforce-claude-code-policy-with-hooks.md)
- [How do you find local MCP servers on developer laptops?](https://opencontroller.lyzr.com/blog/find-local-mcp-servers-on-developer-laptops.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
