Prompt injection: attacks, examples and defences
Prompt injection is an attack in which text given to a large language model overrides the instructions its developer set. In direct injection the attacker types the instructions. In indirect injection they hide inside content the model reads, such as a web page, email, invoice or ticket. OWASP ranks it first (LLM01) in both the 2025 and 2026 editions of its Top 10 for LLM applications.
Prompt injection works because instructions and data share one channel
A traditional application keeps code and data apart: a database query is one thing, the customer's name inside it is another. A language model receives everything as text in one context window. NIST's adversarial machine learning taxonomy puts it plainly: generative AI models combine the data and instruction channels, so an attacker who controls any text the model reads can try to steer it. Every document, email, web page and tool result an agent reads is a possible source of instructions. That is the root of the problem, and it is why the attack has two main forms.
Direct prompt injection
The attacker is the person using the system. They type instructions meant to override the system prompt: ignore your rules, reveal your instructions, act as a different assistant. NIST describes these as in-context instructions appended to higher-trust instructions from the application designer. MITRE ATLAS tracks it as AML.T0051.000.
Indirect prompt injection
The attacker never talks to the model. They plant instructions in something the model will read later: a web page, a shared document, a support ticket, a retrieved file or a tool's output. NIST notes that in these attacks the person harmed is often the legitimate user. MITRE ATLAS tracks it as AML.T0051.001.
Jailbreaking, a close relative
A jailbreak aims to make the model ignore its safety training so it produces content it would normally refuse. MITRE ATLAS lists it separately as AML.T0054. Prompt injection aims at the application: hijacking the task, the data or the tools. Many attacks combine the two.
Six prompt injection examples, from agents to images
An invoice that gives orders
Example: an accounts payable agent reads a supplier invoice. Hidden text in the PDF tells it to update the supplier's bank details and mark the invoice as approved. If the agent can write to the payment system, the instruction becomes a payment.
A support ticket that leaks data
Example: a customer submits a ticket containing instructions to include the last five tickets from other customers in the reply. A support agent with broad read access and no output check may comply.
A web page that exfiltrates a conversation
OWASP describes a scenario where a user asks an assistant to summarise a page, and hidden instructions on the page make the model send the private conversation to an attacker's URL.
A poisoned knowledge base
OWASP describes an attacker editing documents in a retrieval (RAG) repository so the assistant repeats malicious instructions or false answers to every user who asks a related question.
Instructions in an image
Multimodal models read text inside images. OWASP lists hidden prompts in images that change the model's behaviour when processed alongside an innocent request.
Obfuscated and split payloads
Attackers encode instructions in Base64, switch languages, append strings of meaningless characters (adversarial suffixes) or split one instruction across several inputs so no single piece looks harmful. OWASP lists each as a live technique.
A successful injection inherits the agent's permissions
The damage a prompt injection can do depends less on the clever wording and more on what the compromised system is allowed to do. OWASP's excessive agency entry names three causes: tools with more functions than the task needs, permissions broader than the task needs, and high-impact actions with no person in the loop. Map each of your AI systems against four outcomes to see where an injection would hurt most.
Data leaves
The model is told to include confidential records in an answer, or to send them to an external URL through a link, an image request or an outbound tool. OWASP lists sensitive information disclosure as LLM02 in its 2026 list.
The system prompt leaks
The model reveals its own instructions, which can contain business rules, internal names or, by mistake, credentials. OWASP's 2026 list covers this under hidden context exposure (LLM08:2026), which replaced and widened the 2025 system prompt leakage entry. Keep secrets out of prompts entirely.
A tool runs that should not
The agent sends an email, edits a record, approves a request or makes a payment. This is where a text attack becomes a business incident.
Answers change for everyone
A poisoned document in a shared knowledge base changes the answer every user gets on a topic, until someone notices and removes it.
How to prevent prompt injection in layers
Constrain the model's role
Give the system prompt a specific role and scope, and tell the model to ignore attempts to change it. This raises the bar slightly. OWASP lists it as a mitigation, and on its own it is easy to talk around.
Filter inputs and outputs
Score incoming prompts and retrieved content for injection patterns, and check answers before they leave. Validate structured output with deterministic code instead of trusting the model to follow a format.
Mark untrusted content
Keep text from documents, emails, web pages and tool results clearly separated from instructions, and label it as untrusted, so the model and your filters treat it as data.
Give agents least privilege
Each agent gets its own identity, short-lived credentials and only the tools its task needs. Read-only by default. An injected instruction can only use the permissions the agent already has.
Put a person on high-impact actions
Payments, deletions, external emails and permission changes pause for a named approver who sees the business record and any risk signals. OWASP's excessive agency entry points to human approval for high-impact actions.
Attack your own system
Run adversarial tests before release and on a schedule afterwards, using the OWASP and MITRE ATLAS techniques as a checklist. Every new tool or data source an agent can read is a new injection path to test.
Governance teams treat prompt injection as a tracked risk
Security teams own the filters. Governance teams own the question an auditor will ask: for each AI system that reads untrusted content, what is the injection risk, which controls reduce it, and when were those controls last tested? Recording prompt injection as a named risk in each use case's risk register, with its controls and test results attached, turns a security topic into something you can report on. TheAI guardrails guide covers the runtime controls, theAI red teaming guide covers testing, and theOWASP Top 10 for LLM guide places prompt injection among the other nine risks. For agents that reach tools through MCP servers, seeMCP governance.
Inventory the exposure
List every AI system that reads content you do not control: customer messages, inbound documents, web pages, third-party tool output. These are your indirect injection paths.
Map controls to the risk
Link each exposed system to its injection filter, its tool permissions and its approval rules, so a gap shows up as a missing control.
Keep the test evidence current
A red team result from last year says little about a system whose tools or prompts changed last month. Retest when the system changes, and keep the dated report.
How Moring AI handles prompt injection
A prompt injection shield at the gateway
Moring AI runs prompt injection and jailbreak filters at the gateway on every request. A policy can alert or block based on the injection score, and each decision is logged with the policy version that made it.
Permissions and approvals limit the blast radius
Agents act with their own identity and call only allow-listed tools. Actions above a policy limit, such as an invoice payment, pause for a person who sees the business record and risk signals such as recently changed bank details.
Replay the attack before it happens
The agent graph replays scenarios step by step, including an invoice carrying a hidden instruction, to show where the run would pause or be blocked. Red teaming campaigns are mapped to the OWASP Top 10 for LLM applications and MITRE ATLAS.
Tracked as a risk with evidence
Prompt injection is a risk type in the risk register, linked to its controls and to dated test results. See testing and red teaming and policy enforcement.
Frequently asked questions
What is prompt injection?
Prompt injection is an attack where input to a large language model alters its behaviour in ways its developer did not intend, for example making it ignore its instructions, reveal confidential data or call a tool it should not. OWASP defines it as user prompts altering the model's behaviour or output in unintended ways, and ranks it LLM01 in both its 2025 and 2026 Top 10 for LLM applications.
What is an example of a prompt injection attack?
A common example is indirect injection through a document. An AI agent that processes invoices reads a PDF with hidden text telling it to change the supplier's bank account and approve payment. The agent treats the text as an instruction because language models read instructions and data through the same channel. If the agent has write access to the payment system and no approval step, the attack succeeds.
How do you prevent prompt injection?
No single control prevents it. Combine layers: filter prompts and retrieved content for injection patterns, check outputs before they are used, separate untrusted content from instructions, give agents only the tools and permissions their task needs, require human approval for high-impact actions, and red team the system before release and on a schedule. OWASP's prompt injection entry lists these mitigations.
Can prompt injection be fully prevented?
Not with current models. NIST's adversarial machine learning report (AI 100-2 E2025) says current generation models remain highly vulnerable to direct prompt injection and suggests designing systems on the assumption that the model can and will produce malicious output when exposed to attackers. The practical goal is to limit what a successful injection can do.
What is the difference between prompt injection and jailbreaking?
Jailbreaking targets the model's safety training, trying to make it produce content it would refuse. Prompt injection targets the application around the model, trying to hijack its task, data or tools. MITRE ATLAS lists them as separate techniques (AML.T0054 and AML.T0051). In practice attackers often use jailbreak techniques to make an injection work.
Why are AI agents more exposed to prompt injection than chatbots?
A chatbot that is injected says something wrong. An agent that is injected can do something wrong: send data, change records, call APIs or move money. Agents also read more untrusted content (emails, tickets, web pages, MCP tool results), so they have more indirect injection paths. That is why agent defences focus on permissions and approvals as well as filters.
Sources
- OWASP LLM01:2025 Prompt Injection: Definition, direct and indirect types, example attack scenarios and prevention strategies. genai.owasp.org. Checked 25 November 2026.
- NIST AI 100-2 E2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations (March 2025): Section 3.3 (direct prompting attacks) and section 3.4 (indirect prompt injection attacks and mitigations). csrc.nist.gov. Checked 25 November 2026.
- MITRE ATLAS AML.T0051 LLM Prompt Injection: Technique entry with sub-techniques Direct (AML.T0051.000), Indirect (AML.T0051.001) and Triggered (AML.T0051.002). atlas.mitre.org. Checked 25 November 2026.
- MITRE ATLAS AML.T0054 LLM Jailbreak: atlas.mitre.org. Checked 25 November 2026.
- OWASP LLM06:2025 Excessive Agency: Least privilege and human approval as limits on what a manipulated agent can do. genai.owasp.org. Checked 25 November 2026.
- OWASP Top 10 for LLM Applications 2026: Current numbering: LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure, LLM08 Hidden Context Exposure. genai.owasp.org. Checked 25 November 2026.
Agents reading documents you do not control?
See how Moring AI filters injection attempts, limits what an agent can do and keeps the test evidence for every system.
Talk to Moring AI