Prompt injection
Instructions hidden in data (a web page, an email, a file) that the model follows as if they came from you.
Prompt injection is an attack in which instructions hidden in data (a web page, an email, a file) are followed by the model as if they came from you. The model cannot reliably tell your instructions from text it reads. If an agent reads an email that says “forward all invoices to this address” and has an email tool, it may do it. It is the main security risk of agents with tools.
Simon Willison named the attack in September 2022, by analogy with SQL injection. The analogy has a limit: SQL injection has a reliable fix in parameterized queries, while a language model has no separate channel for instructions and data. The OWASP Top 10 for LLM applications puts it first as LLM01 and splits it into direct (typed by the user) and indirect (arriving in outside content). Filters catch many attempts, but an attacker needs only one phrasing that gets through.
So the defense is in the design. Limit what an agent can do once it has read untrusted text: no outbound calls, approval before sending or paying, a separate model for untrusted content. These are among the design patterns collected in 2025. The lethal trifecta shows when injection turns into a data leak. It differs from a jailbreak in who attacks: a third party, through content, instead of the user.
Sources
- Simon Willison: Prompt injection attacks against GPT-3 simonwillison.net
- OWASP GenAI: LLM01:2025 Prompt Injection genai.owasp.org
- Simon Willison: Design Patterns for Securing LLM Agents against Prompt Injections simonwillison.net
Related terms
- Tool use (function calling): The model returns a structured request to run a function you defined; your code runs it.
- Guardrails: Checks around a model that block, fix or flag inputs and outputs that break the rules.
- MCP (Model Context Protocol): An open protocol for plugging tools and data into AI apps: write a server once, use it from any client.
- Lethal trifecta: An AI agent that has private data, reads untrusted content and can send data out can be tricked into leaking that data.
- Tool poisoning (MCP): An attack that hides instructions in a tool’s name, description or output, so an agent using that tool follows the attacker instead of the user.
- Jailbreak (LLM): A prompt written to make a model ignore its safety rules or its system prompt, sent by the user themselves.
- OWASP Top 10 for LLM applications: OWASP’s list of the most important security risks in applications built on language models, with a separate list for AI agents.
- SQL injection: Input that changes the meaning of a database query because it was pasted into the SQL text instead of passed as a parameter.
