Prompt Injection Explained: Why AI Agents Can Be Tricked and How to Limit the Damage

If you are connecting an AI model to your email, documents, CRM or code repository, the first attack to understand is prompt injection. It has been at the top of OWASP’s Top 10 for Large Language Model Applications since the list was created, and the 2026 edition keeps it at number one.

What prompt injection is

A language model receives one long stream of text: your instructions, the user’s question, and whatever content it has been asked to read, such as a web page, an email, a PDF or a tool result. The model has no reliable way to tell which parts of that text are instructions and which parts are data.

Prompt injection exploits that gap. An attacker places instructions inside content the model will read, and the model follows them as if they came from you. It comes in two forms.

In direct injection, the user types the malicious instruction themselves (“ignore your previous instructions and…”). This mostly matters for public chatbots. In indirect injection, the instruction is hidden in content the AI processes on someone else’s behalf: an email in your inbox, a comment in a shared document, white-on-white text on a web page. Indirect injection is the dangerous one, because the victim never sees the instruction.

A real example: EchoLeak

In June 2025, researchers disclosed EchoLeak (CVE-2025-32711), a zero-click attack on Microsoft 365 Copilot. The attacker sent an ordinary-looking email containing hidden instructions. When the victim later asked Copilot a routine question, Copilot retrieved that email as context, followed the hidden instructions, and leaked internal data to an attacker-controlled address. The victim didn’t have to click anything. Microsoft fixed it on the server side, but the same combination of untrusted content, access to private data and a way to send data out shows up in plenty of other products.

Why agents make it worse

Prompt injection can embarrass a chatbot that only replies with text. An agent that can send email, call APIs, edit files or run code can be turned against its owner. OWASP published a separate Top 10 for Agentic Applications in December 2025 with “agent goal hijack” as its first entry, and the 2026 LLM list moved excessive agency (giving a model more permissions than it needs) up to third place.

Why you can’t just patch it

SQL injection was largely solved by separating code from data with parameterised queries. Language models have no equivalent separation, because instructions and data travel in the same channel. Filters and “guardrail” models help, but researchers keep showing that adaptive attackers get around them. OWASP’s own guidance is to assume the boundary will be bypassed and to design so that a successful injection does limited harm.

How to limit the damage

  1. Give each agent only the tools and data scopes its task requires. A summarisation agent doesn’t need permission to send email.
  2. Require a person to click “approve” for irreversible actions: payments, deletions, external emails and permission changes.
  3. Avoid what Simon Willison calls the “lethal trifecta”. The worst cases combine access to private data, exposure to untrusted content and a way to communicate externally, so don’t give one agent all three in the same session.
  4. Restrict which domains an agent can call, and block automatic loading of external images and links in AI output, which is a common exfiltration trick.
  5. Validate model output before passing it to a shell, database or another system, the same way you would validate user input.
  6. Log the agent’s prompts, retrieved content and tool calls so you can investigate when something goes wrong.

I still think agents are worth building. They just need the treatment we give any system that handles untrusted input: assume it will be compromised at some point, limit what a compromised agent can reach, and keep a person in the loop for the actions that matter.

Sources