NachschlagenQuellenregister

Dokumentationerreichbar

Anthropic, Configure the sandboxed Bash tool

code.claude.com (externe Seite)

Die Her­stel­ler­do­ku­men­ta­tion zur Sandbox, die jeden Bash-Befehl in eine vom Betriebssystem gezogene Grenze sperrt. Sie ist die Quelle für den Unterschied, um den es in diesem Kapitel geht: Eine Rechteregel entscheidet je Aufruf, diese Grenze gilt für den laufenden Prozess und alle seine Kinder. Zwei Stellen wiegen schwerer als die Beschreibung selbst. Erstens läuft die Sandbox voreingestellt fail-open: Fehlt ein Paket oder ist die Plattform nicht unterstützt, arbeitet Claude Code ohne Sandbox weiter, bis jemand sandbox.failIfUnavailable setzt. Zweitens darf das Modell die Grenze über einen Rückfallpfad selbst verlassen, wenn ein Befehl darin scheitert; der zweite Versuch läuft dann außerhalb, und wer ihn genehmigt, richtet sich nach dem Rechtemodus. Auf macOS zieht Seatbelt die Grenze, auf Linux und WSL2 bubblewrap, natives Windows wird nicht unterstützt. Seit Version 2.1.271 (Abschnitt 'Per-command allowed domains in auto mode', gesehen 23.09.2026) gibt es einen engeren Weg für einzelne Rechner: Im Auto-Modus kann ein Befehl seine eigene Liste erlaubter Rechner mitbringen, der Klassifikator prüft sie zusammen mit dem Befehl, und der Befehl bleibt dabei in der Sandbox.

geprüft 22.11.2026

