The standard agent loop is a security hole. Most tutorials paste tool outputs directly into the message history as if they are safe return values. They are not. They are untrusted text from external sources, injected into the same context window as your system prompt. There is no type system telling the model that this chunk is data, not command. If the model follows an instruction hidden in a web page or a GitHub issue, it isn't a bug. It is the architecture working as designed.

The OWASP Ranking Has Not Changed

Prompt injection remains LLM01 in the OWASP Top 10 for LLM Applications 2025. The organization explicitly states that fool-proof prevention is unclear due to the stochastic nature of models. For agents, the risk is indirect injection: an attacker does not need to be your user. They only need to write a comment, a README, or a product description that your agent eventually reads. In December 2025, OWASP released a separate Top 10 for Agentic Applications, where "Agent Goal Hijack" (ASI01) is the top entry. The framing shifted from the model saying something bad to the agent doing something bad.

Detection Alone Loses to Adaptive Attacks

Teams often reach for classifiers or delimiters to wrap untrusted text. Microsoft's datamarking technique, which interleaves a marker character between words, reduced attack success from over 50% to below 2% in controlled experiments. But security is adversarial. In October 2025, Nasr, Carlini, and co-authors published "The Attacker Moves Second," demonstrating that adaptive attacks bypassed 12 recent defenses with success rates above 90% for most. As Simon Willison noted, a 95% catch rate is a failing grade in web security. Nobody would ship a SQL escaping function that works 95% of the time, and you should not ship an agent guardrail that does.

The Lethal Trifecta and the Rule of Two

In June 2025, Simon Willison identified the lethal trifecta: access to private data, exposure to untrusted content, and the ability to externally communicate. Any agent with all three can be tricked into exfiltrating data. Meta formalized this in October 2025 with the Agents Rule of Two, stating an agent should have at most two of these properties to operate autonomously. The pattern is mechanical and auditable. For example, a fetch_url tool often carries two properties: untrusted input and external effect. A URL query string is an exfiltration channel. If your agent reads a public repo and writes to a private one, you have the trifecta. Invariant Labs demonstrated this in May 2025 against the GitHub MCP server, where a highly aligned model exfiltrated private repo data via a public issue comment.

Structural Defenses Over Prompt Engineering

The solution is not better prompting. It is architectural separation. The June 2025 paper "Design Patterns for Securing LLM Agents against Prompt Injections" catalogs six patterns where injection cannot reach consequential actions. The most robust are Dual LLM and Code-Then-Execute. The Dual LLM pattern, proposed by Willison in 2023, uses a privileged model that never sees untrusted text and a quarantined model that has no tool access. A controller passes data between them using variable references, not raw text. If the quarantined model is compromised, it can only return a validated schema, like a JSON email address, not an instruction to forward the inbox. CaMeL, published in March 2025, extends this by having the privileged model write a restricted program that the interpreter executes with taint tracking, ensuring control flow remains immune to data poisoning.

Key Takeaways

  • Tool outputs are untrusted input; treat them like SQL strings, not return values.
  • Detection mechanisms are probabilistic and bypassable by adaptive attackers.
  • Implement the Rule of Two: limit agents to two of {untrusted input, private data, external effect}.
  • Move dangerous parameters like recipients and URLs out of the model's reach and into server-side logic.
  • Use architectural patterns like Dual LLM to separate control flow from data flow.

The Bottom Line

Stop trying to teach the model to ignore malicious instructions and start building systems where those instructions have no power. Architectural separation, not prompt engineering, is the only scalable defense against agent injection.