Skip to main content
CriticalAI codeOWASP A02:2021CWE-347

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

  1. 1Always specify the allowed algorithms explicitly: jwt.verify(token, secret, { algorithms: ['HS256'] }).
  2. 2Never accept 'none' as a valid algorithm.
  3. 3Upgrade to a well-maintained JWT library and check its default algorithm handling.
  4. 4Consider switching to opaque session tokens stored server-side for simpler, safer session management.

Code examples

Safe JWT verification

TypeScript
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.

See every ai code check

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.

Propose a checkHow a check is built

Scan your own site for jwt 'none' algorithm accepted

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: JWT 'none' Algorithm Accepted | VulnRadar