Security
JWT pitfalls: multiple-choice review
Six questions that cut across the whole unit. Each one mirrors a real verification decision — not a definition to recite, but a trust boundary to defend under an attacker who controls the token.
Confirm you can connect the JWT failure modes — algorithm trust, key binding, claim checks, revocation, and storage — into one rule: never let the token describe how it should be verified.
A library version accepts a token whose header is alg:none with an empty signature segment and returns valid. Why is this catastrophic, and what is the one-line fix?
In the RS256-to-HS256 confusion attack, what is the secret the attacker signs the forged token with, and why does the server accept it?
A service correctly pins alg:RS256 and verifies the signature, but a token minted for a different microservice in the same trust domain is accepted as its own. Which claim check is missing?
A token's header carries a kid that points at https://attacker.example/jwks.json, and the server fetches the key from that URL to verify. What is the failure, and the fix?
A user reports their session was hijacked. With a stateless JWT, why can't you log them out server-side, and what bounds the damage?
A SPA must survive page refreshes. Which storage split does a security-minded senior ship, and why?
The through-line across the unit is one rule: never trust the token to describe its own verification. alg:none and RS256-to-HS256 confusion both die when you pin an explicit algorithm allowlist and bind each key to one algorithm; attacker-controlled kid/jku die when you resolve keys only against a pinned allowlist. A valid signature is necessary but not sufficient — check aud and iss so a token is scoped to THIS service. And because a stateless token cannot be un-issued, short access TTLs, refresh-token rotation with reuse detection, and XSS-aware storage bound whatever leaks.