Lion Cipher Lab

Write a JWT/OIDC access-token validator from scratch — and break the naive ones

Why it matters

A JSON Web Token (JWT) is how nearly every modern OAuth 2.0 / OpenID Connect system tells your API 'this request is from an authenticated user.' It is three base64url-encoded parts joined by dots — a header, a payload of claims, and a signature — and the ONLY thing standing between a real token and a forged one is whether you check that signature correctly. That check is where teams get owned. The classic disasters are not exotic: a verifier that decodes the payload but never verifies the signature; a verifier that trusts the token header's own `alg` field and so accepts `alg:none` (no…

What you'll learn

Steps in this lab

  1. What a JWT actually is (three parts, and only one protects you)
  2. Stand up a fake IdP and mint one valid RS256 token
  3. The WRONG way: a naive verifier that trusts the payload
  4. Check #1 — verify the RS256 signature (defeats forgery)
  5. Check #2 — PIN the algorithm (defeats alg:none and RS256->HS256 confusion)
  6. Check #3 — validate the claims: exp/nbf, iss, aud (defeats replay & stale tokens)
  7. Check #4 — select the key by kid from a known set (defeats unknown / path-traversal kid)
  8. Fire everything at BOTH validators — the scoreboard
  9. The judgment: build-your-own to LEARN, then use the library

Open the full interactive lab →