In short
A JWT (JSON Web Token) is a signed token that carries a user’s identity and permissions. If implemented incorrectly, it can be forged: an attacker modifies its content (for example, to become an administrator) and the server accepts it. Common causes include accepting the “none” algorithm, a signature secret that is too weak, confusion between algorithms, and failure to verify expiration.
The most common vulnerabilities
- “None” algorithm: the server accepts an unsigned token if the header specifies it.
- Weak secret: A short or default HMAC secret can be cracked via brute force, allowing any token to be signed.
- Algorithm confusion: a server expecting RS256 accepts HS256 and verifies the signature using the public key as the secret.
- Unverified signature: the content is decoded and used without verification.
- No expiration or revocation: a stolen token remains valid indefinitely.
- Sensitive data in the token: it is signed, not encrypted; its contents are readable by anyone.
Best Practices
- Set the expected algorithm on the server side, without reading the one in the header.
- Use a long, random secret or an asymmetric key pair.
- Always verify the signature, expiration (exp), issuer (iss), and audience (aud).
- Short lifetimes, with a renewal and revocation mechanism.
Frequently asked questions
Is a JWT encrypted?
No, a standard JWT (JWS) is only signed: its content is Base64-encoded and readable. Encryption is a feature of a different format, the JWE.
Sources
Find out where an attacker would get in.
Our AI agents actually attack your scope, fully automated, and hand you the proof of every vulnerability.
