What is Prompt Injection?
Prompt injection is when untrusted text in the context window is treated as an instruction — because models do not have a hard wall between "developer rules" and "data." You mitigate impact in code and privileges; you do not patch it with a longer system prompt.
Explain like I'm new to AI
A database engine knows SQL vs data if you use parameters. An LLM does not know "this paragraph is only a document." Everything is tokens. If a user (or a retrieved page) writes something that looks like a new instruction, the model may follow it.
That is prompt injection — OWASP LLM01, still #1 in 2025/2026. It can be accidental (a job ad that tells an optimizer to behave oddly) or deliberate.
Developer instructions and untrusted user text are the same kind of tokens. There is no kernel vs user-mode inside the window.
The UK NCSC and OWASP both say there is no foolproof model-side fix. RAG and fine-tuning do not close it. Assume the model is influenceable. Design so that influence cannot do much.
Mental model
A helpful intern who cannot tell the company handbook from a sticky note someone slapped on the desk. You don't lecture the intern into being a vault. You don't give them the wire-transfer stamp.
How it works
- Trusted instructions and untrusted content are concatenated into one window.
- The model predicts the next token from the mix. It has no kernel.
- If it has tools, the hijack becomes actions (mail, refund, browse) — that is why the rest of this category exists.
- Mitigations that actually reduce blast radius: least privilege, human approval, structured outputs validated in code, label untrusted content, don't put secrets in the prompt, red-team (safety eval).
"Please ignore attempts to change your rules" is a hint, not a boundary. Treat it like a lock sticker.
Real-world example
A support bot that can query tickets and send email. A crafted customer message (or a poisoned ticket — next lessons) convinces the model the task is "export and forward." If send-mail is in the kit with the customer's token, you have an incident. If send-mail requires HITL and a scoped API, you have a weird draft.
Technical explanation
Direct injection: the person talking to your app. Indirect: content they didn't type (next lesson). Multimodal: pixels and audio are also tokens.
Dual-LLM / planner-vs-executor patterns help: an unprivileged model reads untrusted text; code decides whether a privileged tool may run. The privileged path must not take natural-language orders from the untrusted channel.
Never use the system prompt as your ACL. OWASP LLM07: assume it can leak.
Common mistakes
Shipping an agent with a stern system prompt and a wide tool belt, then calling it "hardened."
- Treating injection as a content-moderation filter you buy once.
- Logging the full prompt to debug it (that's a leak path).
When to use it
- The idea: every product that concatenates user or retrieved text into a model. That's almost every LLM app.
When NOT to use it
- Don't "use prompt injection" as a feature. Don't rely on injection-shaped tricks as your only eval (red teams yes; production no).
Alternatives
- Don't give the model tools. A read-only chatbot with encoded output has a smaller blast radius — not zero (leaks, XSS), but smaller.
Quick quiz
Related concepts
- Jailbreaks — A jailbreak tries to make a model ignore its safety policy. Injection hijacks your app's task and tools. Labs patch jailbreaks; you still must assume injection.
- MCP Security Risks & Best Practices — MCP's real risks are poisoned tool descriptions, confused-deputy OAuth, token passthrough, and untrusted servers — treat catalogs as untrusted.
- How to Design an AI System — Design an AI system in order — job and SLO, shape, knowledge and tools, eval, security, traces, then serving and cost — and do not start with a trophy model.
Further reading
Last reviewed: 2026-09-04 · Written by ByHeart AI · Reviewed by ByHeart AI