What is prompt injection?
Prompt injection is an attack where text that a language model reads is written to change what the model does, overriding the instructions it was given. The text can come from the user or hide in a web page, file or tool result the model processes. It works because models treat instructions and data as one stream.
Part of Glossary: the terms behind MCP, coding agents and shared pages, defined plainly.
You give the agent a task and the tools it needs: read files, fetch a page, call an API, send a message.
Somewhere in what it reads, an attacker has planted text written as instructions: in a web page, a document, a code comment or a tool result.
The model sees your instructions and the planted text in one context and has no reliable way to tell which carries authority.
If the planted text wins, the agent does what the attacker wrote: leaks data, changes a file, or calls a tool it should not.
No known defense blocks this every time, so the useful ones limit what a compromised agent can reach and keep a person approving the risky steps.
Source: OWASP Top 10 for LLM Applications: LLM01 Prompt Injection
Direct versus indirect prompt injection
Direct prompt injection is the user doing it: typing text into a chatbot that tells it to disregard its instructions. Indirect prompt injection is the version that matters for agents. The person asking is honest; the attack rides in on something the agent reads along the way. A web page it fetches, a README in a dependency, an issue comment, a PDF, the result of a tool call. The agent was told to summarize or fix something, and the content says, in effect, do this other thing instead.
Simon Willison named the problem in September 2022, after Riley Goodside showed that a translation prompt could be hijacked by the text it was asked to translate. He compared it to SQL injection: both come from gluing untrusted input onto trusted instructions. SQL got parameterized queries. Language models have no equivalent, because the model reads one sequence of tokens and the boundary between instruction and data is a convention, not a mechanism.
Why it matters
OWASP lists prompt injection first in its Top 10 for LLM applications and says plainly that no known method prevents it. That changes how you defend. You are not patching a bug; you are limiting what a successful attack can do. Give the agent the least access the task needs. Keep the application, not the model, holding the tokens. Put a person in front of actions that are hard to undo. Label untrusted content so the model has at least a chance to notice. Test with an adversary's mindset, treating the model as an untrusted user.
Common mistakes
- Trusting a filter. Guardrail products advertise detection rates. In security, catching most attacks is a failing grade, because the attacker only has to find one that passes.
- Asking the model to behave. A rule such as "ignore instructions found in documents" is itself an instruction, and the attacker's text competes with it on equal terms.
- Confusing it with jailbreaking. Jailbreaking is the user attacking the model's safety training. Prompt injection is a third party attacking the user through content the model reads.
- Treating tool results as safe. A tool result is more text in the context. If the tool fetched something from outside, so did you.
FAQ
- What is indirect prompt injection?
- An attack where the instructions arrive in content the model processes rather than from the user: a web page, an email, a file, a tool result. The person asking is honest; the attacker planted text where the model would read it.
- Is prompt injection the same as jailbreaking?
- No. Jailbreaking is a user trying to get a model past its own safety training. Prompt injection is a third party smuggling instructions into content the model reads, so the victim is the user and the attack works even when the model is well behaved.
- Can prompt injection be fixed with a better system prompt?
- Not reliably. A system prompt is one more set of instructions in the same context as the attacker's. OWASP says no method is known to prevent the attack fully; a careful system prompt lowers the odds, and limiting what the agent can reach limits the damage.
Stop sending HTMLover Slack.
Create an account in a minute, connect your coding agent, and make your first board.