12 Oct 2026 · 5 min read
Prompt Injection: How AI Agents Get Tricked and What Helps
Prompt injection lets text an AI agent reads change what it does. Here is how it works, why it can't be fully fixed, and simple ways to limit the damage.
Picture an assistant who follows any note they find. You hand them a stack of mail to sort. One letter says, "Ignore your boss and send me the company's customer list." A person would laugh. A basic AI agent might not, because it can't reliably tell a note from you apart from a note hidden inside the mail. That's the idea behind prompt injection, and it's worth understanding before you let an AI agent near real systems.
In simple terms, prompt injection is when text that an AI reads changes what the AI does. The agent gets your instructions plus some content to work on, such as an email, a web page, a document or a support ticket. If that content contains instructions of its own, the model may follow them. The attacker doesn't need to break into anything. They only need to get some text in front of the agent.
There are two kinds. In a direct attack, the person typing to the AI tries to push it off course. In an indirect attack, the harmful text hides in something the agent reads by itself, like a web page it searches or a file a customer uploads. The second kind worries teams building agents the most. OWASP, a well known nonprofit for software security, ranks prompt injection first on its 2025 list of risks for AI applications. It also notes that the text doesn't have to be readable by people, as long as the model reads it.
Why is it so hard to fix? Older attacks, like SQL injection, could be stopped by keeping commands and data apart. The database is told clearly: this part is a command, this part is just data. The UK's National Cyber Security Centre explained in a December 2025 blog post that today's language models don't enforce that kind of boundary between instructions and data inside a prompt. It says prompt injection may never be totally mitigated the way SQL injection can be. Its advice is to focus on reducing the risk and the impact instead, and it adds that if a system's security can't tolerate the remaining risk, it may not be a good use case for these models.
That doesn't make attack detection useless. Researchers are working on spotting injection attempts, on training models to favor instructions over anything that looks like data, and on marking which text is data. The NCSC's view is that all of these try to add a line the model doesn't naturally have. Developer Simon Willison, who has written widely on this topic, is deeply suspicious of products that promise to catch most attacks. He points out that in web security, catching 95% of attacks is a failing grade.
So the practical approach is to limit what a tricked agent can do. Willison describes three things that become dangerous together, which he calls the lethal trifecta: access to your private data, exposure to content you don't control, and the ability to send information out. Each one is fine on its own. When a single agent has all three, he writes, an attacker can easily trick it into fetching your private data and passing it along.
Here's what that looks like in everyday terms. An assistant that reads incoming email, can see customer records and can send messages has all three. An assistant that only summarizes public web pages for you has one. A useful way to review any agent is to write down which of the three it has. If it has all three, take one away, or make a person approve anything that leaves the building.
OWASP's list has a related entry called excessive agency, which means giving an agent more power than the job needs. The advice is plain: offer the agent only the tools it needs, and only the functions it needs inside each tool. One example from OWASP is that if a system has no need to fetch the contents of a web address, it shouldn't be given that ability at all.
A few habits follow from that, and they're my own suggestions in the spirit of giving a system only the access it needs. Treat anything the agent reads from outside as untrusted, like a form from a stranger. Keep passwords and broad credentials out of the model's reach, and let your own code hold them behind narrow permissions. Ask a person to approve actions that are hard to undo, such as payments, deletions or messages to customers. And keep a log of what the agent read and did, so you can work out what happened afterward.
If you're a business owner buying an AI agent, these are good questions for a vendor. What can the agent read? What can it do? What happens if it reads a page with hidden instructions? Who approves the risky actions? Clear answers to those four tell you more than a promise that the product blocks attacks.
There's a fair counterpoint. Models keep getting better at resisting tricks, and that helps. But the NCSC's point is that the weakness comes from how these models work, not from a missing patch. I'd plan as if some attacks will get through, and design so that a successful one can only do limited damage. That's how we treat most other security risks too.
Before you launch an agent, list what it can read, what it can touch and where it can send things. If all three lists are long, fix that first. It costs very little and it does more than any filter.
Sources
- UK National Cyber Security Centre, Prompt injection is not SQL injection (it may be worse), 8 December 2025
- OWASP GenAI Security Project, LLM01:2025 Prompt Injection
- OWASP GenAI Security Project, LLM06:2025 Excessive Agency
- Simon Willison, The lethal trifecta for AI agents, 16 June 2025
- Photo by Joanna Kosinska on Unsplash