JWT Security Walkthrough Signed is not secret. Valid is not authorized. 0 · Start Three parts, one dot apart Header alg · typ Payload sub · exp · iss · aud Signature integrity . . Base64URL is not encryption Anyone can decode it. Only the key proves it. 1 · Anatomy Stateless has a price JWT stateless revoking is hard Session cookie server-side state instant logout Need instant logout? Prefer sessions. 2 · Do you need it? Who can mint a token? Public key private key consumers can only verify Shared secret secret every holder can forge 3 · Signing Pick strong, pin one public key EdDSA ES256 PS256 shared secret HS256 HS384 HS512 avoid none RS256 (old) allow one, in your code Never let the token choose its algorithm 4 · Algorithms Strong random secrets only Do random 256+ bit secrets manager Never a password hardcoded in code non-crypto random too short 5 · Secrets The header is attacker input Header alg algorithm confusion jku / x5u SSRF jwk attacker's own key kid injection trusted keys Keys come from your config, not the token 6 · Header risks Validate every claim iss · who signed aud · is it for me exp · not expired nbf · not too early sub · right subject typ · right purpose Optional in the spec? Require them anyway. 7 · Claims No signature, no entry "alg": "none" signed Allowlist algorithms. Reject none. 8 · alg: none Public key as a secret public key HS256 ES256 only algorithms=["ES256"] Bind each key to one algorithm 9 · Alg confusion Never fetch the attacker's key own jwk / jku attacker key kid trusted JWKS kid picks a trusted key. It never creates trust. 10 · Trusted keys A token is for one service IdP aud: payments Payments Internal API check aud Reject tokens meant for someone else 11 · Audience Bind keys to issuers Combined keys issuer A issuer B one key set Own keys each issuer A issuer B Exact iss match, then that issuer's keys only 12 · Issuer Right token, right job at+jwt logout+jwt reset+jwt typ? API ID, logout and reset tokens are not access tokens 13 · Token type Ways to cancel a token Short-lived access tokens Denylist jti + iss Status list status claim Sender-bound DPoP · mTLS Key denylists on claims, not raw token bytes 14 · Revocation A stolen token needs a key token + proof no private key API DPoP or mTLS binds the token to its holder 15 · Replay Signed is not secret Signed (JWS) anyone can read it Encrypted (JWE) only the recipient can No passwords or secrets in claims 16 · Confidential? Sign, then encrypt Issuer Consumer Claims Sign Encrypt Decrypt Verify Validate Decryption alone proves nothing. Verify the signature. 17 · Sign + encrypt Checklist at a glance Pin algorithm No alg none Strong keys Trusted keys iss + aud exp + nbf Token type Revocation Replay guard Payload clean JWE if needed Verify first 18 · Recap
← Previous
Next scene →
▶ Auto-play
Use Previous / Next (or the arrow keys) to step through all 19 panels, or Auto-play for a hands-free presentation. The SVG artwork is embedded in this page.