Lion Cipher Lab
Build a DLP guard for LLM outputs — catch PII and secret leakage before it reaches the user, and measure it
- AI Security
- Advanced
- ~60 min
- Free · no account required
Why it matters
An LLM app leaks sensitive data through its RESPONSES: a customer's email or card number pulled from context, an API key echoed back from a config file, another tenant's record surfaced by a RAG retrieval. Telling the model "don't reveal secrets" is not a control — the model is non-deterministic and can be injected into ignoring the instruction. The real control is a deterministic scanner that inspects every response BEFORE it reaches the user and blocks or redacts leaks. This is OWASP LLM02:2025 Sensitive Information Disclosure. Anyone can bolt on a regex; the job is to prove it works — so…
What you'll learn
- output-side data-loss-prevention (DLP) for LLM apps
- detecting PII & secrets with regex, a Luhn check, and Shannon entropy
- building a labeled evaluation corpus with deliberate near-misses
- measuring a detector: confusion matrix, precision, recall, false-positive rate
- knowing the deterministic ceiling and when to escalate to a NER model
Steps in this lab
- The threat: your model answers, and the answer contains a secret
- Set up a scratch folder
- Build the detector: regex + Luhn + Shannon entropy + allowlist
- Build a labeled corpus — including deliberate near-misses
- Measure it — read the confusion matrix
- Read the tuned numbers — what each knob bought you
- Redact and fail closed — turning detection into a control
- Judgment: the ceiling, when to escalate, and defense-in-depth