Part 6 · LLM Application Security
LLM01: Prompt Injection
Text a model reads can change what it does, because models have no built-in boundary between instructions and data.
What it is
A prompt injection occurs when input alters a model's behavior in ways the developer did not intend. That input can be typed by a user, retrieved from a document, returned by a tool, hidden in an image or audio file, or stored in memory.
The root cause is architectural. Instructions and data reach the model as tokens in one stream, so there is no equivalent of the parameterized query that largely solved SQL injection. Injected text also need not be visible to the person using the application.
How the attack unfolds
An indirect injection against an email assistant. Switch scenarios to see where architectural controls stop the attack.
Forms of injection
| Form | Where the instruction comes from |
|---|---|
| Direct | The user types text intended to override the application's rules |
| Indirect | Web pages, emails, documents, code comments, or tool results |
| Multimodal | Images, audio, video, or file metadata |
| Persistent | Instructions saved into memory that influence later sessions |
| Jailbreak | Prompts that target the model's safety training specifically |
Real-world case
EchoLeak (CVE-2025-32711) affected Microsoft 365 Copilot and was disclosed in June 2025. A single crafted email could trigger data exfiltration without any user interaction. Microsoft fixed it on the server side.
Defenses
OWASP's position is that no reliable prevention exists, so defenses should be architectural: assume the instruction boundary will eventually be bypassed, and limit what a compromised model can do.
- Constrain capabilities. Give the model only the tools and data this task needs.
- Break the lethal trifecta. Avoid combining private data, untrusted content, and an outbound channel in one session.
- Authorize outside the model. Enforce permissions in deterministic code.
- Require approval for high-impact actions. Show the exact recipient, amount, or change.
- Control output channels. Block automatic loading of external links and images.
- Test adversarially. Measure attack success rates on every change.
Common misconception
"A strong system prompt prevents injection."
A system prompt is more text in the same stream. It can reduce some attacks but cannot enforce a security boundary.
Key takeaways
- Any content a model reads can attempt to steer it.
- Current defenses reduce risk but do not eliminate injection.
- Limit what a successful injection can do.