How to securely use JSON Web Tokens
summary
Explains JWT structure (header, payload, signature), warns never to store secrets in the base64 payload, and demonstrates two real vulnerabilities: a library-attack where an ES256 public key is reused to sign as HS256 letting an attacker forge admin tokens (demoed against an old jsonwebtoken version now patched), and acceptance of alg none allowing arbitrary payloads. Shows a session-token proof-of-failure: embedding user state prevents revocation and forces a revocation DB, negating stateless gains. Recommends short-lived tokens, verification, asymmetric keys, and alternatives like PASETO.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 0:46What are JWTs
- 2:58Signing tokens securely
- 4:24Symmetric vs asymmetric
- 5:28Dangers of none algorithm
- 6:31Algorithm confusion attack
- 8:58Use cases for JWTs
- 10:22Short-lived tokens
- 10:42Session tokens overview
- 12:08Live demo of JWT API
- 16:28Why JWTs fail for sessions
- 17:10Best practices for JWTs
- 18:37Alternatives to JWTs
