Skip to content
mentoor

Topic 3 of 4 · 4 min read

Poisoned and manipulated knowledge bases

Goal: Assess an ingestion pipeline for poisoning risk and add provenance and review controls for untrusted sources.

Whoever can write to a source your pipeline ingests can steer your answers, so control who writes, record where each chunk came from and review what enters the index.

Check yourself · 1 of 3

Why is an open-edit company wiki a poisoning risk for a RAG assistant?

Choose one answer

Why it matters

A RAG app answers from what it retrieves. An attacker, or an honest mistake, that puts a document into the index changes what the app says. The PoisonedRAG paper (2024) showed that adding a handful of crafted texts per target question to a large knowledge base could make the system give an attacker-chosen answer. Each text was written to be both similar to the target question, so it wins retrieval, and to contain the false answer, so the model repeats it. You do not need to break in. An editable wiki, a public web crawl, a shared drive or a customer upload is enough.

How to do it

  1. List every source and who can write to it. For each one, ask "who can add or edit a file here without review?" Public pages, open wikis, email inboxes and user uploads are untrusted.
  2. Tier your sources. Trusted: reviewed policy repository. Semi-trusted: internal wiki. Untrusted: web, email, uploads. Keep tiers in metadata and keep untrusted content out of the index that answers high-stakes questions.
  3. Record provenance on every chunk: source, URL or path, author, ingestion time, content hash and the pipeline run that created it.
  4. Review before publish. New or changed documents from semi-trusted sources go through a diff review or an approval step before the index version is promoted.
  5. Show and weigh sources. Display the citation so users can check it, and prefer trusted tiers when chunks conflict.
  6. Monitor. Alert on a new document that suddenly ranks first for many important queries, on sources with a burst of edits and on near-duplicates of existing policy text.
  7. Make rollback cheap. Index by version, so a bad ingestion run can be removed by its run id.

Before and after

Before: a nightly job crawls the whole company wiki and any shared-drive folder into one index. After: only the approved policy repository feeds the answer index. Wiki pages enter a separate tier, labelled in the answer, and each chunk carries source, author, sha256 and run_id.

What goes wrong

  • Treating "internal" as trusted. One compromised account or careless editor poisons answers for everyone.
  • No provenance. Without a source on each chunk you cannot find or remove the bad document.
  • Reviewing the model, not the corpus. Evaluation sets that never include planted documents will not show the weakness.

Examples

The editable pricing page

A sales assistant ingests the public wiki. Someone edits the discount page to say "Enterprise customers get 90% off on request". The edited page is a close match for "what discount can I offer?" and now wins every time. With a content hash and author on each chunk, the changed page is flagged, and a reviewer reverts it from the run log.

Copying the pipeline plan

Sources: policy-repo (reviewed), wiki (open edit), uploads (any user)
Index A: policy-repo only -> answers about refunds, legal, pricing
Index B: wiki + uploads -> labelled "unverified" in answers
Each chunk: source, author, sha256, run_id, tier
Promotion: diff review for wiki changes touching A's topics

The split keeps untrusted writers away from the answers that matter.

Key points

  • Anyone who can write to an ingested source can influence answers; map who that is.
  • Poisoned texts are written to rank first for target questions and to carry the wrong answer.
  • Tier sources by trust and keep untrusted content out of high-stakes indexes.
  • Record source, author, hash and ingestion run on every chunk so bad content can be traced and removed.
  • Version the index and review changes from semi-trusted sources before promoting them.

Common mistakes

  • Assuming internal documents are trustworthy because they sit behind a login.
  • Ingesting everything into one index with no record of where each chunk came from.
  • Adding documents automatically with no review or ability to roll back an ingestion run.
  • Evaluating retrieval quality on clean data only, never on planted or conflicting documents.

Check yourself · 2 of 3

What does recording a content hash, author and run id on every chunk let you do?

Choose one answer

Check yourself · 3 of 3

A pipeline ingests a reviewed policy repo, an open wiki and user uploads into one index. What is the best change?

Choose one answer

Practice items, not counted towards your mastery.

Start here