Updated October 2026 with newer research and the lessons from real agent incidents.
You shipped an AI feature. It answers customer questions, summarises documents or automates a workflow, and it works beautifully, until someone types "ignore all previous instructions", or until your assistant reads an email that does it for them.
Prompt injection is the #1 risk in the OWASP Top 10 for LLM Applications, and it is not going away. Language models follow instructions from whatever text lands in their context window, and they cannot reliably tell your instructions from an attacker's. Unlike SQL injection, there is no parameterised query that fixes it.
What does work is defense in depth: several imperfect layers that together make attacks hard and contain the damage when one gets through. Here are seven, in roughly the order you should build them.
1. Least Privilege: Limit What the Model Can Do
Start here, because it limits the damage of every other failure.
- A FAQ bot does not need database write access.
- A document summariser does not need to send email.
- A browsing agent should run in a sandbox with no access to local files or credentials.
Implementation patterns:
- Brokered actions: the model never calls APIs directly. It requests an action, and middleware checks the request against an allowlist and the user's own permissions.
- Read-only by default: start with zero permissions and add only what a feature needs.
- Break the lethal trifecta: avoid giving one agent private data, untrusted content and a way to send data out all at once. In May 2025, a malicious GitHub issue steered an AI agent with exactly that combination into leaking private repositories through a public pull request.
Least privilege does not stop injection. It decides whether a successful injection is an embarrassment or a breach.
2. Separate Trusted Instructions from Untrusted Data
Most serious incidents (Slack AI in 2024, Microsoft 365 Copilot's "EchoLeak" in 2025) were indirect injection: instructions hidden in content the model retrieved.
