What are the common JWT pitfalls?
AdvancedConceptFoundations, Threat Modeling and OWASP
Answer
- Accepting
alg: noneor letting the token choose the algorithm; pin the expected algorithm server-side. - Not validating
iss,aud,expandnbf. - HS256 with a weak or shared secret; prefer asymmetric RS256/ES256 with JWKS for multi-service setups.
- Storing tokens in
localStoragewhere XSS can read them. - Long-lived tokens with no revocation; use short expiry plus refresh tokens with rotation.
- Putting sensitive data in the payload: it is only base64url-encoded, not encrypted.
More on Foundations, Threat Modeling and OWASP
What is DevSecOps, and how is it different from DevOps?BeginnerWhat does "shift-left" mean?BeginnerIf we shift left, why do we still need "shift-right" controls?IntermediateWhat are the phases of a secure SDLC and a security activity for each?BeginnerExplain the CIA triad with a DevOps example for each property.BeginnerWhat is threat modeling and when should you do it?Beginner