Lion Cipher Lab

Defend a RAG pipeline against indirect prompt injection: poison a document, watch the model obey it, then shut it down (free, local Ollama — no API key)

Why it matters

The moment your app answers questions using text it retrieved — a document, a web page, a support ticket, an email — you have opened a second, quieter door for attackers. Direct prompt injection is what a user types; INDIRECT prompt injection is an instruction hidden inside the content your pipeline pulls in and hands to the model. Because a language model cannot reliably tell your instructions apart from instructions buried in the data it is reading, a single poisoned document can make it leak secrets, follow a malicious link, or quietly change its answer for everyone who asks. RAG systems…

What you'll learn

Steps in this lab

  1. Direct vs INDIRECT prompt injection — the word that matters here
  2. Why the data channel is the dangerous one, and why you can't just filter it
  3. Install Ollama and pull two small models (embedder + chat)
  4. Write the pipeline: a tiny local RAG with one poisoned document
  5. Run it naive and watch the model obey the document
  6. The layered defense: spotlighting, a strict system prompt, and an output gate
  7. Re-test: same poison, no bite
  8. The judgment: why marking is not enough, and the one rule that is
  9. Do it better — where a production version goes

Open the full interactive lab →