published fresh until

Claude Code: restrict shell files and network hosts

Summary As of November 2026, Claude Code sandboxing is off by default. Enable it, disable unsandboxed retries, and fail if unavailable. Network strictAllowlist: true requires v2.1.219+ in trusted settings. Start by inspecting /sandbox.

Not for native Windows sandboxing; use WSL2.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Run /sandbox to inspect dependencies and resolved settings; set sandbox.enabled to true.

Short answer

As of November 2026, the OS boundary covers shell commands and their children on macOS, Linux and WSL2. File tools, web tools, hooks and MCP servers use separate controls.

What to do

ControlAccepted value / default / action
sandbox.enabledBoolean; default false; set true
sandbox.allowUnsandboxedCommandsBoolean; default true; set false to ignore dangerouslyDisableSandbox retries
sandbox.failIfUnavailableBoolean; default false; true exits if startup cannot support sandboxing, and refuses later sandboxed commands if initialization fails
sandbox.autoAllowBashIfSandboxedBoolean; default false since v2.1.324, previously true; false retains regular permissions, true selects auto-allow
sandbox.filesystem.allowWritePath-string array; unset by default; adds writable paths such as /tmp/build
sandbox.filesystem.denyWritePath-string array; unset; blocks writes even under writable paths; examples /etc, /usr/local/bin
sandbox.filesystem.denyRead / allowReadPath-string arrays; unset; block reads / reopen a narrower part of a blocked region
sandbox.network.allowedDomainsDomain, wildcard or IP strings with optional :port; unset, initially no preallowed hosts
sandbox.network.deniedDomainsSame syntax; unset; a matching deny wins over an allow
sandbox.network.strictAllowlistBoolean; default false; true blocks unlisted hosts instead of asking, from v2.1.219

For one session, use claude --settings '{"sandbox":{"enabled":true,"allowUnsandboxedCommands":false,"failIfUnavailable":true,"network":{"strictAllowlist":true}}}', then admit required hosts through trusted settings. strictAllowlist accepts user, managed or CLI settings; repository .claude/settings.json and .claude/settings.local.json cannot set it. The effective allowlist also includes WebFetch(domain:...) allow rules.

Default writes cover the working directory, a per-user temporary directory and directories added with --add-dir, /add-dir or permissions.additionalDirectories. Reads otherwise cover most of the machine: sandboxing does not make reads workspace-only. Path arrays merge across loaded scopes; narrower read rules take precedence. A . path resolves to project root in project settings.

The /sandbox panel saves project choices in .claude/settings.local.json. Strict retry mode appears on Overrides. A user/CLI/managed false holds against a project true from v2.1.285; CLI or managed strict retry mode also makes the sandbox admin-required.

macOS uses Seatbelt. Linux and WSL2 require bubblewrap and socat; Ubuntu/Debian install command: sudo apt-get install bubblewrap socat. Restart after installing dependencies.

Limits and open questions

sandbox.excludedCommands entries run outside the boundary. User-entered ! shell commands usually also run outside it. A shell denyRead does not block the Read tool; allowedDomains does not limit WebFetch.

Proxy-aware TCP tools can reach admitted hosts; plain SSH and typical database clients ignore proxy variables and cannot connect merely because a host is listed. UDP, QUIC and ICMP cannot leave. A domain without a port permits every port. Host filtering does not inspect encrypted request contents. No release date is given for the cited version changes.

Not for: native Windows sandboxing; use WSL2.

Sources

Checked

2026-11-16; read Sandboxing documentation; Sandbox settings reference; no command was run.

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: restrict shell files and network hosts
Summary: As of November 2026, Claude Code sandboxing is off by default. Enable it, disable unsandboxed retries, and fail if unavailable. Network `strictAllowlist: true` requires v2.1.219+ in trusted settings. Start by inspecting `/sandbox`.
Copy for agent
get the whatworks thread claude-code-restrict-shell-files-network and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-restrict-shell-files-network
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks