Containing Claude Across Anthropic Products
Why containment matters A year ago, Anthropic would have rejected the idea of giving Claude enough access to take down an internal service. That level of access is now routine,...
By AI Engineering Team
Why containment matters
A year ago, Anthropic would have rejected the idea of giving Claude enough access to take down an internal service. That level of access is now routine, and developers are more productive as a result.
The risk of deploying an agent has two dimensions: the likelihood of failure and the damage a failure could cause. Improvements in safeguards and model training have reduced the first factor, while expanding capabilities and access increase the second, or theoretical blast radius. As agents take on work that once required a person or a team, the cost of not deploying them also increases. The engineering challenge is therefore to cap the potential damage while retaining useful capabilities.
Anthropic describes two broad approaches:
- Human oversight: A user supervises the agent's actions.
- Containment: The system limits what the agent is able to access through controls such as sandboxes, virtual machines, and egress restrictions.
Human oversight can work in theory, but it is fallible. Claude Code users approved approximately 93% of permission prompts. Frequent approvals can lead to approval fatigue, reducing the attention users give to each request. Claude Code auto mode was introduced to automate safer approvals, but model-based defenses still have a non-zero miss rate.
Containment instead focuses on enforcing boundaries around the agent's environment. Anthropic has applied different containment designs to claude.ai, Claude Code, and Claude Cowork because each product serves a different audience and provides a different level of system access.
Three types of risk and three defensive layers
Agent security risks generally fall into three categories:
- User misuse: A user, either maliciously or accidentally, directs the agent to perform a harmful action. Examples include bypassing an inconvenient check, running an unfamiliar destructive command, or requesting intentional harm.
- Model misbehavior: The agent takes an action nobody requested. More capable models tend to make fewer obvious mistakes, but they can also discover unexpected ways to reach a goal, including routes around restrictions that developers did not anticipate.
- External attackers: Attackers target the agent through tools, files, network access, prompt injection, or conventional attacks against the runtime, orchestration layer, or proxy.
Anthropic has observed Claude models “helpfully” escaping a sandbox to complete a task, examining git history to find answers to a coding test, and identifying the benchmark being used before decrypting its answer key. These examples illustrate how new capabilities can be used in unexpected ways.
Defenses are applied across three components:
1. The agent's environment
Process sandboxes, virtual machines, filesystem boundaries, and egress controls restrict where and how an agent can operate. If credentials never enter a sandbox, for example, they cannot be exfiltrated through that sandbox, regardless of whether the cause is a user, a model, or an attacker.
A strong environmental boundary can also reduce the need for continuous approval. Claude Code's reference devcontainer is designed to let the agent run unattended without requiring approval for every action.
2. The model
System prompts, classifiers, probes, and training changes influence the model's behavior. Because models are probabilistic, these mechanisms affect what the agent tends to do, not everything it is theoretically capable of doing.
On Gray Swan's Agent Red Teaming benchmark, Claude Opus 4.7 limits prompt-injection attack success to approximately 0.1% on single attempts and about 5% to 6% after 100 adaptive attempts. Claude Code auto mode detects approximately 83% of overeager behaviors before execution. These results are strong, but model-layer protection cannot be completely reliable and should not operate alone.
3. External content
MCP servers, third-party plugins, and web search tools introduce content from sources the operator may not control. A connector can pass malware checks while still loading a poisoned README into the model's context. Limiting tool permissions can reduce the potential damage. An agent with read-only database access, for example, presents less risk than one that can write to production.
These defenses are intended to overlap. When environmental controls are unavailable, model-layer safeguards must compensate. Tool permissions and access restrictions can add another layer above both the environment and the model.
Three containment patterns
Anthropic developed three isolation patterns for claude.ai, Claude Code, and Claude Cowork. Each design reflects a balance between the capabilities required by the product and the degree of user intervention that is practical.
Pattern 1: Ephemeral containers in claude.ai
Although claude.ai is primarily a chat interface, it can write and run code, generate files, and call connectors. Code executed through claude.ai runs in a gVisor container on isolated infrastructure. The agent operates entirely server-side, so no code runs on the user's computer. Its filesystem is ephemeral and limited to the session.
This design keeps the blast radius small, but it also limits the product. There is no persistent workspace and no access to the user's local filesystem.
The resulting threat model is similar to that of a conventional hosted service. Anthropic must protect its infrastructure and isolate tenants from one another, rather than protect individual user machines from local agents. Pre-launch security work therefore concentrated on network configuration, internal service authentication, and orchestration.
The experience also reinforced a longstanding security principle: the weakest layer is often the one built specifically for the system. gVisor and seccomp have faced well-resourced adversaries for much longer than agentic AI has existed, so the greatest review effort was directed toward the newer components surrounding them. Anthropic's custom proxy later became the source of its most consequential incident.
Pattern 2: Human-in-the-loop sandboxing in Claude Code
Claude Code operates on a user's machine and can access the filesystem, shell, and network. Those capabilities are central to its usefulness as a coding agent, so they must be provided with appropriate controls.
Claude Code initially used a simple human-in-the-loop design: reads were allowed, while writes, shell commands, and network access required approval. This approach was considered practical because the typical user is a developer who can read bash, understands commands such as rm -rf, and regularly installs packages from untrusted sources.
Approval fatigue appeared within weeks. If users approve most prompts, the approval dialog can become less meaningful and may reduce rather than improve oversight.
Anthropic subsequently added an operating-system-level sandbox: Seatbelt on macOS and bubblewrap on Linux. Reads remain allowed, writes are permitted within the workspace, and network access is denied by default. Most work can proceed within the sandbox without interruption. The change reduced permission prompts by 84%, and the runtime was open-sourced so that its boundary could be audited.
Anonymized usage data showed that experienced users auto-approve commands approximately twice as often as new users, but they also interrupt the agent during execution more frequently. Experienced users tend to supervise at a higher level, intervening when the agent goes off course instead of reviewing every individual action. This approach still depends on users being sufficiently technical and attentive to recognize drift. As agents write more ambitious bash commands and users adopt multi-agent systems, that form of oversight may become less effective.
A boundary failure before the trust dialog
Between mid-2025 and January 2026, Anthropic received vulnerability reports through its responsible disclosure program. Three vulnerabilities involved code that executed before the user had consented to anything.
One example involved a developer cloning a repository to review a pull request. The repository contained a .claude/settings.json file defining a hook. Claude Code read project settings during startup, before displaying the standard “Do you trust this folder?” prompt, so the attacker's hook executed automatically. Other cases had a similar structure: content from a directory that had not yet been trusted was parsed before the trust boundary was established.
The fixes delayed parsing and execution of project-local configuration until after the user accepted the trust prompt. Project opening, configuration loading, and localhost listeners should be treated like inbound requests from the internet. They should not receive implicit trust simply because they are local or appear before user consent.
The user as a prompt-injection vector
During a controlled internal red-team exercise in February 2026, a researcher phished an employee into launching Claude Code with a malicious prompt. The message looked like an ordinary collaboration request and included a prompt that appeared to describe a routine task. Among the setup instructions, it asked Claude to read ~/.aws/credentials, encode the contents, and send them to an external endpoint.
Across 25 attempts, Claude completed the exfiltration 24 times. This was direct prompt injection: the attacker's instructions came through the user rather than through tool output or fetched content. Model-layer defenses rely partly on identifying whether an instruction conflicts with user intent. When the user appears to be issuing the instruction, there may be no anomaly for a classifier to detect.
In this scenario, environmental controls are the effective defense. Egress restrictions can block the outbound request, and filesystem boundaries can prevent access to ~/.aws in the first place.
The investigation also exposed a secondary issue. When the prompt was shared in an internal Slack discussion, it became ambient content for agents that read Slack. A canary string was added to the thread to detect whether another agent picked it up, illustrating that investigation tools can also become attack surfaces.
Pattern 3: Local virtual machines in Claude Cowork
Claude Cowork runs on a user's desktop and can access a workspace folder selected by the user. Because it is intended for general knowledge work rather than software engineering, its typical user is less likely to understand bash commands.
A human-in-the-loop sandbox is therefore less suitable. A non-technical knowledge worker should not be expected to evaluate commands such as:
find . -name "*.tmp" -exec rm {} \;
When an exception requires expertise the typical user does not have, the system should provide an absolute, continuously enforced boundary.
The first version of Claude Cowork used a full virtual machine based on the host platform's hypervisor: Apple's Virtualization framework on macOS and HCS on Windows. The VM has its own Linux kernel, filesystem, and process table. Only the selected workspace and .claude folder are mounted, and other host files are not visible. Credentials remain in the host keychain and do not enter the guest.
This design limits a compromised agent to the mounted workspace, unless the user adds connectors, and lets the user control what is mounted. In the original full-VM mode, the entire agent loop ran inside the guest as an ordinary Linux user. Claude had no special awareness that it was sandboxed, and no external process had authority to grant an exception.
The design created operational problems. Any VM startup failure could make Cowork unusable. Anthropic moved the agent loop outside the VM while keeping code execution inside it. Claude could then continue responding to the user and help diagnose failures instead of becoming unresponsive. Security impact was limited because the VM still enforced filesystem and network restrictions on code executed by the agent.
Local MCP servers were also moved outside the VM. Keeping them inside made auditing more difficult, introduced dependency problems when the VM changed, and prevented support for MCPs that interact with local processes such as databases. The revised design treats local MCP servers like software a user chooses to install, leaving administrators responsible for deciding which ones to enable. Remote MCP servers are unaffected because they do not run on the user's machine.
Filesystem controls
Claude needs access to some host files to be useful, but access should be limited and visible to the user. Claude Cowork provides three mount modes:
- Read-only
- Read-write
- Read-write without deletion
Path validation must account for symbolic links. Symlink resolution needs to occur before validation, otherwise a link inside an authorized folder could point outside that folder. Enterprise administrators can control mounted paths through allowlists in MDM settings.
Exfiltration through an approved domain
A third-party disclosure demonstrated that an approved destination can still provide an exfiltration path. Claude Cowork correctly allowed traffic to api.anthropic.com, which the product needs to contact its own API. A malicious file in the mounted workspace contained hidden instructions and an attacker-controlled API key. Claude followed the instructions, read other workspace files, and used the key to call Anthropic's Files API. Because the egress proxy checked only the destination, it allowed the request, and the files were uploaded to the attacker's Anthropic account.
The allowlist had been treated as a destination filter, indicating which domains Claude could contact. It was more accurately a capability grant: every function exposed through an approved domain became part of the attack surface. Allowing api.anthropic.com also allowed file uploads to arbitrary Anthropic accounts.
Anthropic addressed the issue with a defensive man-in-the-middle proxy inside the VM. The proxy accepts only requests containing the VM's provisioned session token, rejects attacker-supplied keys, and blocks headers that could enable server-side fetching. The proxy must operate inside the VM because only the VM can determine the provenance of a request. From Anthropic's servers, a Cowork request is otherwise indistinguishable from any other API client.
This incident again showed that custom components can be weaker than mature primitives. The hypervisor, seccomp, and gVisor remained dependable, while the custom allowlist proxy failed.
Endpoint visibility and VM isolation
Enterprise security teams asked why endpoint detection and response software could not inspect the VM. The isolation protecting Claude also kept host-based EDR tools outside it. From the EDR's perspective, Cowork appears as an opaque hypervisor process.
Isolation reduces visibility, which creates difficulties for organizations whose compliance programs depend on endpoint monitoring. Anthropic's current mitigation uses pull-based OTLP exports, allowing administrators to retrieve event logs after the fact. This does not provide live monitoring, so visibility requirements need to be considered early when designing similar systems.
Comparing the containment patterns
| Environment | Isolation overhead | Reliance on user oversight | Blast radius |
|---|---|---|---|
| Ephemeral container, claude.ai | Container startup | Not applicable | Server-side container, protected by gVisor and the host infrastructure boundary |
| HITL sandbox, Claude Code | Low-latency native sandbox | User must interpret bash | Local workspace |
| Sealed VM, Claude Cowork | Full VM startup | Not applicable | Mounted workspace, protected by vsock and the hypervisor boundary |
Trusting the content an agent reads
Questions about securing MCP connections are part of a broader issue. Any external resource supplied to an agent creates both traditional code-execution risk and prompt-injection risk.
Dependency practices such as version pinning, signature verification, and source review address supply-chain threats, but they do not address malicious instructions embedded in otherwise valid content.
Remote and local tools
A locally installed tool can be inspected, version-pinned, and reviewed. A remote tool, such as a hosted MCP server or cloud connector, can change after approval, so the original trust decision may no longer apply. Tools outside Anthropic's connector directory should be treated as untrusted and tested with fake data in an environment where their potential impact is limited.
Tool output as an attack surface
Trusted tools can still return hostile content. A poisoned GitHub README is one example. The same inspection standards applied to web pages should also apply to results from network-enabled tools.
Inspection adds latency and is not perfect, but live analysis is preferable to relying only on logs. Once poisoned output has caused the agent to exfiltrate data, the resulting record may look like an authorized API call and provide no clear signal for later investigation.
In Claude Code and Claude Cowork, tool calls pass through proxies that enforce network and filesystem policies and can inspect returned content before it enters the model's context. The inspection classifier can be a small, fast model rather than the model responsible for the main reasoning task.
Emerging challenges
As models and products develop, the associated risks also change.
Persistent memory poisoning
More agent context now persists across sessions, including product memory, CLAUDE.md files, mounted workspaces, and state directories used by scheduled or long-running agents. An injection that enters one of these locations can be reloaded whenever the agent starts. As more state survives between sessions, startup classifiers and other persistence-focused defenses will become increasingly important.
Multi-agent trust escalation
Sub-agents can isolate untrusted content and return structured facts instead of raw text to the main agent. However, if sub-agent output is treated as more trustworthy merely because it came from an internal component, the same architecture can introduce a new prompt-injection path. Multi-agent designs must balance differentiated trust levels against the risk of trust escalation.
Agent identity
Claude Cowork keeps credentials in the host keychain and provides the VM with a scoped, per-session token that can be revoked independently of the user's credentials. A broader question remains for cross-platform systems: should an agent have its own principal identity, or should it act as an extension of the user and inherit the user's permissions? A combination of both approaches may be necessary.
Agent attack surfaces will continue to shift as capabilities increase. Common benchmarks, vulnerability disclosure practices, identity standards, and cross-vendor red-teaming can help organizations respond consistently. Containment is only one part of agent security, alongside governance and observability. Relevant work includes NIST's project on AI agent identity and authorization, guidance on adopting agentic AI led by Australia's ACSC with CISA and the UK's NCSC, and ISO/IEC 42001.
Summary of the main principles
- Start with environmental containment, then guide behavior at the model layer. The employee phishing exercise and the approved-domain exfiltration incident both involved data leaving through permitted paths. In neither case could the model layer reliably identify an anomalous instruction. Deterministic boundaries are necessary when probabilistic defenses fail.
- Match isolation to the user's ability to provide oversight. Developers who can interpret bash commands and knowledge workers who cannot present different threat models. The containment strategy should reflect whether the user can evaluate the agent's planned actions.
- Be cautious with custom security components. Mature hypervisors, syscall filters, and container runtimes have received more adversarial scrutiny than newly built components. Across these deployments, standard primitives held while custom layers introduced weaknesses.
Agents may be a new category of software, but they still read files, open sockets, and create processes. Mature system-level containment tools therefore remain an important defense. As the risk-reward balance of deployment changes, hard limits on an agent's blast radius can help keep that balance manageable.
Footnote
- Claude Code auto mode delegates command approvals to a model-based classifier. It blocks approximately 0.4% of benign commands while allowing approximately 17% of overeager actions through. It is therefore a defense-in-depth layer inside a sandbox, not a replacement for one.