Worauf sich diese Seite beruft, wörtlich, abgerufen am 06.11.2026:

  • 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.bestätigt 22.11.2026
  • Unless managed settings set them, a developer’s user settings or --settings can turn on the following keys.bestätigt 22.11.2026
  • 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.bestätigt 22.11.2026
  • 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.bestätigt 22.11.2026
  • code running inside the sandbox can potentially use domain fronting or similar techniques to reach hosts outside the allowlistbestätigt 22.11.2026
  • Auto-allow mode works independently of your permission mode setting, with three exceptions: plan mode, an auto mode command that carries per-command allowed domains, and server-side classifier review of sandboxed commands in auto mode.bestätigt 22.11.2026
  • A command that carries hosts goes to the classifier instead of being approved by a permission rule or the sandbox's auto-allow mode.bestätigt 22.11.2026
  • 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.bestätigt 22.11.2026
  • By default, when the platform doesn’t support the sandbox or the dependency check at startup fails, Claude Code runs commands without sandboxing.bestätigt 22.11.2026
  • The retried command runs unsandboxed. In an interactive terminal session, who approves it depends on your permission mode:bestätigt 22.11.2026
  • The sandbox is off by default.bestätigt 22.11.2026
  • To turn it on, run /sandbox in a sessionbestätigt 22.11.2026
  • Claude’s file tools, MCP servers, and hooks run outside itbestätigt 22.11.2026
  • What you type at the ! prompt usually runs outside the sandbox, so typing a line yourself doesn’t test it.bestätigt 22.11.2026
  • Most of the machine, including credential files such as ~/.ssh and ~/.aws/credentialsbestätigt 22.11.2026
  • Inherited from Claude Code, including any secrets in its environmentbestätigt 22.11.2026
  • The sandbox.credentials setting declares credential files and environment variables to protect from sandboxed commands.bestätigt 22.11.2026
  • environment variables are unset before each sandboxed command runsbestätigt 22.11.2026
  • There is no built-in credential deny list, so only the files and variables you list are restricted.bestätigt 22.11.2026
  • no scope can remove one that another scope addedbestätigt 22.11.2026
  • sandbox.credentials affects sandboxed Bash commands only.bestätigt 22.11.2026
  • Claude Code shows sandboxed commands a per-session placeholder called the sentinelbestätigt 22.11.2026
  • the command still sees only the sentinel, but the sentinel reaches the server unchanged and authentication failsbestätigt 22.11.2026
  • It ignores them in a repository’s .claude/settings.json or .claude/settings.local.jsonbestätigt 22.11.2026
  • Masking files requires Claude Code v2.1.221 or later.bestätigt 22.11.2026
  • For files on macOS, Claude Code blocks the file instead of masking it.bestätigt 22.11.2026
  • and tools that use UDP behave this waybestätigt 22.11.2026
  • docker is incompatible with the sandbox.bestätigt 22.11.2026
  • Connections go through a proxy on your machine that checks each host against your allowed domains, which start empty.bestätigt 22.11.2026
  • so a tool that opens its own connection failsbestätigt 22.11.2026
  • fail for the reason the database client entry givesbestätigt 22.11.2026
  • against an SSH remote fail inside the sandbox even when the host is allowedsteht dort nicht mehr
  • 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.bestätigt 22.11.2026
  • Use it for a tool that can’t work inside the sandbox and that you trust with your full access.bestätigt 22.11.2026
  • An excluded command runs with your full access.bestätigt 22.11.2026
  • An excluded command goes through the regular permission flowbestätigt 22.11.2026
  • For example, allowing access to /var/run/docker.sock effectively grants access to the host system through the Docker socket.bestätigt 22.11.2026
  • Sandboxing reduces risk but is not a complete isolation boundary.bestätigt 22.11.2026
  • Each one weakens the sandbox, so set it to false in managed settings if you don’t want it usedbestätigt 22.11.2026
  • If you set allowNestedUserNamespaces to true, you turn off a security boundary: code from a sandboxed command can end up running outside the sandbox.bestätigt 22.11.2026
  • sandboxed commands can then launch other applications unsandboxed with no user promptbestätigt 22.11.2026
  • the setting exposes process information to sandboxed commands that a fresh /proc mount would hidebestätigt 22.11.2026
  • Requires Claude Code v2.1.305 or later.bestätigt 22.11.2026
  • still force a prompt even for sandboxed commandsbestätigt 22.11.2026
  • Some sandboxed commands also go through the regular permission flow instead of being approved automatically.bestätigt 22.11.2026
  • Monitor tool commands aren’t approved automatically, though they still run in the sandbox.bestätigt 22.11.2026
  • Until you lift the restriction, commands run without the sandbox under the regular permission flowbestätigt 22.11.2026
  • To make Claude Code exit at startup instead, set sandbox.failIfUnavailable to true.bestätigt 22.11.2026
  • The session keeps running, and the refused command doesn’t run unsandboxedbestätigt 22.11.2026
  • Excluded commands and commands you type yourself keep runningbestätigt 22.11.2026
  • In a background session, they’re refused toobestätigt 22.11.2026
  • to be prompted on Bash retriesbestätigt 22.11.2026
  • which opens every Unix socket to sandboxed commandsbestätigt 22.11.2026
  • connect to any port on localhost, which includes every other service listening therebestätigt 22.11.2026
  • set enableWeakerNetworkIsolation to true insteadbestätigt 22.11.2026
  • A repository’s .claude/settings.json can too, unless the sandbox is admin-required.bestätigt 22.11.2026
  • Built-in file and web tools: tools such as Read, Edit, Write, WebFetch, and WebSearch follow permission rules instead.bestätigt 22.11.2026
  • command hooks, local MCP servers, plugin monitors, LSP servers, and helper commands such as your status line command and apiKeyHelper run with your full accessbestätigt 22.11.2026
  • In bypassPermissions mode, hosts outside your allowed domains are allowed unless one of them is on.bestätigt 22.11.2026
  • A connection to a host in deniedDomains is refused in every permission mode too.bestätigt 22.11.2026
  • Allowing broad domains such as github.com can create paths for data exfiltration.bestätigt 22.11.2026
  • Because the proxy makes its allow decision from the client-supplied hostname without inspecting TLSbestätigt 22.11.2026
  • configure a custom proxy that terminates TLS and inspects traffic, and install its CA certificate inside the sandboxbestätigt 22.11.2026
  • Claude can write that file and then run it outside the sandbox.bestätigt 22.11.2026

Sandbox im Glossar01 Was Claude Code ist09 Sandbox und Isolierung11 Eine Wissensbasis aufbauen12 Rechner und Netz pflegen16 Rechte und Sandbox31 Der Harness

Alle Quellen

↑↓ auswählenEnter öffnenDie Suche läuft im Browser. Nichts wird übertragen.