Lion Cipher Lab

Decode and normalize encoded prompt injection before your input filter, and measure what still slips through

Why it matters

Most LLM apps put a filter in front of the model: a list of phrases like 'ignore previous instructions' checked against everything a user types and every document the app retrieves. It feels like a defence, and against the plain phrase it is. But the filter matches characters, and the model reads meaning. Write the same instruction in base64, hex, ROT13 or leetspeak and the filter sees noise while a capable model can still decode and follow it - the 2023 Jailbroken paper by Wei, Haghtalab and Steinhardt documents exactly this gap. In this lab the naive filter caught every plain canary…

What you'll learn

Steps in this lab

  1. What an input filter is, and why an encoded instruction walks past it
  2. Open a terminal, check Python, and make a scratch folder
  3. Build the labelled corpus: canary attacks in 14 encodings, and benign text that is legitimately encoded
  4. The naive filter: six regex patterns, and what it sees
  5. Build the decode-and-normalize layer: bounded views, one filter call per view
  6. Measure detection per encoding: naive against careful against aggressive
  7. Read the false-positive table: what decoding does to benign traffic
  8. Measure why every bound exists - and the blind spot the size limit creates
  9. What still slips through, and what each obvious patch costs
  10. The judgment: where a decode-and-filter layer belongs, and how a pro deploys it
  11. Recap, and one experiment: raise the depth and watch what moves

Open the full interactive lab →