High-impact JWT mistakes
Many JWT incidents come from skipping issuer/audience checks or accepting tokens signed with unexpected algorithms.
Another common issue is leaking signing keys through poor secret management practices.
- Accepting any algorithm from token header.
- No `iss` or `aud` validation.
- Overly long expiration windows.
- Missing key rotation policy.
Defensive implementation checklist
Harden JWT verification with explicit algorithm allowlists and strict claim policy.
Keep short token lifetimes and pair with secure refresh/revocation mechanisms.
- Pin allowed algorithms server-side.
- Validate `exp`, `nbf`, `iss`, `aud` on every request.
- Rotate keys and track key IDs.
- Log auth failures with minimal token exposure.
FAQ
Is a strong signature enough for JWT security?
No. Claims and policy checks are equally important to avoid accepting validly signed but unauthorized tokens.
Should access tokens be long-lived?
Generally no. Short lifetimes reduce exposure and make compromise impact smaller.
Can I store JWT in browser storage?
It is possible but increases XSS exposure risk. Prefer hardened cookie/session strategies when appropriate.