Lion Cipher Lab

Poison a RAG knowledge base (PoisonedRAG) and defend it: flip an answer with a few crafted documents, measure the attack success rate, then drive it back down (free, local, deterministic — no API key)

Why it matters

The moment your app answers from retrieved text, the documents it retrieves become part of its trust boundary — and most teams never treat their corpus like the security-critical asset it now is. PoisonedRAG is the sharp version of that risk: an attacker who can add even a handful of documents to your knowledge base (a wiki anyone can edit, a scraped web index, a shared drive, a support-ticket store, a user-upload feature) can make your assistant confidently state an attacker-chosen 'fact' for a specific question — a wrong dosage, a malicious download URL described as official, a competitor…

What you'll learn

Steps in this lab

  1. Two different attacks on RAG — and which one this is
  2. The two conditions a poison document must satisfy, and ASR
  3. Why relevance is not truth — the taxonomy and the judgment
  4. Set up a clean environment and install the local stack
  5. Write the deterministic RAG: corpus, targets, embedder, cosine index, reader, and the attack
  6. Measure the clean baseline: ASR = 0.00
  7. Inject the poison and watch ASR jump to 1.00
  8. Defense 1 — self-consistency (majority vote), and why bigger k cuts both ways
  9. Defense 2 — why the keyword filter fails, and the near-duplicate filter that works (with its cost)
  10. The judgment: named failure modes, and where the real boundary lives
  11. Do it better — where a production version goes

Open the full interactive lab →