Protect a RAG app from poisoned documents
Score each retrieved chunk for injection, poisoning, personal data and source trust, then allow, redact, reject or quarantine it.

Contents
Learning how to protect a RAG app from poisoned documents starts with one rule: retrieved text is data, not instructions. DeepintShield scores every retrieved chunk for indirect prompt injection, poisoning, personal data and source trust, then allows, redacts, rejects, quarantines or warns before the chunk reaches the model.
The challenge
Retrieval-augmented generation trusts its sources. Anyone who can edit one of those sources can influence the answer, and sometimes the actions that follow:
- Hidden instructions. A wiki page, ticket or web page can include text aimed at the assistant rather than the reader.
- Poison persists. A planted passage is indexed once and returned again and again.
- Mixed trust. Curated policy documents and open user uploads often share one index.
- Sensitive content. Chunks may carry personal data or secrets that should never reach the model.
- Agents act on what they read. When the assistant can call tools, a poisoned passage can become an action.
The approach
Check content twice: when it is ingested and when it is retrieved. Set a minimum trust level for sources and a maximum injection score for chunks. Quarantine suspect content for review instead of silently dropping it. Keep document permissions in your retriever, because chunk scoring is not access control. Keep tool permissions separate, so a clean-looking chunk can never authorise an action. Start in shadow mode, review the decisions, then enforce. Give each source an owner who reviews quarantined chunks, so poisoned content is removed at the source rather than filtered for ever.
How to protect a RAG app from poisoned documents with DeepintShield
- Wrap the retriever and the embedder. Add
guard_retriever()in one line around a LangChain, LlamaIndex or custom retriever, or callshield.rag.filter()on the chunks you retrieve. Useguard_embedder()to check content at ingestion. The SDK checks what you retrieve; it does not retrieve or embed documents for you. See the RAG security docs. - Set the policy. Scope it to retrieval, ingestion or response. Set a minimum trust score, a maximum injection score and, where answers must cite, “citation required”. Choose actions per finding: allow, warn, redact, quarantine or block, with severity from low to critical. Per-chunk decisions are Allow, Redact, Reject, Quarantine or Warn. Set stricter thresholds for open sources, such as user uploads, than for curated ones. Run it in shadow mode first.
- Keep actions behind their own check. If the assistant can call tools, Agentic Security requires an exact Allow for each governed call (Business plan and above), whatever the retrieved text says. Add output guardrails, and use Hallucination Defense with “Require sources” for grounded answers (Business plan and above).
RAG security live evaluation is available on the Team plan and above; verified provenance for agents and the evidence export need Business and above.
What you can show afterwards
- A decision for every chunk, with its injection score, trust score and action.
- A queue of quarantined sources for owners to review and clean.
- Evidence mapped to the OWASP LLM Top 10, MITRE ATLAS and NIST AI RMF.
- Proof that retrieved text never authorised a tool call on its own.
- The sources that produce the most quarantined chunks, so owners know where to clean up first.
To test the policy, index a synthetic document that contains an instruction aimed at the assistant, a chunk with a made-up personal identifier, and a chunk from a low-trust source. Confirm the decisions match your policy, that quarantined content stays out of answers, and that a document cannot make the assistant call a tool.
For the threat itself, read how to protect retrieved content from indirect prompt injection.
Related
- RAG Security: per-chunk scoring and decisions
- Sovereign AI security for the public sector: assistants over policy and case documents
- Stop prompt injection attacks: layered defences at every stage
- Stop personal data leaking to LLMs: redact personal data in chunks and prompts