At a glance
- Who should read this
- Teams building or operating LLM assistants, retrieval-augmented generation (RAG) systems and agents that read external content or call tools.
- The risk
- Text the model reads can act as instructions. Any content an attacker can influence, such as a web page, shared document, email or ticket, can redirect the model's behavior without the attacker ever interacting with it directly.
- Priority actions
- Treat every tool and data permission as available to whoever controls the content the model reads.
- Require human approval, outside the model, for consequential actions.
- Block or constrain the output channels that can leak data, such as rendered links and images.
Summary
Large language models do not reliably separate instructions from data. When an application places retrieved content into a model's context, any instructions inside that content compete with the developer's and user's instructions. This is indirect prompt injection: the attacker does not type into the chat. They plant text where the model will later read it.
The risk grows with what the application can do. A chatbot that only answers questions can be made to mislead. An assistant that can read email, search internal files and call tools can be made to exfiltrate data or take actions on the user's behalf. OWASP lists prompt injection as the first risk in its 2025 Top 10 for LLM Applications, and NIST AI 100-2 E2025 describes indirect prompt injection as a distinct attack class against generative AI systems.
How the attack works
The pattern has three parts:
- Placement. The attacker puts instructions in content the system will retrieve: a public web page, a document shared into a workspace, an inbound email, a support ticket, a code comment or a product review. The text may be hidden from human readers, for example in white-on-white text, metadata or alternative text.
- Retrieval. A legitimate user asks a question, and the application retrieves the planted content into the model's context, alongside the user's request and the system prompt.
- Execution. The model follows some or all of the planted instructions, because nothing in the model itself marks them as untrusted.
Common goals include changing an answer (for example, recommending a fraudulent payee), exfiltrating data from the context or connected sources, invoking tools the user did not intend to use, and persisting by writing new instructions into memory or a shared knowledge base.
The key insight: the attacker's privileges become the application's privileges. Whatever the model can read or do, a successful injection can direct.
Exfiltration channels to watch
Data leaves through any channel the model's output can reach. The most common are:
- Rendered links and images. If the interface renders markdown, an injected instruction can ask the model to output an image or link whose URL contains sensitive data. The browser requests the URL automatically, delivering the data to the attacker's server.
- Tool calls. Email, messaging, HTTP request and file-write tools can all send data out if the model can call them with arbitrary arguments.
- Downstream systems. Model output passed to other systems, such as tickets, code or databases, without validation can carry injected content further.
Why filtering alone is not enough
Input filters and classifiers that look for injection phrases are useful signals, but they cannot be the main control. Natural language has unlimited ways to express an instruction, attackers can encode or split instructions across content, and filters that are strict enough to stop determined attempts tend to block legitimate content too. Prompt-level defenses, such as telling the model to ignore instructions in retrieved text or wrapping content in delimiters, reduce success rates but do not eliminate them.
Design on the assumption that some injections will succeed, and limit what a successful injection can achieve.
Layered mitigations
| Layer | Control | What it limits |
|---|---|---|
| Content sources | Restrict retrieval to sources you control or trust; record the source of every retrieved chunk; apply access controls so users only retrieve what they may see | Where planted instructions can come from |
| Context handling | Separate and label untrusted content; apply injection classifiers as a signal; strip hidden text and active markup before indexing | How easily injected text is followed |
| Tool permissions | Grant the minimum tools and scopes per task; run tools with the user's own permissions, not a service account; avoid combining access to private data, untrusted content and outbound communication in one agent | What a successful injection can do |
| Human approval | Require confirmation, enforced outside the model, for sending, deleting, paying, sharing or changing permissions; show the user exactly what will happen | Consequential actions |
| Output handling | Disable or allow-list rendered images and links; validate and encode output before it reaches other systems; enforce a content security policy | Exfiltration and downstream injection |
| Monitoring | Log prompts, retrieved sources, tool calls and outputs; alert on unusual tool use and on instruction-like text in retrieved content | Time to detect and scope an incident |
The single most effective design decision is usually the third row: avoid giving one agent, at the same time, access to private data, exposure to untrusted content, and a way to communicate externally. Where all three are needed, put a human approval step between them, and keep approvals rare and specific enough that users do not approve by reflex.
Testing your application
Include indirect injection in security testing before release and after significant changes:
- Inventory every source of content the model can read, and who can write to each.
- Plant test instructions in each source, in visible and hidden forms, and check whether the model follows them.
- For each tool, test whether planted content can cause it to be called, and with what arguments.
- Test output rendering for link and image exfiltration.
- Re-test when you add a data source, a tool or a new model version, because behavior changes.
References
- LLM01:2025 Prompt Injection, OWASP Gen AI Security Project
- NIST AI 100-2 E2025, Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST
- Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection, Greshake et al., 2023
- MITRE ATLAS, MITRE
This advisory draws on public research, standards and official guidance. It is general guidance, not advice for a specific environment. Related training: LLM and Agentic Application Security.