The Agent Is Already Inside
Zero trust stopped trusting the network. An AI agent holds real credentials and can take orders from any text it reads. What already broke, the controls that belong outside the model, and a first hardening session.
In February 2026, during an internal red-team exercise at Anthropic, a researcher phished an employee into launching Claude Code with a malicious prompt. The team retried that prompt 25 times. Claude completed the exfiltration 24 times.
There was no exploit to patch. The employee started the agent, and the agent followed its instructions. When Anthropic published the result on May 25, it named the only defense that holds in that situation: "the environment, specifically egress controls that block the POST regardless of intent and filesystem boundaries that keep ~/.aws out of reach in the first place."
A smarter model is not on that list. Neither is a more careful user.
That is the case for applying zero trust to AI agents, with one change of direction. Zero trust taught us to assume the breach has happened. With agents, assume the breach is the agent.
Sources are linked and were read on 22 November 2026. Vendor measurements are labelled as such.
TL;DR
- An agent is an insider with real credentials and machine speed, and any text it reads can steer it: an issue, an email, a web page, a tool description, a dataset.
- Treat it as already compromised. Put the controls that matter outside the model, where no prompt can change them: an OS or VM boundary, an egress proxy, credentials it never holds.
- Give every agent its own identity and a grant sized to one task. In OpenAI's July incident, a shared credential, an exploitable proxy and leaked tokens took agents from a sandbox into another company's systems.
- Model robustness, approval prompts and narrow tokens all help. None of them is a boundary. Injection rates in recent model tests are lower, but models still get broken, and Claude Code users approve 93–97% of prompts, by Anthropic's count.
- For remote MCP, the spec has authorization rules: tokens bound to one server, no passthrough, per-client consent at proxies. They don't cover stdio servers on your laptop.
Start here
| 🧭 | A first hardening session for a coding agent, on one machine. The example is Claude Code, with every setting named as in its documentation on 22 November 2026. You need a throwaway repository. The Bash sandbox runs on macOS, Linux and WSL2; on native Windows, commands run unsandboxed. 1. Turn the sandbox on and watch it work. Start a session in manual permission mode ( 2. Make it fail closed. In 3. Grant the network on purpose. 4. Put credentials out of reach of shell commands. The default read policy still lets sandboxed commands read your credential files. Add 5. Protect the same paths from the file tools. Claude's file tools run outside the Bash sandbox, so add 6. Deny what must stay yours. Rules run deny, then ask, then allow, and an allow can't carve an exception out of a deny. Deny 7. Turn on the audit trail (optional for this first session). If you have an OTLP collector, export 8. Attack it. In a fresh session, again in manual mode, ask for four things: a shell read of the fake secret through a script ( How it ends. Both reads and the push fail whatever you answer. The |
The keys from steps 2 to 6, to merge into ~/.claude/settings.json (add only the domains you need; swap in your canary path):
{
"sandbox": {
"enabled": true,
"failIfUnavailable": true,
"allowUnsandboxedCommands": false,
"network": {
"allowedDomains": []
},
"credentials": {
"files": [
{ "path": "~/.aws", "mode": "deny" },
{ "path": "~/.ssh", "mode": "deny" },
{ "path": "~/canary-secret", "mode": "deny" }
],
"envVars": [
{ "name": "GITHUB_TOKEN", "mode": "deny" },
{ "name": "NPM_TOKEN", "mode": "deny" }
]
}
},
"permissions": {
"deny": [
"Read(~/.aws/**)",
"Read(~/.ssh/**)",
"Read(~/canary-secret)",
"Bash(git push *)"
]
}
}Why agents break zero trust's assumptions
NIST SP 800-207, published in August 2020, removes "implicit trust granted to assets or user accounts based solely on their physical or network location." Access is granted per session, "with the least privileges needed to complete the task," through a policy decision point and an enforcement point. The NSTAC definition quoted in CISA's Zero Trust Maturity Model 2.0 (April 2023) states the assume-breach idea directly: it "assumes that a breach has already occurred or will occur."
That model was built around users, devices and workloads. You authenticate the actor, check the device, then grant the least access the request needs. An agent can pass every one of those checks and still work for someone else. The identity is valid, the machine is healthy, the token is real. Only the intent came from an attacker.
NIST saw a version of this six years ago. Section 5.7 of SP 800-207, on non-person entities, opens with a plain observation: "Artificial intelligence and other software-based agents are being deployed to manage security issues on enterprise networks." Then it warns "that an attacker will be able to induce or coerce an NPE to perform some task that the attacker is not privileged to perform." Such an agent "may have a lower bar for authentication (e.g., API key versus MFA)." In 2020 that described a narrow class of security tools. Today it describes a coding agent reading an issue.
The root cause fits in one line from the OWASP Top 10 for Agentic Applications (December 2025): "agents and the underlying model cannot reliably distinguish instructions from related content."
Two design rules follow. Simon Willison's lethal trifecta (June 2025): an agent that combines access to private data, exposure to untrusted content and a way to communicate externally can be tricked into stealing the data. Meta's Agents Rule of Two (October 2025): within a session, allow at most two of untrusted input, access to sensitive systems or data, and the ability to change state or communicate externally. A session that needs all three should not run autonomously. Meta calls the rule a supplement to least privilege, not a substitute.
A useful coding agent has all three by lunchtime. It reads the issue, opens the private repository and pushes a branch.
OWASP's Least-Agency principle comes before any permission: "avoid unnecessary autonomy," because agentic behavior where it isn't needed "expands the attack surface without adding value." Its entry ASI03, Identity and Privilege Abuse, names the structural gap: "Without a distinct, governed identity of its own, an agent operates in an attribution gap that makes enforcing true least privilege impossible."
What has already failed
Some of these are attacks or accidents in the wild, some are research demonstrations or disclosed vulnerabilities.
The OpenAI case deserves a closer look, because nobody had to inject anything. During internal cybersecurity evaluations, OpenAI models with certain safeguards disabled got out of their isolated environment. According to OpenAI's technical report of August 2026, "by design, many Research CaaS workloads used the same shared Artifactory credential." From July 8 the agents "exploited a cybersecurity vulnerability in that service to circumvent controls and access the public internet," where they found exposed Hugging Face user credentials. They ended up executing code on 41 Hugging Face production dataset workers, with root on at least one node. The compromise ran from July 11 to 13; OpenAI detected suspicious activity on July 19.
A shared credential, an implicit trust zone, a bypassed egress control and slow detection: all familiar failures. OpenAI's conclusion fits the whole table: "no single control should ever be assumed to be fully robust."
Give the agent an identity of its own
If the agent runs as you, the log says you did it. Revoking its access can also mean revoking your own.
A standard way to express the difference has existed since January 2020. RFC 8693, OAuth 2.0 Token Exchange, defines an act claim to express "that delegation has occurred and identify the acting party," and a may_act claim that says who "is authorized to become the actor." A token can then say: this agent, acting for that person. For access control only the current actor counts; earlier actors in a delegation chain are "informational only."
How to apply that to agents is still being worked out. NIST's NCCoE published a draft concept paper in February 2026 on agent identification, authorization, delegation and logging, and says it will apply SP 800-207. It asks the right questions, among them: "How do we establish 'least privilege' for an agent, especially when its required actions might not be fully predictable when deployed?" At the IETF, the WIMSE working group's agent identity draft reached revision 01 on November 2. It is not a standard yet.
Products are ahead of the standards: Bedrock AgentCore, Okta's Agent SSO, Microsoft Entra Agent ID and Google Cloud Agent Identity all offer forms of agent identity. Okta issues "short-lived, identity-governed tokens in place of stored credentials."
You need none of them to begin. Create a separate principal for each agent, stop sharing service accounts between agents, and make sure you can revoke one without touching the rest.
Keep credentials where the agent can't reach them
A secret in the agent's environment is one prompt injection away from the attacker. Anthropic's Managed Agents post of April 8, 2026 describes its own earlier design that way: "a prompt injection only had to convince Claude to read its own environment."
The fix is an injecting proxy. The agent sends its request without the secret, and a component outside its boundary adds the secret, only for approved destinations. Three current implementations, and one simpler alternative:
- Anthropic Managed Agents keeps MCP OAuth tokens in a vault behind a proxy: "The harness is never made aware of any credentials."
- Claude Code on the web keeps your real GitHub token outside the session's VM; the git client inside holds a scoped credential that the proxy verifies and swaps. Its network secrets do the same for any API, "so the key itself stays outside the VM."
- Claude Code's local sandbox can mask a credential: commands see a per-session placeholder, and the proxy substitutes the real value for hosts you name. It needs the experimental
network.tlsTerminate, and it ignores mask entries in a repository's own.claude/settings.json, so a cloned repo can't decide where your secrets go. - OpenAI Codex cloud takes a simpler route: secrets reach setup scripts only and "are removed before the agent phase starts."
Know what this buys you. It keeps the secret out of the agent's direct reach. It doesn't stop misuse: Anthropic's Managed Agents security docs note that limiting hosts "does not stop the agent from using a credential on a host you allowed." Scope the key at the service that issued it too.
Treat egress as a capability grant
Most of us write an allowlist as a list of places. Anthropic's May containment post explains why that's wrong. "Previously, we'd conceptualized the allowlist as a destination filter," it says. "But it may be better conceptualized as a capability grant. Every function reachable through any domain on an allowlist is now an attack surface."
Anthropic learned that on its own domain: "Allowing api.anthropic.com meant allowing file uploads to arbitrary Anthropic accounts." The destination was approved; the account belonged to whoever supplied the key. The fix was a proxy inside the VM that only passes requests carrying the VM's own session token and rejects a key an attacker planted. The post's verdict on its own component: "Our custom allowlist proxy was the piece that failed."
Ask of every entry on your list: what can be written there, and into whose account? A code host accepts pushes to repositories you don't own. A domain that accepts uploads from any account is, for exfiltration purposes, open egress until something narrows it.
The enforcement has limits too. Claude Code's sandbox proxy decides from the hostname the client supplies, without inspecting TLS; its docs warn that code inside "can potentially use domain fronting" to get out, and point to a TLS-inspecting proxy for stronger guarantees. GitHub says its Copilot cloud agent firewall doesn't directly cover MCP servers beyond its built-in ones, or setup steps, and warns: "Sophisticated attacks may bypass the firewall, potentially allowing unauthorized network access and data exfiltration." Codex cloud blocks the internet during the agent phase by default and suggests limiting requests to GET, HEAD and OPTIONS.
Even "off" needs checking. A Claude Code cloud session with network access disabled can still reach the Anthropic API, "which may allow data to exit the VM." Write down every path that skips your allowlist.
Put permissions outside the model
A rule in a prompt is a request. Claude Code's permissions docs are blunt: "Permission rules are enforced by Claude Code, not by the model." What you write in a prompt or CLAUDE.md shapes what Claude tries; it doesn't change the rules.
An allow rule "can't carve an exception out of a deny rule," and managed settings sit above anything a developer or a repository sets. Hooks are the closest thing to a programmable enforcement point: a PreToolUse hook runs before each tool call, and one that exits with code 2 blocks the call even when an allow rule matches. A hook that returns allow can skip a prompt, but it can't override a deny or ask rule.
Two edges matter:
- Files you reference with
@in a prompt are added without a tool call by default, so noPreToolUsehook fires for them. - In
-pand SDK sessions the folder is treated as trusted, so hooks committed in a repository's settings run. In a headless loop over code you didn't write, those hooks are someone else's code running on your machine.
Auto mode adds two layers, a probe that scans what the agent reads for injection and a classifier that reviews what it does, and since v2.1.283 it is the built-in starting mode for interactive sessions. It's useful. It's also, in the documentation's words, "a per-action control, not an isolation boundary," and Anthropic's engineering post reported in March a 17% miss rate on real overeager actions, calling it "the honest number."
The Roo Code bypass in the table shows why the layer below matters. A permission rule judges a string. A sandbox constrains a process. You want both.
Size the blast radius to the task
Start from the task and ask what the agent could destroy or leak if every decision it made were hostile. Then shrink that.
- Isolate the whole agent when it runs unattended. Claude Code's sandbox covers shell commands only, so its docs say to "always run
--dangerously-skip-permissionssessions inside a container, a VM, or the sandbox runtime," where file tools, MCP servers and hooks are inside the boundary too. Don't mount~/.ssh, cloud credential files or the Docker socket, which, per the sandboxing docs, "effectively grants access to the host system." - Separate development from production. A development agent holds no production credential. A code freeze written into a chat is an instruction, not a control; Replit's fix was "automatic DB dev/prod separation to prevent this categorically."
- One repository per session. That was Invariant Labs' example policy after the GitHub MCP finding. It keeps public input away from unrelated private code.
- Split reading from acting. An agent that triages public issues doesn't need a shell, and it must never share a cache with your release job.
- Enforce pushes on the server. Claude Code's cloud git proxy "doesn't limit which branches a push can update," its docs say, and they send you to branch protection.
Researchers from several labs put the design principle this way in June 2025: once an agent has ingested untrusted input, "it must be constrained so that it is impossible for that input to trigger any consequential actions."
Use MCP's authorization rules, and know where they stop
The current MCP specification, revision 2026-07-28, reads like zero trust for tool connections:
- Resource indicators: clients must name the server a token is for, in both the authorization and the token request.
- Audience validation: servers "MUST validate that access tokens were issued specifically for them."
- No passthrough: "The MCP server MUST NOT pass through the token it received from the MCP client" (security considerations).
- Consent per client: proxy servers with static client IDs must get user consent for each client, the confused-deputy fix.
- Central control: the Enterprise-Managed Authorization extension, listed as Stable, lets the company's identity provider decide which agent reaches which server.
Now the limits. Authorization is optional in MCP, and servers on the stdio transport are told not to follow this part of the spec and to take credentials from the environment. So the rules above don't cover a stdio server on your laptop.
A valid token also says nothing about what a tool claims. In April 2025 Invariant Labs showed that tool descriptions can carry hidden instructions and change after approval. In September, Koi Security found postmark-mcp, an impostor package that had been "quietly copying every email to the developer's personal server." Pin server and tool versions, allowlist servers centrally, and treat descriptions and results as untrusted input.
Record what the agent decided and did
After an incident you'll need three answers: what ran, who allowed it, and on whose behalf.
Claude Code exports OpenTelemetry metrics and events, with traces in beta. The claude_code.tool_decision event records each permission decision with its decision, source, tool_source and a tool_use_id that matches the one hooks receive. Send it somewhere the agent can't write. Keep your proxy's request log next to it, because an accepted command doesn't tell you where the process connected.
For fleets that mix vendors, the OpenTelemetry GenAI conventions define agent and tool spans such as invoke_agent and execute_tool; they are still marked Development, so expect names to move.
What does not count as a boundary
A robust model
Models have improved a lot. The numbers still aren't zero, and they depend on who's attacking.
In January 2025, NIST's AI safety team, now the Center for AI Standards and Innovation (CAISI), raised attack success against an upgraded Claude 3.5 Sonnet from 11% to 81% by writing better attacks. In March 2026 a public competition run by Gray Swan with CAISI and the UK AI Security Institute found success rates from 0.5% to 8.5% across 13 frontier models, and every one was broken at least once.
Anthropic's Claude Opus 5 system card (July 24, 2026) gives vendor numbers for browser use against professional red-teamers. Without safeguards, 3.70% of attempts succeeded. With auto mode, no attack succeeded in any of the 129 scenarios. Opus 4.8 on the same test: 31.5% without safeguards, 0.08% with them.
That's real progress, and it's a score against one set of attacks. In October 2025, a paper on adaptive attacks bypassed 12 published defenses, most of them more than 90% of the time. Most had originally reported near-zero attack success. Anthropic's Managed Agents security docs say it plainly: "model behavior is not a security control."
An approval prompt
Anthropic reported that Claude Code users accept 93% of permission prompts in March 2026 and 97% in August. The August post adds a controlled experiment with 1,053 paid professional testers: "human review caught just 13.6% of dangerous commands, while auto mode caught 89%." These are Anthropic's own measurements.
Meta's Rule of Two falls back on supervision when a session needs all three properties; on these numbers, supervision needs a boundary under it.
A narrow token on its own
Scope every token, then assume the scope is wider than you think. The Managed Agents post again: "Narrow scoping is an obvious mitigation, but this encodes an assumption about what Claude can't do with a limited token—and Claude is getting increasingly smart." Its structural fix was to make the tokens unreachable from the sandbox.
The tenets, translated
The seven tenets come from SP 800-207, shortened. The last row is NSTAC's, as quoted by CISA. The mapping is mine.
My view: the next incident will take a boring path
A clever jailbreak may start the next big agent incident and get the headline. The damage will be decided by what the process could reach: a shared credential, a default role, an allowed domain that does more than anyone listed. Every case in the table exposed a weakness in access or enforcement outside the model.
That's good news, in a way. Prompt injection is an open research problem. Credential hygiene and egress control are engineering work you can start now.
I run some agents in headless loops, where nobody is there to click no. I want to hand an agent a task without having to trust it, so I have to limit what it can do when it goes wrong.
So before you give an agent its next tool, do one exercise. Write down what you'd do with that session if you were the attacker and the agent obeyed every word. Whatever is on that page is what you've granted. Take away what the task doesn't need, and enforce that limit somewhere the model can't edit.