Verification··6 min read·By Veer Bhanushali
Stopping JWT algorithm confusion, kid path traversal, and jku spoofing
Enforce strict asymmetric algorithm allowlists and pinned issuer JWKS URLs instead of trusting headers embedded inside incoming tokens.
Key takeaway
Never pass algorithms from the JWT header into jwt.verify(); pin expected alg, iss, and aud values strictly on the server.
Why jku and kid headers belong to untrusted input
Every JSON key inside the decoded JOSE header arrives from the client. Reading jku directly fetches attacker keys via SSRF, while unvalidated kid values can inject path segments or SQL fragments.