Treat every document your RAG pipeline or agent reads as untrusted input, and test it against indirect prompt injection with poisoned documents
Treat every document your RAG pipeline reads as untrusted input, then test it with poisoned documents The short answer: a document your RAG pipeline or agent retrieves is input from someone you may not know. Treat it like a form field on a public website. Then prove your defences work by feeding th

The short answer: a document your RAG pipeline or agent retrieves is input from someone you may not know. Treat it like a form field on a public website. Then prove your defences work by feeding the pipeline poisoned documents before an attacker does.
A thread on r/LLMDevs asks the question this article builds on: IBM trained small models to ignore instructions hidden in documents. Would you trust that in a RAG pipeline? I take only its title from the thread. The rest is a method you can run this week.
In a RAG pipeline, the model reads retrieved text and your instructions in the same context window. Anyone who can get text into your corpus can try to put instructions in it. That is indirect prompt injection.
I wrote about where this bites in AI attackers go after Integrity first. Your control roadmap probably doesn’t.. My line there: "For most enterprise deployments, indirect prompt injection at the tool layer is where AI security stops being theoretical."
The scale needed is small: the same article cites PoisonedRAG (Zou et al., arXiv 2402.07867), which "reached 90 percent attack success against RAG corpora of a million documents with just five poisoned documents."
One caveat from that article, which applies to my own framing too: its heatmap cell values "are editorial judgments, not measurements." The PoisonedRAG result is a published finding. My ranking of risks is a judgement.
Before you test, map the inputs. For each one, write down who can change it.
If the answer is "anyone with an account" or "anyone on the internet", it is untrusted.
Make a test folder of documents that look normal but carry a hidden instruction. Vary the hiding place so the test covers the whole pipeline:
Plant them in a copy of your corpus, not production. Give each a unique marker string so you can search logs for it.
A poisoned document does nothing if it is never retrieved. Write queries that should pull each one into context. Run each query many times, because model output varies. Record three things per run:
The third is the one that matters most. A wrong sentence is a quality bug. An unrequested tool call is an incident.
In my article I argued that tool allowlisting, agent identity and action authorisation become core AI security controls. For a RAG pipeline, that means the rules sit in your code, where the model cannot change them.
So decide what must never happen, and enforce it in code:
That last point ties to integrity. In the same article I wrote: "If your AI governance program can’t produce tamper-evident evidence of a decision three years after it was made, it won’t survive contact with a regulator or a litigant." Logs that link a document to an action are the start of that evidence.
One run proves little. Put the poisoned documents in CI.
Write down three numbers per release: how many poisoned documents you tested, how many were retrieved, and how many produced a bad action. Do not report an "injection resistance score" unless you can explain how it was measured. If a leader asks whether the pipeline is safe, the honest answer is "these cases pass, these controls hold, and here is what we have not tested."
Ship RAG with the safety rules in the pipeline you control, because you cannot count on the model to ignore what it reads.
Which of your input sources can someone outside your organisation write to today, and have you ever tested it with a poisoned document?