JWT Vulnerabilities
JWT vulnerabilities include algorithm confusion, none algorithm bypass, weak secrets, and key injection attacks that allow token forgery.
These payloads are for authorized testing only — systems you own, authorized bug bounty programs, or controlled lab environments. Unauthorized testing is illegal.
What it is
JWT (JSON Web Token) vulnerabilities occur when tokens are improperly implemented or validated. Common issues include accepting the none algorithm (no signature), algorithm confusion (switching RS256 to HS256 and signing with the public key), weak HMAC secrets susceptible to brute-force, and key injection via the JWK header parameter.
Attack Vectors
- Authentication tokens in Authorization headers
- Cookie-based JWT session management
- API authentication
- OAuth/OIDC access and ID tokens
Testing Methodology
- Decode the JWT (base64) and examine the header and payload
- Test alg: none by removing the signature and setting algorithm to none
- Test RS256 to HS256 confusion by signing the token with the server's public key as HMAC secret
- Brute-force the HMAC secret with jwt-cracker or hashcat
- Test for sensitive data exposure in unencrypted payload
Payloads
Reference payloads for authorized testing. Always verify you have permission before use.
Indicators of Vulnerability
- Token with alg:none accepted by the server
- Token signed with different algorithm than expected is accepted
- Payload claims (role, admin) accepted from forged token
Detection Guidance
Enforce explicit algorithm allowlists in JWT verification. Never accept the none algorithm in production. Monitor for JWT decoding errors.
Mitigation & Remediation
- Explicitly specify and enforce the expected algorithm in JWT validation
- Never accept the none algorithm in production
- Use a strong, randomly generated secret key (256+ bits for HMAC)
- Validate all claims (exp, iss, aud) on the server
- Disable JKU/JWK header parameter processing unless specifically required
References
Responsible Use
All content in this reference is for authorized security testing only. Use only on systems you own or have explicit written permission to test.
- Systems and applications you own
- Authorized penetration testing engagements
- Bug bounty programs with defined scope
- Educational lab environments (DVWA, WebGoat, HackTheBox)