When verifying JSON Web Tokens (JWTs), always specify the expected algorithm to prevent attackers from manipulating the alg attribute in the token header. Use a library that allows you to pass an explicit algorithm to verify(), such as jwt.verify(secret, token, 'HS256'). This pr…
JSON Web Tokens (JWT): how to hunt it
Where to look
- Tokens accepted with alg set to none, an empty signature or a changed payload.
- Algorithm confusion, such as an RS256 public key accepted as an HS256 secret.
- Weak HMAC secrets that can be cracked offline, and kid or jku headers that point to keys you control.
- Tokens still valid after logout or a password change, and expiry that is never checked.
What proves it
Show a token you forged or changed being accepted, and the identity or role it gives, with test accounts only.
Read further
Writeups on JSON Web Tokens (JWT), by hunters and researchers, most with a short summary.
Related classes