Prompt injection is an attack where someone writes input that makes an AI model ignore its intended instructions and follow the attacker's instead. It is the number one risk in the OWASP Top 10 for LLM Applications, and it is hard to eliminate because language models do not reliably separate instructions from data.
Direct Prompt Injection
In direct injection, the attacker types the malicious instruction into the chat. A classic example is telling the assistant to ignore previous instructions and reveal its hidden system prompt. Jailbreaks, which try to talk a model out of its safety rules, are a related family of direct attacks.
Indirect Prompt Injection
In indirect injection, the instruction hides inside content the model processes: a web page it is asked to summarise, an email it reads, a document uploaded to a RAG system. The user never sees it. This is far more dangerous for assistants that can browse, read mail or call tools, because a stranger can control them without ever talking to them.
What Attackers Try to Achieve
- Extract the system prompt or confidential data
- Make the assistant produce harmful or off-brand content
- Exfiltrate information, for example by getting the model to include data in a link or image URL
- Trigger tool calls the user never asked for
Why It Is Hard to Fix
A model sees one stream of text. Your instructions and the attacker's text arrive in the same format, so you cannot just filter one out. Filters help but can be bypassed with rephrasing, role-play, encoding and other tricks.
How to Reduce the Risk
- Give the model the least privilege: only the tools and data the task needs.
- Treat all model output as untrusted input to other systems and validate it.
- Require human approval for sensitive or irreversible actions.
- Separate trusted instructions from untrusted content and label untrusted content clearly.
- Add content filters and tools such as Prompt Shields as one layer, not the only layer.
- Log and monitor interactions, and red-team regularly.
Practise Safely
The best way to understand prompt injection is to try it in a legal practice environment. Our AI Security course includes a hands-on module on prompt injection and jailbreaking, and the AI Security Lab lets you practise on any basic laptop.
