Not What You've Signed Up For: Indirect Prompt Injection
TL;DR. This early-2023 paper named and mapped indirect prompt injection: an attacker does not talk to the model at all, but places instructions in content the application will later retrieve (a web page, an email, a code file). When the model reads that content, it may follow the instructions. The authors build a taxonomy of how injections arrive and what they can achieve, and show working examples on Bing Chat, GitHub Copilot and GPT-4 tool-using apps. Their central point is that LLMs have no separate channel for instructions, so any text the model reads can act like code.
Why it matters now. In 2023 the main risk was a chatbot giving manipulated answers. Today’s agents browse, read mail, edit repositories and run tools for many steps, so the same weakness can turn into real actions. Retrieval-augmented systems, which IR researchers build, are the main entry point. The threat model here is the starting point for later benchmarks such as AgentDojo and for every defence that separates trusted from untrusted context. This page summarises the paper for defenders and does not reproduce attack prompts.
Key idea
Section titled “Key idea”One stream, mixed authority. An LLM application builds a context from several sources and generates from all of it:
The developer prompt and the user request are trusted. The retrieved items are not: anyone who can publish a page, send an email or commit to a repository can control them. But sees only tokens. Nothing in the model marks which tokens are allowed to give orders. Direct prompt injection needs the attacker to be the user; indirect injection only needs the attacker’s text to be among the .
How injections arrive (§3.1).
- Passive: placed where retrieval will find it, such as public web pages (helped by SEO) or code repositories.
- Active: delivered to the target, for example an email that an email-reading assistant will process.
- User-driven: the user is tricked into pasting text that carries hidden instructions.
- Hidden: a small first-stage injection makes the model fetch a larger one, or the instructions are encoded or hidden in other modalities.
What they can achieve (§3.2). Information gathering (getting the user to reveal data), fraud (phishing or scams presented by a trusted assistant), intrusion (persistent control, including through memory), malware and worm-like spread (the model passes the injection on, for example by email), manipulated content (biased or false summaries, suppressed sources) and availability attacks (making the assistant useless or slow). Attacks can be untargeted or aimed at particular users.
Key results
Section titled “Key results”The paper is a security analysis with demonstrations, not a benchmark, so results are qualitative.
- Set-up (§4.1). Synthetic chat apps use text-davinci-003 (LangChain, ReAct prompting) or GPT-4 (plain tool descriptions, no ReAct) with tools for search, viewing the current page, retrieving URLs, reading and sending email, an address book and memory, all on mock content at temperature 0. Real systems tested were Bing Chat (through the Edge sidebar reading local HTML files) and GitHub Copilot (code completion driven by the surrounding code context).
- Three general remarks (§4.2). Indirectly injected instructions can steer the model; prompts that the chat interface filters are not filtered when injected indirectly; and in most cases the model keeps following the injection for the rest of the session.
- Observations. Attacks may only need to state a goal, which the model then pursues by itself; models can elaborate beyond what was injected; and the model may issue follow-up queries that reinforce the injection.
- Effort. The authors note that their prompts often worked on the first try (§5.2), suggesting little skill is needed.
- Disclosure (§5.1). No injections were placed on live public sites; the findings were disclosed to OpenAI and Microsoft.
Limitations & open questions
Section titled “Limitations & open questions”- No success rates. The paper does not quantify how often attacks work; later benchmarks were needed to compare models and defences.
- 2023 systems. The models and products tested have changed, and vendors added defences, so specific demonstrations may no longer work. The structural problem has not gone away.
- Synthetic tools. Tool-using apps were simulated with mock content, which simplifies real retrieval and real user behaviour.
- Mitigation dilemma. A filter model strong enough to understand obfuscated instructions may itself be injectable, and a weak one misses them (§5.6). How to escape this trade-off is still open.
Connections
Section titled “Connections”- Measured next: AgentDojo turns this threat model into a benchmark with attack-success and utility metrics.
- Training-time cousin: pretraining backdoors plant the trigger in the weights instead of the context.
- Where untrusted text enters: RAG, ReAct, Toolformer and deep-research agents such as OpenAI Deep Research.
- Judges are injectable too: LLM-as-a-judge and verifier robustness, where text inside the graded answer can steer the grader.
- Fixed corpora for controlled tests: BrowseComp-Plus.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
A search agent reads 50 retrieved documents per task, and a fraction q = 0.001 of documents in its index contain an injected instruction. Assuming independence, compute the probability that a single task exposes the model to at least one injection, and the expected number of exposed tasks per day at one million tasks. Then name two design changes that reduce exposure and two that reduce impact, and explain why the distinction matters.
What a strong answer covers
- P(at least one) = 1 − (1 − 0.001)^50, which is about 1 − e^(−0.05), so about 4.9% of tasks.
- At one million tasks per day, that is about 49,000 exposed tasks per day; even a low per-exposure success rate gives many incidents.
- Reducing exposure: read fewer documents per step, prefer trusted or curated sources, or filter instruction-like text before it reaches the model.
- Reducing impact: restrict which tools can run after reading untrusted text, require user confirmation for side-effecting actions, and block exfiltration channels.
- Exposure is hard to push to zero for an open-web agent, so impact controls are what bound the damage; this mirrors defence in depth in classic security.
- Mechanism
The paper says that retrieval blurs the line between data and instructions, and that injected text can act like arbitrary code. Explain mechanically why an instruction-tuned LLM follows instructions found inside retrieved content, and why Bing Chat's chat-interface filters, which blocked the same text typed by a user, did not stop it when the text came from a page.
What a strong answer covers
- The model sees one token sequence; the system prompt, user turn and retrieved text are all just tokens, and nothing in the architecture marks which ones carry authority.
- Instruction tuning rewards following imperative text wherever it appears, so a command inside a document is a strong cue to act.
- Filters attached to the user input channel inspect only what the user types; retrieved text enters through a different path that the filter never sees.
- Because the injection sits in the context, it tends to persist for the rest of the session, which the paper observed in most cases.
- This is the LLM version of mixing code and data in one channel, the root cause of SQL injection; the difference is that there is no reliable escaping for natural language.
- Critique
The paper demonstrates many attacks but reports no success rates, and tests on synthetic apps and local HTML files instead of live injections. Critique what the paper does and does not establish, and explain how a later benchmark such as AgentDojo fills the gap.
What a strong answer covers
- It establishes feasibility and a threat taxonomy: indirect injection works on real deployed systems (Bing Chat, GitHub Copilot) and on tool-using GPT-4 apps.
- It does not measure how often attacks succeed across tasks, users, phrasings and models, so it cannot compare defences or models.
- The authors note that prompts often worked on the first attempt, which suggests low attacker effort, but this is anecdotal.
- Avoiding live injections was the ethical choice and they disclosed to vendors, but it leaves open how often real retrieval would surface such content.
- AgentDojo adds stateful environments, many user and injection tasks, deterministic success checks and separate utility and attack-success metrics, which makes defences comparable.
- Design
You are adding web search and email tools to a RAG assistant used inside a company. Using the paper's taxonomy (injection methods and threats), design a defensive architecture. Keep it at the level of trust boundaries and controls.
What a strong answer covers
- Label every context segment by origin (developer, user, retrieved web, received email) and keep untrusted text clearly delimited and never treated as instructions by the orchestrator code.
- Plan tool use from the trusted user request before reading untrusted content, and restrict later calls to that plan (least privilege per task).
- Require explicit user confirmation for side-effecting actions such as sending email, and block or rewrite outbound URLs that could carry data out.
- Add an independent detector or monitor on tool outputs and on proposed actions, while accepting that detectors can be evaded.
- Log all retrieved content and actions so incidents can be traced to a source; red-team each injection method (passive, active, user-driven, hidden) before launch.
- Connect
For an IR researcher, indirect prompt injection looks like a new form of adversarial retrieval. Connect it to search-engine optimisation and corpus poisoning, and explain how the threat changes when the retriever feeds a deep-research agent instead of a ranked list shown to a person.
What a strong answer covers
- Passive injection relies on the attacker's page being retrieved, which is exactly what SEO and adversarial ranking attacks try to achieve.
- In classic search, a person reads the result and judges it; in a RAG or agent pipeline, the model reads it and may act on it with no human in between.
- Deep-research agents read many more documents per task and issue follow-up queries, so exposure grows and injected text can steer later searches, as the paper observed.
- Retrieval-side defences (source reputation, spam detection, deduplication) become part of the security boundary, not only the quality boundary.
- Fixed-corpus benchmarks such as BrowseComp-Plus make it possible to plant controlled injections and measure their effect reproducibly.