How to fix: JWT 'none' Algorithm Accepted
The response body contains patterns suggesting JWT tokens with the 'none' algorithm may be accepted, or the JWT library is used without explicit algorithm restriction.
Why it matters
The JWT 'none' algorithm attack allows an attacker to forge any JWT payload without knowing the signing key. By setting alg: 'none' and removing the signature, an attacker can impersonate any user including admins.
AI-generated JWT verification code often omits the `algorithms` whitelist parameter. Libraries like jsonwebtoken default to accepting any algorithm unless explicitly restricted. The 'none' algorithm means the token is unsigned and trivially forgeable.
How to fix it
- 1Always specify the allowed algorithms explicitly: jwt.verify(token, secret, { algorithms: ['HS256'] }).
- 2Never accept 'none' as a valid algorithm.
- 3Upgrade to a well-maintained JWT library and check its default algorithm handling.
- 4Consider switching to opaque session tokens stored server-side for simpler, safer session management.
Code examples
Safe JWT verification
import jwt from 'jsonwebtoken';
// Bad (AI-generated, no algorithm restriction)
const payload = jwt.verify(token, process.env.JWT_SECRET);
// Good
const payload = jwt.verify(token, process.env.JWT_SECRET, {
algorithms: ['HS256'], // Explicit whitelist: rejects 'none' and RS256
});References
Detected automatically by VulnRadar. The check id is vibe-jwt-none-alg, stable across every scan so you can filter or diff on it.
More ai code checks
- LowGeneric Error Messages Leak No Context
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalHardcoded Credential in Authentication Logic
- CriticalSQL String Concatenation Pattern Detected
- MediumStack Trace Exposed in Response
Questions
- How severe is JWT 'none' Algorithm Accepted?
- VulnRadar rates this critical severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id vibe-jwt-none-alg, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does JWT 'none' Algorithm Accepted map to?
- It maps to CWE-347. In the OWASP Top 10 it falls under A02:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.