How JWT (JSON Web Token) Works in Practice
Stateless APIs issue a signed JWT after login containing claims like sub (user ID), role, iat (issued at), and exp (expiration). When the client sends the JWT in an Authorization: Bearer header, the server verifies the cryptographic signature before trusting the claims. Importantly, standard JWTs (JWS) are signed, NOT encrypted—anyone can Base64URL-decode and read the payload.
Defensive Mitigation & Hardening Checklist
Explicitly whitelist allowed signing algorithms server-side (reject alg: none and prevent RS256-to-HS256 confusion), enforce short expiration times (exp), and never place sensitive secrets in the JWT payload.