
Short answer: Prompt injection is input that changes a language model’s behaviour in ways its builders didn’t intend. It can come directly from a user (“ignore your rules and…”) or indirectly from content the model reads, such as a web page, a file, an email or a document in its knowledge base. OWASP lists it first, as LLM01, in its Top 10 for LLM Applications 2025. OWASP notes that it is unclear whether any fool-proof prevention exists, so protection comes in layers: limit what the agent is allowed to do, require human approval for risky actions, keep outside content clearly separate from instructions, check outputs, and test attacks before attackers do.
Direct and indirect injection
OWASP separates two kinds:
- Direct: the user’s own message changes the model’s behaviour, on purpose or by accident.
- Indirect: the model takes in outside content that carries instructions, for example a web page it summarises or a file it was given.
OWASP also notes that the instructions don’t have to be visible to people. Text hidden in a page or an image is enough, as long as the model reads it.
What attacks look like
OWASP’s example scenarios include, among others:
- A support chatbot is told to ignore its guidelines, look up private data and send emails.
- A page the model is asked to summarise contains hidden instructions that leak the conversation through an image link.
- A document in a retrieval knowledge base is altered so the model gives wrong answers.
- Instructions are hidden in an image sent alongside harmless text.
- Filters are dodged with other languages, encodings such as Base64, or emoji.
The risk grows with what the system can do. A chatbot that can only reply can be embarrassed; an agent that can send email, change orders or move money can cause real harm.
The defences OWASP recommends
- Constrain the model’s behaviour. Give clear instructions about its role, its limits and what it must ignore.
- Define and check the expected output format. Validate answers before they are used.
- Filter input and output. Look for sensitive content and known attack patterns in both directions.
- Give the least privilege. The agent’s tools and tokens should only allow what the task needs.
- Require human approval for high-risk actions.
- Separate and label outside content. Make it clear to the model which text is data, not instruction.
- Test with attacks. Run adversarial tests and simulations regularly.
OpenAI’s guide to building agents makes the same point about approval: actions that are sensitive, irreversible or high-stakes, such as cancelling orders, authorising large refunds or making payments, should trigger human oversight, at least until the agent’s reliability is proven.
A checklist before an agent goes live
- List every tool the agent can call and remove the ones it doesn’t need.
- Mark which actions need a person’s approval, and enforce that in code, not only in the prompt.
- Treat everything the agent reads, including your own knowledge base, as potentially hostile.
- Keep secrets out of prompts and tool responses.
- Log tool calls so you can see what happened.
- Try the attacks above against your own system.
If you connect agents to business systems through MCP, the same rules apply to every server you add; see What is MCP.
Summary
- Prompt injection changes a model’s behaviour through direct messages or content it reads.
- It is OWASP’s top risk for LLM applications in 2025.
- Defence is layered: least privilege, human approval, separated content, output checks and regular attack tests.


