Indirect Prompt Injection in RAG
In this article
- Recognise text in a retrieved chunk that gives orders to the model instead of stating facts, including text a reader cannot see.
- Render a suspicious chunk as a labelled, untrusted evidence block so its facts can be cited and its commands are obeyed in nothing.
- Keep the untrusted label on evidence through a summary step.
- Authorise a tool call from the customer's session and the application's policy, never from retrieved text.
Overview
Your support assistant searches a router manual and finds the right sentence: the router has a two-year warranty. The same passage holds a line nobody at your company wrote, invisible on the page, telling the assistant to reveal its instructions and pay the customer back. The model reads both lines as text.
How do you use the fact without taking the order? By the end you can spot instructions hidden in retrieved text, send it as labelled evidence that is cited but never obeyed, keep the label through a summary, and make sure no retrieved passage can start a payment.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- A warranty passage with a second voice
- Pasted into the instructions
- Evidence, not orders
- The label travels
- Actions come from the session
- Label, do not delete
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions