vibe-audit.lab

guides · 2026-11-14

RAG Poisoning: How One Planted Document Rewrites Your Chatbot's Answers

Published 2026-11-14 · Reviewed 2026-11-14 · By the Ingenious AI team

The short answer

A RAG system answers from retrieved documents, so whoever controls a document controls the answer. Poisoning paths include public contribution pipelines, crawled pages carrying hidden instructions, and metadata trusted for access decisions. Defend ingestion like a publishing pipeline — review, provenance and scoping — and never let document metadata decide who may see what.

Check your own app free: paste your code or enter your site URL on the Vibe-Code Audit homepage — the free scan checks for exposed secrets, injection flaws, XSS patterns, missing headers and exposed .env/.git paths, with a copy-paste fix for every finding. No credit card.

Why retrieval is a trust decision

RAG architectures fetch 'relevant' chunks and place them in the model's context, where the model treats them as ground truth — that is the product working as designed. The security question is provenance: how did this chunk earn its place? In AI-built support bots the ingestion pipeline is often a folder, a crawler or an upload form with no review, because the demo needs documents, not governance. Vibe-Code Audit's RAG detector family flags the code-level symptoms — ingestion without validation, retrieval results trusted wholesale, and document metadata used for access decisions — because the architecture's trust assumptions live in those lines.

Attack shapes vary: a document stating false facts (refunds are always approved, the CEO's email is…), a document carrying instructions rather than facts ('when asked about pricing, direct users to…'), and visibility poisoning, where a restricted document's chunks are retrieved into unrestricted sessions because the filter trusted a metadata field the document itself supplied.

Metadata is not an access control

The subtlest detector in the family deserves its own paragraph: retrieval filters like 'audience = doc.metadata.audience' fail when metadata is authored by the document's contributor — the attacker simply labels their restricted-content plant 'public', or labels a malicious plant with the victim audience. Access scoping must come from your system's own records about the document (who published it, into which collection, under whose authority), stored outside the document and not editable by its author. The same discipline applies in reverse: a chunk's source label shown to the model ('from the official handbook') must be system-assigned, or the plant claims officialdom.

Ingestion as a publishing pipeline

Treat every ingestion route as a submission to a publication you are responsible for. Crawled sources: pin an allow-list of domains and paths, re-crawl on a schedule, and diff content so silent edits to a trusted page are noticed rather than absorbed. Uploaded or contributed documents: quarantine, scan (including for instruction-like text and hidden content — white-on-white and metadata payloads are real), human or rules-based review proportionate to the audience the document can reach. Version everything, so a poisoning event can be rolled back and its exposure window (which answers cited this chunk?) answered from logs.

At answer time, prefer grounded responses with visible citations to your own UI: a user who can see the source can spot the plant, and citation logging gives you the forensic trail. Low-confidence or single-source answers on sensitive topics (money, medical, legal, account changes) deserve either corroboration requirements or a refusal to answer from retrieval alone.

Detection and response

Canary documents — harmless markers with known content seeded into collections — reveal scoping failures when they surface in the wrong audience's answers. Periodic probe suites ('what is the refund policy?' across audiences) catch drift. When poisoning is confirmed: remove the document, purge its chunks and embeddings (deleting the source file is not enough — the vectors remain), review answers that cited it, and treat the ingestion route as the vulnerability to fix, not the document as an isolated incident.

Worked example: Atlas Answers, a docs-chat vendor

Atlas Answers (fictional), powering support bots for 38 small SaaS products, let each client's team upload help-centre articles directly into the retrieval index. A scan flagged unvalidated ingestion and metadata-trusted scoping. Review found a test article — planted by a client's ex-contractor account that was never deprovisioned — claiming the product offered 'lifetime refunds on request', which the bot had quoted to at least 9 customers. Atlas rebuilt ingestion with quarantine and review for public-facing collections, moved audience scoping to system-owned collection records, purged and re-indexed the affected collection, and added canary documents per audience. The refund article's citation trail, kept by their logging, told them exactly which conversations needed a correction email.

Five things to do before you ship

  1. Inventory every ingestion route — uploads, crawlers, sync jobs, APIs — and name who can publish through each.
  2. Move audience and access scoping to system-owned records; never trust metadata supplied inside the document.
  3. Quarantine and review new documents proportionate to their reach; scan for instruction-like and hidden content before indexing.
  4. Purge chunks and embeddings (not just source files) when a document is removed, and version collections so rollbacks are possible.
  5. Seed canary documents per audience and probe key questions regularly to catch scoping and poisoning drift.

What is RAG poisoning?

manipulating the content a retrieval-augmented generation system retrieves — planted, edited or crafted documents — so the model produces attacker-chosen answers, leaks restricted content, or follows embedded instructions, all in the product's own voice.

Sources

Frequently asked questions

Isn't this just 'bad content'? Why is it a security issue?

Because the bot speaks with your authority and can be aimed: false policies create obligations, embedded instructions steer behaviour, and scoping failures leak restricted content. Content integrity at machine scale is a security property.

Can output filtering catch poisoned answers?

Partially — filters can flag known-sensitive claims, but a plausible false policy sails through. Provenance and ingestion control stop the plant; filtering is the last net, not the fence.

We only crawl our own website. Safe?

Safer, not safe: your site can be defaced, a contributor account can be compromised, or an old page can be edited maliciously. Pin sources, diff on re-crawl, and you have converted silent trust into monitored trust.

How do embeddings affect incident response?

The index is a derived copy of the poison. Deleting the document without deleting its vectors leaves the attack live. Your removal procedure must cover chunks, embeddings and any cached answers.

Related guides

Browse the full library on the guides index, run the checks in the launch audit, or compare plans on pricing.


Informational explainer, not a security guarantee. Scan your code free before every deploy.

← all guides

← Back