The 'none' Algorithm Vulnerability
What you'll learn: How attackers exploit JWT implementations that accept the 'none' algorithm to completely bypass signature verification.
The Core Idea
In the previous lesson, you learned that JWTs support different signature algorithms like HS256 or RS256. The JWT specification also includes a 'none' algorithm intended for situations where the JWT's integrity is already protected by another mechanism (like a secure channel).
The vulnerability occurs when a JWT library or application accepts the 'none' algorithm in production without proper validation. An attacker can take a valid JWT, change its payload to grant themselves admin privileges or access other users' data, set the algorithm to "none", remove the signature entirely, and the server will accept it as valid.
How It Works
Think of it like a document that says "This document must be notarized" — but also accepts documents that say "This document doesn't need a notary." If you accept both types without question, anyone can forge the second type.
A typical attack looks like this:
- Attacker receives a legitimate JWT:
header.payload.signature - Decodes the header and changes
"alg": "HS256"to"alg": "none" - Modifies the payload (e.g.,
"admin": true) - Re-encodes header and payload, but removes the signature
- Sends:
modified_header.modified_payload.(notice the trailing dot with no signature) - Vulnerable server sees
alg: none, skips signature verification, and trusts the token
Prevention
Always explicitly whitelist allowed algorithms and never include 'none' in production environments. Reject any JWT using the 'none' algorithm unless you have a very specific, isolated use case.
Key Takeaway: The 'none' algorithm vulnerability lets attackers forge JWTs by removing signature verification entirely — always reject 'none' in production and explicitly validate the algorithm before processing tokens.