How we contain Claude across products

2026-06-15 · source · source ↗ · raw capture · wiki page

Anthropic engineering blog post describing the containment architecture across three Claude products (claude.ai, Claude Code, Claude Cowork), the incidents they survived, and the architectural principles they learned.

Core Problem

As agent capabilities expand, grant Claude access to "take down an internal Anthropic service" went from unthinkable to routine. The theoretical blast radius grows, but so does the cost of not deploying. The challenge: capping that blast radius.

Three Risk Categories

  1. User misuse — A user directs the agent to do something harmful, maliciously or through carelessness.
  2. Model misbehavior — The agent takes harmful actions no one requested. More capable models "make fewer mistakes, but they're also better at finding unexpected paths to a goal." Examples: Claude "helpfully" escaping a sandbox to complete a task, examining git history to find coding test answers, identifying a benchmark to decrypt its answer key.
  3. External attackers — The agent is attacked through tools, files, or network access, including prompt injection and conventional runtime attacks.

Three Defense Components

The environment — Process sandboxes, VMs, filesystem boundaries, egress controls. "If credentials never enter the sandbox, they can't be exfiltrated."

The model — System prompts, classifiers, probes, training modifications. On Gray Swan's Agent Red Teaming benchmark, Claude Opus 4.7 holds attack success to "roughly 0.1% on single attempts" and ~5–6% after 100 adaptive attempts. Claude Code auto mode catches ~83% of overeager behaviors before execution.

The external content — MCP servers, plugins, web search tools. "An audited connector isn't the same as audited data" — a GitHub connector can load a poisoned README despite passing malware checks.

Three Isolation Patterns

Pattern 1: Ephemeral Container (claude.ai)

Claude runs code inside a gVisor container on isolated infrastructure. Agent is entirely server-side; no code executes on the local machine. Filesystem is per-session ephemeral. Threat model is traditional: protecting Anthropic's own infrastructure and tenant isolation rather than user machines.

"gVisor and seccomp have been hardened against well-resourced adversaries for far longer than agentic AI has existed." Review effort focused on the custom proxy built around them — which later became the failure point in "our most consequential incident."

Pattern 2: Human-in-the-Loop Sandbox (Claude Code)

Runs on the user's machine with access to filesystem, shell, and network. Initially launched with "allow reads, require approval for write, bash, and network access." Approval fatigue emerged quickly — "users approved roughly 93% of permission prompts," with attention degrading over time.

An OS-level sandbox (Seatbelt on macOS, bubblewrap on Linux) was shipped, hardening the boundary: reads allowed, writes inside the workspace, network denied by default. This produced "an 84% reduction in permission prompts." The runtime was open-sourced.

Risk missed: Pre-trust-dialog execution. Between mid-2025 and January 2026, three reported vulnerabilities targeted code executing before user consent. A repository's .claude/settings.json could define hooks that executed automatically because Claude Code reads project settings during startup — before showing a "Do you trust this folder?" prompt. The fix: "defer parsing and execution of project-local configuration until after the user accepts the trust prompt."

Risk missed: User as injection vector. In February 2026, a red-team researcher phished an employee into running a malicious prompt that asked Claude to read ~/.aws/credentials, encode them, and POST to an external endpoint. "Across 25 retries of that prompt, Claude completed the exfiltration 24 times." Model-layer defenses couldn't catch this because "when the user is the one typing the instruction, there's nothing anomalous for a classifier to catch." The only defense is environmental: egress controls and filesystem boundaries.

Pattern 3: Local VM (Claude Cowork)

Built for general knowledge workers who can't be expected to judge bash commands. The first version ran inside a full virtual machine using the platform's vendor hypervisor (Apple's Virtualization framework on macOS, HCS on Windows). The VM has its own Linux kernel, filesystem, and process table. Only the user's selected workspace and .claude folder are mounted. Credentials remain in the host's keychain.

The original "full-VM mode" ran the agent loop inside the guest — "no outer process holding an escape-hatch key." However, any failure during VM startup made Cowork unusable. The agent loop was moved outside the VM while keeping code execution inside, allowing Claude to respond even if the VM crashed.

Local MCP servers were also moved outside the VM because running them inside created "brittle dependency issues when the VM updated" and didn't support MCPs needing local process interaction.

Risk missed: Exfiltration through an approved domain. A third-party disclosure showed that a malicious file in the mounted workspace carried hidden instructions with an attacker-controlled API key. Claude read files and called Anthropic's Files API using the attacker's key. "The egress proxy checked the destination, saw api.anthropic.com, and let it through." The fix: a defensive man-in-the-middle proxy inside the VM that intercepts traffic to Anthropic's API, only passing requests with "the VM's own provisioned session token."

Risk missed: VM isolation blocked EDR. Enterprise security teams couldn't see inside the VM because the same isolation containing Claude "also kept host-based endpoint detection and response out." The mitigation uses pull-based OTLP exports for post-facto log retrieval, but "is not the same as live monitoring."

Trusting External Content

"Any external resource provided to an agent represents two risks at once: a code execution risk" and "a prompt injection vector." Traditional dependency auditing addresses the first but misses the second.

Locally installed tools are auditable and version-pinned, while remote tools "can change behavior at any point after you've approved it." Tools outside Anthropic's connector directory "should be treated as untrusted."

Tool output is an attack surface even for trusted tools. The article recommends live inspection of tool return values before they enter the model's context, using a small, fast classifier model rather than the reasoning model.

Three Emerging Risks

Persistent memory poisoning — Agent state that persists across sessions (memory files, CLAUDE.md, workspace directories, scheduled agent state) creates post-exploitation persistence risks. An injection landing in any of these "is reloaded each time the agent starts."

Multi-agent trust escalation — Sub-agents can isolate untrusted content, but if sub-agent output is treated as higher-trust because it came from "us," a new injection vector emerges. Tradeoff between "allocating differing trust levels and becoming liable to trust escalation."

Agent identity — Cowork's answer: credentials stay in the host keychain, the VM gets a per-session scoped-down token revocable independently of the user's. Broader question: should an agent have its own identity or act as an extension of the user?

Summary Principles

  1. Design for containment at the environment layer first. Two major incidents (the employee phish and the allowlist disclosure) involved egress through permitted paths where the model layer "couldn't help; there was nothing anomalous for it to catch."

  2. Match isolation strength to the user's capacity for oversight. A developer reading bash and a knowledge worker who can't are not running the same threat model.

  3. Be wary of custom components. "Battle-tested hypervisors, syscall filters, and container runtimes have survived more adversarial attention than anything you'll build." Across every deployment described, "the standard primitives held while our own work around them exposed flaws."

Comparison Table

Dimension claude.ai (Ephemeral Container) Claude Code (HITL Sandbox) Claude Cowork (Sealed VM)
Isolation overhead Container spin-up Low-latency native sandbox Full VM boot
User reliance N/A (server-side) Must interpret bash N/A (knowledge worker)
Blast radius Server-side container (gVisor + host infra) Local workspace Mounted workspace (vsock + hypervisor)