The mechanism
A language model gets one stream of tokens. The system prompt, the user's request, a retrieved web page and a tool's JSON result all arrive in that stream, and nothing in the model's architecture marks one part as instructions and another as data. NIST's taxonomy of attacks (AI 100-2 E2025) puts it as "Because GenAI models combine the data and instruction channels, attackers can leverage the data channel to affect system operations". Greshake et al.'s 2023 paper on indirect prompt injection, which attacked Bing's GPT-4 powered Chat, says the same thing: "LLM-Integrated Applications blur the line between data and instructions."
Direct and indirect
OWASP's Top 10 for LLM Applications (2025) lists prompt injection first, as LLM01, and splits it in two:
- Direct: "a user's prompt input directly alters the behavior of the model." The attacker is the person typing. For an agent this matters mostly when the user is not the owner of the data or tools, such as a support bot with access to other customers' records.
- Indirect: "Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files." NIST adds that these attacks are mounted "not by the primary user of a model but instead by a third party", and that "it is the primary user of the model who is harmed".
For agents with tools, indirect injection is the one that matters. The attacker does not need an account. They need to put text somewhere your agent will read it: an email, a GitHub issue, a web page, a PDF, a calendar invite, a code comment, a tool description.
Why a better prompt does not fix it
Every mitigation that works inside the model is probabilistic, and the attacker gets as many attempts as they can plant documents.
- OWASP's first listed mitigation is to constrain behaviour in the system prompt, but the same page introduces its mitigations with: "Given the stochastic influence at the heart of the way models work, it is unclear if there are fool-proof methods of prevention for prompt injection."
- NIST lists training, detectors and input processing ("spotlighting", instructing models to disregard instructions in data), then concludes: "Because current mitigations do not offer full protection against all attacker techniques, application designers may design systems with the assumption that prompt injection attacks are possible if a model is exposed to untrusted input sources".
- Anthropic reports its own numbers for Claude in Chrome. Its general-availability post (26 August 2026) says that on a harder set of attacks from professional red-teamers, attacks that reached the model succeeded against Opus 5 "3.8% of the time" before additional safeguards; with probes and a safety classifier, none succeeded against Claude Sonnet 5, Opus 5 or Mythos 5, and Fable 5 showed "a 0.3% attack success rate". Its conclusion: "Prompt injection remains a moving target." These are vendor-reported internal tests. In its 2025 pilot, before system-prompt, site-blocking and classifier mitigations, a test email "claiming that, for security reasons, emails needed to be deleted" got the agent to delete the user's emails "without confirmation." (Disclosure: Development Radio is made with Claude, Anthropic's model.)
- Simon Willison, who coined the term "prompt injection", notes that guardrail products "almost always carry confident claims that they capture '95% of attacks' or similar... but in web application security 95% is very much a failing grade."
- The CaMeL paper (Debenedetti et al., 2025) answers its own question, "So, Are Prompt Injections Solved Now?", with "No, prompt injection attacks are not fully solved."
So the permission boundary cannot sit in the prompt. It has to sit in code that runs after the model has decided what to do, and that code has to assume the model may have been taken over by anything it has read.
The lethal trifecta
Willison's June 2025 post names the combination that turns an injection into a data theft. An agent is exposed when one session has all three of:
- "Access to your private data"
- "Exposure to untrusted content"
- "The ability to externally communicate in a way that could be used to steal your data"
His advice for anyone combining tools: "The only way to stay safe there is to avoid that lethal trifecta combination entirely." "Externally communicate" is wider than a send-email tool: it includes creating a public pull request, fetching a URL with data in the query string, and a chat client rendering a Markdown image from a model-written URL.
Steps as text
- Attacker plants text: Email, issue, web page or file the agent reads
- Agent retrieves it: Tool result enters the same context as the task
- Model follows it: Read as an instruction, not as data (where it breaks)
- Reads private data: With the user's own tool permissions
- Sends it out: PR, email, fetched URL or auto-loaded image
Defences that change the outcome
Least-privilege tools. OWASP: "Restrict the model's access privileges to the minimum necessary for its intended operations." In practice this means credentials scoped to the task, not to the user. Invariant Labs' suggested mitigation for the GitHub MCP attack below, written for its own Guardrails product, is a policy that "restricts an agent to working with only one repository per session". Anthropic's cloud Claude Code sessions get "a short-lived credential scoped to that session", and a proxy rejects branch deletions and pushes of anything but a branch.
Human confirmation on side effects. OWASP: "Implement human-in-the-loop controls for privileged operations". Two conditions make this a boundary rather than a ritual. The confirmation must be enforced by the tool runtime, outside anything the agent can edit (see the Copilot incident below). And it must show the actual effect, such as the recipient, the full URL or the diff, because a model-written summary of the action is itself attacker-controlled text. Too many prompts defeat it: Claude Code's docs list "Prompt fatigue mitigation" through allowlists as a feature, and every allowlist entry is a side effect you no longer see.
Separate trusted instructions from untrusted data. OWASP: "Separate and clearly denote untrusted content to limit its influence on user prompts." Delimiters, spotlighting and "ignore instructions in documents" lower the success rate against known attacks. They are worth having, but they are hints to the model, not a boundary.
Dual LLM and CaMeL. Willison's dual LLM pattern (April 2023) splits the agent. A privileged LLM plans and calls tools but never sees untrusted text. A quarantined LLM reads untrusted text, "does not have access to tools, and is expected to have the potential to go rogue at any moment." Ordinary code, the controller, passes results around as references such as $VAR1, so "The Privileged LLM only ever sees those variable names." Willison's own verdict, under the heading "This solution is pretty bad", is that it adds complexity and that "The social engineering aspects also mean that this isn't a 100% reliable solution." CaMeL makes this rigorous: the privileged model writes a Python program from the user's trusted request; a custom interpreter runs it, calls the quarantined model to parse untrusted data, tracks which values each variable depends on, and checks security policies before every tool call. The refusing is done by a policy written for each tool: the paper's send_email policy requires that "Recipients must come from the user", so a recipient taken from an untrusted email is refused, and in a real deployment, the paper says, a violation "will require user confirmation" instead of being blocked. The paper is explicit about what remains: section 7 is titled "Side Channels Can Be a Problem", and section 9.3 says CaMeL "suffers from users needing to codify and specify security policies and maintain them."
Steps as text
- User → Privileged LLM: Task, in trusted words
- Privileged LLM → Interpreter: Plan as code; sees no tool output
- Interpreter → Quarantined LLM: Untrusted email: extract the date
- Quarantined LLM → Interpreter: Untrusted value back; it has no tools
- Interpreter → User: Policy check: ask before send_email
Beurer-Kellner et al. (2025), a group of 14 authors that includes CaMeL's Debenedetti and Tramèr, generalise this into six patterns: action-selector, plan-then-execute, LLM map-reduce, dual LLM, code-then-execute and context-minimization. Their shared principle: "once an LLM agent has ingested untrusted input, it must be constrained so that it is impossible for that input to trigger any consequential actions". They are also blunt about the limit: "securing general-purpose agents remains out of reach with current capabilities", while "application-specific agents can be secured through principled system design."
Output egress controls. If the agent cannot send data anywhere the attacker can read it, an injection can still do damage but cannot steal. Egress has to be controlled where the bytes leave: the network sandbox, the client that renders Markdown, the tool that fetches URLs. Claude Code, for example, prompts before curl and wget by default in its Manual mode, and its docs say a deny rule "matches the command as written"; for enforcement that does not depend on the command text they point to sandbox network isolation. An allowlist by domain is weaker than it looks: EchoLeak, below, left through a Microsoft domain that the content security policy allowed.
Worked numbers
The CaMeL paper compares defences on AgentDojo, a benchmark of agent tasks with injected tool results, using Claude 3.5 Sonnet and 949 attacks:
Data as text
| Successful attacks (attacks) | |
|---|---|
| No defence | 44 |
| Prompt sandwiching | 24 |
| Tool filter | 8 |
| Spotlighting | 5 |
| CaMeL | 0 |
Two cautions from the same paper. The baseline model is "already not particularly vulnerable to AgentDojo's default prompt attack", and the paper cites US AISI work showing that "when attacked with adaptive prompts, the robustness of Claude 3.5 Sonnet drops drastically". A fixed benchmark measures the attacks someone already wrote. And the design boundary costs utility: in table 5, the same model completes 90.72% of tasks undefended and 63.92% under CaMeL, with the Travel suite down to 25%. Section 6.5 reports 2.82 times the input tokens and 2.73 times the output tokens of native tool calling for the median task, counted with GPT-4o's tokenizer; its appendix tables give other medians (2.02 and 2.64 under attack), so read it as roughly two to three times. The abstract's headline, with newer models, is 77% of tasks "with provable security (compared to 84% with an undefended system)".
Why a rate is not a boundary (illustrative). Assume each planted document independently succeeds with probability p. With p = 11.2%, the rate Anthropic reported for its 2025 pilot after mitigations, an attacker who gets ten documents in front of the agent succeeds at least once with probability 1 − 0.888^10 ≈ 69.5%. With p = 1% and a hundred documents, 1 − 0.99^100 ≈ 63.4%. Even at the 0.3% Anthropic reports for Fable 5 in 2026, a hundred documents give 1 − 0.997^100 ≈ 25.9%. Independence is generous to the defender, because attackers iterate on what works. Model-level defences change how many attempts an attacker needs; permissions and egress controls change what a successful attempt can do.
Data as text
| p = 11.2% (%) | p = 1% (%) | |
|---|---|---|
| 1 | 11.2 | 1 |
| 5 | 44.8 | 4.9 |
| 10 | 69.5 | 9.6 |
| 20 | 90.7 | 18.2 |
| 50 | 99.7 | 39.5 |
| 100 | 100 | 63.4 |
How it fails
- GitHub MCP server, private repositories leaked through a public issue (disclosed 26 May 2025). Invariant Labs showed that a malicious issue in a public repository could "hijack a user's agent via a malicious GitHub Issue, and coerce it into leaking data from private repositories." In the demo, the user asks Claude 4 Opus in Claude Desktop to look at the public repository's issues. The agent follows the injected instructions, reads the user's private repositories with the user's token, and writes their contents into a pull request on the public repository. All three legs of the trifecta came from one token. Invariant: "this is not a flaw in the GitHub MCP server code itself", so no server patch fixes it. Scoping the session to one repository blocks this cross-repository leak, though not an injection that acts within that one repository.
- EchoLeak, Microsoft 365 Copilot, CVE-2025-32711 (advisory 11 June 2025). Microsoft scored it CVSS 9.3. According to a case study by Reddy and Gujral of George Washington University (Aim Labs found the flaw), one "single crafted email" was enough, with no user interaction: the attack chained "evading Microsoft's XPIA (Cross Prompt Injection Attempt) classifier, circumventing link redaction with reference-style Markdown, exploiting auto-fetched images, and abusing a Microsoft Teams proxy allowed by the content security policy". Aim Labs reported it to Microsoft in January 2025, and it was fixed server-side in May; the case study says "Microsoft stated that no customer action was required and there was no evidence of in-the-wild exploitation." Each bypass defeated one layer: the classifier, the output filter, and the egress allowlist. Aim Labs called the class an "LLM Scope Violation".
- GitHub Copilot in VS Code and Visual Studio, CVE-2025-53773 (published 12 August 2025, CVSS 7.8). A post on the Embrace The Red blog showed that an injection in content Copilot reads could make it add
"chat.tools.autoApprove": trueto the project's.vscode/settings.json, which "will put GitHub Copilot in YOLO mode", disabling confirmations so it could run shell commands. It was reported on 29 June 2025; Microsoft said it was already tracking the issue, and "With the August Patch Tuesday release this is now fixed." The post's summary: "AI that can set its own permissions and configuration settings is wild!" The confirmation step existed, but the switch that turned it off was inside the agent's write scope.
Willison's trifecta post lists more than a dozen products with exfiltration bugs of this shape, from ChatGPT in April 2023 to ChatGPT Operator in February 2025, including Slack, Amazon Q, Google NotebookLM, GitHub Copilot Chat and Anthropic's Claude iOS app.
Our episodes This Certificate Authority's Private Key Was the Number 4 and AI Got Faster This Week. Every Story Still Came Down to a Person. cover the same boundary from another side: coding agents that changed the monitoring meant to watch them. Config that governs an agent should not be writable by that agent.
Decision table
| Option | What it costs | Choose it when |
|---|---|---|
| System-prompt rules, delimiters, spotlighting | Almost nothing; lowers success against known attacks only | Always, as a layer; never as the boundary |
| Injection classifier on inputs | Latency, false positives; bypassable (EchoLeak evaded XPIA) | You want detection and telemetry, in addition to controls in code |
| Least-privilege, per-session credentials | Token plumbing; more, narrower tools | Always; scope to the task (one repository, one mailbox folder), not the user |
| Confirmation enforced by the runtime | User attention; fatigue grows with every prompt | Any irreversible or outward side effect: send, publish, pay, delete, merge |
| Agent cannot write its own config | Policy files and code owners for agent settings | Always; covers .vscode, .claude, .mcp.json, CI and alerting config |
| Egress controls (network sandbox, no auto-loaded model URLs, exact-URL allowlists) | Breaks some integrations; allowlists need upkeep | The agent can read private data; often the easiest leg of the trifecta to remove |
| Split sessions so no session holds all three trifecta legs | More orchestration; some tasks no longer fit one agent | Agents that read untrusted content and hold private data |
| Plan-then-execute or action-selector | Less flexibility; the plan is fixed before untrusted data arrives, but in plan-then-execute injected text can still change a call's arguments, such as an email body | Workflows with a known shape: triage, routing, form filling; check arguments as well as the plan |
| Dual LLM or CaMeL-style interpreter | Large build cost; 90.72% to 63.92% task completion in the paper's Claude 3.5 Sonnet runs; roughly 2 to 3 times the tokens for the median task; policies to write and maintain | High-value agents that must read untrusted data and act on private data |
A check you can run this week
List every agent and MCP server your team runs, and for each one fill in three columns per session: does it read private data, does it read content an outsider can write, and can it send anything outward, including a pull request, an email, a fetched URL or a rendered image. Any row with three yeses is a finding, whatever its prompt says.
Then check whether any agent can rewrite its own permissions. In each repository an agent works in:
git ls-files --cached --others | grep -E '(^|/)(\.vscode/settings\.json|\.claude/|\.mcp\.json|\.cursor/|\.github/workflows/|\.github/copilot-instructions\.md|CLAUDE\.md|AGENTS\.md)'--others adds untracked files, but an agent that can write the workspace can also create any of these paths, so treat each path as in scope even when nothing matches. For every file that matches, ask: can the agent's tools write it without a human approving that specific diff? If yes, put it under code owners, deny writes to it in the agent's permission rules, or block it with a hook. Claude Code's ConfigChange hooks run only when its own settings, managed policy or skill files change, so cover .vscode, .mcp.json, .cursor, instruction and workflow files with code owners or a PreToolUse hook that denies edits to those paths.
Sources
The primary sources this guide was checked against.
- OWASP Top 10 for LLM Applications 2025: LLM01 Prompt Injection
- NIST AI 100-2 E2025: Adversarial Machine Learning, A Taxonomy and Terminology of Attacks and Mitigations (March 2025)
- Greshake et al.: Not what you've signed up for, Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection (2023)
- Debenedetti et al.: Defeating Prompt Injections by Design (CaMeL, 2025)
- Beurer-Kellner et al.: Design Patterns for Securing LLM Agents against Prompt Injections (2025)
- Simon Willison: The Dual LLM pattern for building AI assistants that can resist prompt injection (April 2023)
- Simon Willison: The lethal trifecta for AI agents (June 2025)
- Invariant Labs: GitHub MCP exploited, accessing private repositories via MCP (26 May 2025)
- Reddy and Gujral: EchoLeak, the first real-world zero-click prompt injection exploit in a production LLM system (2025)
- NVD: CVE-2025-32711, Microsoft 365 Copilot AI command injection
- Embrace The Red: GitHub Copilot remote code execution via prompt injection (CVE-2025-53773)
- NVD: CVE-2025-53773, GitHub Copilot and Visual Studio command injection
- Anthropic: Piloting Claude in Chrome (25 August 2025)
- Anthropic: Claude in Chrome is generally available (26 August 2026)
- Claude Code documentation: Security (permissions, prompt injection, cloud execution)
Hear it discussed
Episodes of the show that work through this decision.