You cannot filter prompt injection out of an AI agent, so you have to design the agent so that a successful injection does little damage. That means deciding which of three capabilities the agent gives up in each session, where a person approves an action, and what you log.
TL;DR and key takeaways
- An injected agent acts. A chat model that is tricked says something wrong. An agent that is tricked sends the email, runs the command or moves the data.
- Filters are not the control. OWASP, the UK’s National Cyber Security Centre and OpenAI all say in writing that prompt injection will not be fully solved.
- Models help, but only partly. Anthropic’s own tests show training and safeguards cut attack success a lot, but not to zero.
- Drop one of three. Meta’s Agents Rule of Two: a session should not combine untrusted input, private data and the power to act, unless a person approves.
- Build controls outside the model. Least privilege, human approval, separated content, protected permission files, full logs and adaptive testing.
If you are wondering how this differs from bad context building up over a long session, that is a separate problem covered in our post on context poisoning.
Why an agent turns an injection into an action
Prompt injection is text that changes what a model does. OWASP’s LLM01:2025 entry splits it into direct injection, typed by the user, and indirect injection, hidden in content the model reads, such as a web page, an email or a file.
For an agent, indirect injection is the one that matters. The agent reads content as part of its job, and its output drives tools. So an injected instruction does not stay in the chat window: it becomes a tool call.
OWASP now treats this as the top agent risk. Its Top 10 for Agentic Applications, published 9 December 2025, lists Agent Goal Hijack as ASI01, ahead of tool misuse and identity and privilege abuse.
A real case shows the shape. In Embrace The Red’s disclosure of CVE-2025-53773 on 12 August 2025, instructions hidden in content GitHub Copilot read made it switch on its own auto-approve setting. After that it could run shell commands without asking. Our roundup of AI agent security incidents covers that case and seven others.
Why filters will not save you
The people who build and regulate these systems now say in writing that prompt injection will not go away.
The UK National Cyber Security Centre wrote on 8 December 2025 that “Current large language models (LLMs) simply do not enforce a security boundary between instructions and data inside a prompt.” It calls the model an “inherently confusable deputy” and advises against relying on blocklists. This is UK government guidance, and it reads well for anyone.
OWASP’s LLM01 entry agrees: “it is unclear if there are fool-proof methods of prevention for prompt injection.”
OpenAI wrote on 22 December 2025 that prompt injection “is unlikely to ever be fully ‘solved’.” That came from a company shipping a browser agent.
The research backs this up. Nasr, Carlini and co-authors (arXiv 2510.09023, 10 October 2025) tested 12 published defences against adaptive attacks and bypassed most of them with attack success above 90%. Many of those defences had originally reported near-zero attack success.
The lesson: a defence that passes a fixed test set tells you little about an attacker who adapts.
What the model can and cannot do for you
Model training lowers the success rate of injection attacks a lot, but not to zero. Treat it as one layer, not as the control.
Anthropic published browser-use results on 24 November 2025 against its own adaptive attacker, which got 100 attempts per environment. Claude Opus 4.5 was attacked successfully 8.0% of the time with the model alone, and 1.4% with Anthropic’s improved safeguards. Claude Sonnet 4.5 went from 13.8% to 1.9%.
Source: Anthropic, “Mitigating the risk of prompt injections in browser use”, 24 Nov 2025 (Anthropic’s own internal test). Chart by HorizonLux.
Anthropic is clear about what that means. In its words, a 1% attack success rate, while a significant improvement, “still represents meaningful risk.” For an agent that reads untrusted content all day, that remaining risk adds up.
These are Anthropic’s own numbers from its own test. No vendor-neutral, dated measurement of injection rates in production agents exists that we could find, so treat any claimed rate as specific to the test that produced it.
Drop one of three: the Agents Rule of Two
Since you cannot stop every injection, limit what an injected agent can reach. Meta’s Agents Rule of Two, published 31 October 2025, gives a simple test. A session can have at most two of these three properties:
- [A] it processes untrustworthy inputs,
- [B] it can access sensitive systems or private data,
- [C] it can change state or communicate externally.
If a task needs all three, Meta says the agent should not run on its own. It needs oversight, such as a person approving its actions, or the work moves to a new session with a fresh context.
Source: Meta, “Agents Rule of Two: a practical approach to AI agent security”, 31 Oct 2025. Chart by HorizonLux.
Which capability to drop, by agent type
The table applies Meta’s rule to five common agents. It is our reading of the rule, not Meta’s.
| Agent | A: untrusted input | B: private data | C: acts or talks out | What to drop | Where a person approves |
|---|---|---|---|---|---|
| Email assistant | Yes, every inbound email | Yes, the inbox | Sending mail | C: draft, do not send | Before any email goes out |
| Browser agent | Yes, every web page | Logged-in sessions | Forms, purchases | B: run in a clean profile | Before any submit or payment |
| Coding agent | Issues, PRs, dependencies | Repo and secrets | Shell, push, deploy | C for shell and network | Before commands, pushes, installs |
| Support agent | Yes, customer messages | Customer records | Refunds, account changes | C for money and accounts | Before refunds or changes |
| MCP-connected internal tool | Tool outputs, documents | Internal systems | Writes through tools | A: trusted sources only | Before writes to shared systems |
The controls, in the order to build them
The controls that hold are deterministic and sit outside the model. Build them in this order.
Source: OWASP LLM01:2025, UK NCSC (8 Dec 2025), Meta (31 Oct 2025), arXiv 2510.09023. Chart by HorizonLux.
Least privilege for tools
Scope every tool and token to the task in front of the agent. OWASP’s LLM01 mitigation list puts it as “Enforce privilege control and least privilege access.” An agent that can only read one folder cannot leak the rest. For MCP servers, our post on MCP OAuth security covers scopes in detail, and MCP vs function calling covers where each tool boundary sits.
Human approval for high-risk actions
Both OWASP and Meta call for a person to approve actions that are hard to undo: sending, paying, deleting, deploying. Keep the approval list short, so people read each request instead of clicking yes by habit.
Mark and separate external content
OWASP advises you to “Segregate and identify external content,” so the model and your code both know what came from outside. The NCSC is clear that this makes attacks harder, not impossible. Use it, but do not rely on it alone.
Agents must not edit their own permissions
CVE-2025-53773 worked because the agent could write the file that set its own permissions. Make settings, hooks and allowlists read-only to the agent, and review every change to them by hand.
Log inputs, outputs and every tool call
The NCSC’s 8 December 2025 guidance recommends logging enough to spot suspicious activity, potentially the full input and output of the model, and says failed tool or API calls can reveal the early stages of an attack. Log every tool call too: it is how you answer “what did it touch?” after an incident.
Test with adaptive attacks, not a fixed prompt list
OWASP lists “Conduct adversarial testing.” The arXiv 2510.09023 results show why it has to be adaptive: defences that scored near zero on fixed tests fell to attacks that adjusted. Rerun the tests whenever you add a tool or change the model.
If you are building an agent with real tools and want these controls designed in from the start, that is what our AI agent development work covers. To see where an existing rollout stands, run the AI governance check.
For coding agents in particular, Day 10 of our Claude Code Challenge shows how to set up the sandbox and permission rules in Claude Code.
Frequently asked questions
Can prompt injection be fully prevented?
No. OWASP says it is unclear whether fool-proof prevention exists, the UK NCSC says current models do not enforce a boundary between instructions and data, and OpenAI says it is unlikely ever to be fully solved. Design so a successful injection does limited damage.
What is indirect prompt injection in an AI agent?
It is an instruction hidden in content the agent reads as part of its task, such as a web page, an email, a file or a tool result. The user never sees it. Because the agent’s output drives tools, the hidden instruction can turn into a real action.
What is the Agents Rule of Two?
It is Meta’s rule, published 31 October 2025, that an agent session should combine at most two of three things: untrusted input, access to private data, and the ability to change state or communicate externally. If it needs all three, a person approves or the context is reset.
Do guardrail products stop prompt injection?
They lower the rate, but they do not stop it. A 2025 study by Nasr, Carlini and others bypassed 12 published defences with adaptive attacks, mostly at above 90% success. Use guardrails as one layer, behind least privilege and human approval.
How do I protect a coding agent like Claude Code or Copilot from prompt injection?
Keep the agent from editing its own settings, require approval for shell commands, pushes and installs, and run it without production secrets in reach. Treat issues, pull requests and dependencies as untrusted input, and log every command it runs.
Sources
- OWASP GenAI Security Project, “LLM01:2025 Prompt Injection”, 2025 list (no page date), https://genai.owasp.org/llmrisk/llm01-prompt-injection/
- OWASP GenAI Security Project, “OWASP Top 10 for Agentic Applications”, 9 Dec 2025, https://genai.owasp.org/2025/12/09/owasp-top-10-for-agentic-applications-the-benchmark-for-agentic-security-in-the-age-of-autonomous-ai
- UK National Cyber Security Centre, “Prompt injection is not SQL injection (it may be worse)”, 8 Dec 2025, https://www.ncsc.gov.uk/blog-post/prompt-injection-is-not-sql-injection
- OpenAI, “Continuously hardening ChatGPT Atlas against prompt injection attacks”, 22 Dec 2025, https://openai.com/index/hardening-atlas-against-prompt-injection/
- Nasr, Carlini et al., adaptive attacks against LLM defences, arXiv 2510.09023, 10 Oct 2025, https://arxiv.org/abs/2510.09023
- Anthropic, “Mitigating the risk of prompt injections in browser use”, 24 Nov 2025, https://www.anthropic.com/research/prompt-injection-defenses
- Meta AI, “Agents Rule of Two: a practical approach to AI agent security”, 31 Oct 2025, https://ai.meta.com/blog/practical-ai-agent-security/
- Embrace The Red, “GitHub Copilot: remote code execution via prompt injection” (CVE-2025-53773), 12 Aug 2025, https://embracethered.com/blog/posts/2025/github-copilot-remote-code-execution-via-prompt-injection
Notes on sources:
- ASI01 “Agent Goal Hijack” was confirmed on the OWASP announcement page on 26 Nov 2026; the PDF itself was not opened.
- Anthropic’s figures were re-read on 26 Nov 2026 from the chart’s alt text, including Sonnet 4 (13.8% to 2.0%) and Haiku 4.5 (12.0% to 2.4%). Its 1% quote uses a dash in the original, so the post paraphrases the first half and quotes only the end.
- Simon Willison’s “lethal trifecta” (June 2025), the idea Meta builds on, was not opened, so it is not cited.






