Lion Cipher Lab

Build a Bloom filter for breached-password screening, and measure its false-positive rate

Why it matters

NIST's password guidance says that when someone sets or changes a password, the service SHALL compare it against a blocklist of commonly used, expected or compromised passwords, and make them pick another if it is on the list. That list can be big. The obvious ways to hold it are a database or an in-memory set, and a set of one million passwords took 86 MB in this lab. A BLOOM FILTER holds the same million in 1.2 MB and answers in one of two ways: 'definitely not on the list' or 'probably on the list'. It is a classic tool, and it shows up in browsers, databases and caches. But it only works…

What you'll learn

Steps in this lab

  1. The problem: screen new passwords against a big blocklist without holding the whole list
  2. Set up: a terminal, Python, and a lab folder
  3. Generate a synthetic 'breach' and a disjoint clean set
  4. Build the filter: m bits, k positions, double hashing
  5. Size it from a target false-positive rate, then measure the real rate
  6. Mis-size it on purpose: the wrong k, and an overfilled filter
  7. Memory and speed: the filter vs a set vs a sorted list
  8. Honest negative 1: a false positive is a person told their fine password is breached
  9. Honest negative 2: you cannot delete from a plain Bloom filter
  10. Honest negative 3: the filter file is not a secret
  11. Do it better: where a Bloom filter fits in a real password check

Open the full interactive lab →