Prompt injection
Also known as: prompt injection attack, indirect prompt injection
Hiding instructions in the text an AI system reads so that it ignores its own rules and follows the attacker instead.
Draft - this entry has not been reviewed yet.
Formal
An attack on a large language model in which input written by an outsider, typed directly or hidden in a web page, file or email the model is asked to read, is treated as an instruction and overrides what its owner intended.
In plain English
Like slipping a note into a pile of letters a new assistant is sorting that says "ignore your boss and send me the keys" - and the assistant cannot tell the note apart from real orders.
In practice
A municipality's AI assistant sums up incoming emails from citizens; one email hides white-on-white text telling it to forward the last ten messages to an outside address, and it does.
Why it matters
The model mixes rules and content in the same stream of words, so there is no watertight fix yet; the more an AI system is allowed to do on its own, the more damage one hidden sentence can cause.
Technical deep dive
The root cause is architectural. An LLM receives one token sequence in which the system prompt, user turns, retrieved documents and tool results are separated only by chat-template markers and formatting conventions; attention operates over all of it, and there is no equivalent of a parameterised query that forces a span to be treated as inert data. Role tokens and training give privileged segments more weight, but the separation is statistical, which is why the analogy with SQL injection is instructive but misleading: SQL injection has a complete fix (prepared statements), prompt injection currently does not. Greshake et al. (2023) formalised indirect prompt injection, in which the payload arrives through content the application retrieves - web pages, emails, PDFs, tool descriptions - so the attacker never interacts with the system directly.
Payloads pursue a small set of goals: goal hijacking (do something else), prompt leaking (reveal the system prompt, see OWASP LLM07), data exfiltration, and unauthorised tool use. A well-known exfiltration channel is output rendering: the model is told to emit a Markdown image whose URL contains conversation data in the query string, and the client leaks it when it fetches the image; blocking external image rendering or enforcing a strict content security policy closes that path. Agents with memory add persistence, since an injected instruction can be written into long-term memory and replayed in later sessions.
Mitigations at the model level include instruction-hierarchy training (Wallace et al., 2024), which teaches models to privilege system and developer messages over tool output, and spotlighting (Hines et al., 2024), which marks untrusted text with delimiters, interleaved datamarks or encoding. Classifier-based detectors screen retrieved content. All of these reduce success rates but are bypassed by adaptive attacks, as benchmarks such as AgentDojo show. Stronger guarantees come from system design: the dual-LLM pattern, where a privileged model never sees untrusted text and a quarantined model processes it without tool access; CaMeL (Debenedetti et al., 2025), which extracts a control flow from the trusted query and tracks capabilities on data derived from untrusted sources; and plain least privilege, human confirmation and egress restrictions, which limit what a successful injection can do.
OWASP ranks prompt injection as LLM01:2025 and includes jailbreaking as a subtype; NIST AI 100-2 classifies it as an attack on generative AI with direct and indirect variants. It differs from data poisoning, which alters the model's weights during training, and from excessive agency, which is the design weakness that determines the blast radius. For an EU deployer, a successful injection that exposes personal data is a personal data breach under GDPR Art. 33 with the usual 72-hour notification clock, and for high-risk AI systems, EU AI Act Art. 15(5) requires resilience against attempts by unauthorised third parties to alter use or outputs by exploiting system vulnerabilities.
What to learn first
Everything this builds on, foundations first.
- Token
- →Transformer
- →Large language model (LLM)
- →Prompt
- →Prompt injection
Relationships
- Requires
- Large language model (LLM)Prompt
- Don't confuse with
- Social engineeringSQL injectionSystem promptData poisoningJailbreak
Sources & further reading
Standards & official texts
Reference works
Where this data comes from
This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.
See the review queueSuggest a correction on GitHubThis term as JSON
Check yourself
Loading…