Lion Cipher Lab

Exploit and fix predictable password-reset tokens (weak randomness)

Why it matters

Almost every application hands out secret strings that are supposed to be unguessable: password-reset tokens, session identifiers, API keys, email-verification links, 'remember me' cookies, one-time codes. The security of all of them rests on a single, quiet assumption — that an attacker cannot predict the next value. And the most common way that assumption fails is not a broken algorithm or a leaked key; it is a developer reaching for the FIRST random function their language offers. `random` in Python, `Math.random()` in JavaScript, `rand()` in C, `mt_rand()` in PHP — these are…

What you'll learn

Steps in this lab

  1. PRNG vs CSPRNG: the one distinction the whole lab rests on
  2. Build the vulnerable 'app': a time-seeded reset token
  3. Attack it: brute-force the seed and regenerate the exact token
  4. Fix it: mint the token with a CSPRNG
  5. Re-measure: run the identical attack against the fixed token
  6. What a CSPRNG does NOT fix — harden the whole reset flow
  7. Do it better — spotting weak randomness in the wild

Open the full interactive lab →