Knowledge Base · general

JWT Attacks

generaltechnique notetechniquejwt

Weaknesses in JSON Web Token validation: alg:none, algorithm confusion (RS256→HS256), weak secrets, and unvalidated claims.

How it works

  • alg:none — strip the signature and keep a trailing dot; a trusting verifier accepts it.
  • RS256→HS256 confusion — sign with HMAC using the RSA public key as the secret.
  • Also check kid path traversal, jku/x5u URL injection, and crackable HMAC secrets (hashcat -m 16500).

Detection & defence

  • Pin the expected algorithm server-side; never trust the header alg.
  • Verify the signature before reading any claim; keep keys out of the token.