Lion Cipher Lab
Analyze a JWT for security flaws
- AppSec / DevSecOps
- Beginner
- ~45 min
- Free · no account required
Why it matters
A JWT is the little signed token most modern sites and APIs hand your browser after you log in, and then trust on every request that follows. Because the server trusts whatever a valid token says, the security of a whole application often rests on how carefully that token is verified — and the same handful of mistakes show up again and again: accepting an unsigned 'alg=none' token, signing with a weak secret an attacker can guess, letting an attacker switch the algorithm from RS256 to HS256, forgetting to set an expiry, or stuffing passwords and personal data into a payload that is only…
What you'll learn
- reading the three-part structure of a JWT (header.payload.signature) and what base64url encoding is
- generating your own test JWT with a Python one-liner or a local decoder
- decoding a token and reading its registered claims (iss, sub, aud, exp)
- explaining why the payload is encoded, not encrypted, so secrets and PII do not belong in it
- recognizing the alg=none downgrade and why a verifier must pin allowed algorithms
- showing that a weak HMAC secret is guessable by recomputing the signature
- understanding RS256-to-HS256 algorithm confusion and the missing-expiry problem
- stating the defensive checklist: verify signature and algorithm, require a short expiry, use a strong secret, keep secrets out of the token
Steps in this lab
- What a JWT is — and the ground rules
- The three parts: header.payload.signature
- Generate your OWN test token
- Decode it and read the claims — no key required
- Flaw 1: the alg=none downgrade
- Flaw 2: a weak HMAC secret is guessable
- Flaw 3: algorithm confusion (RS256 to HS256) and missing expiry
- What you learned — and the defender's checklist