criticalCWE-327A02:2021

JWT Algorithm None

Accepting 'none' as a valid JWT signing algorithm lets attackers forge tokens without a secret key.

How It Works

JWT headers carry an 'alg' field. If your verification code accepts 'alg: none', an attacker can strip the signature entirely and craft a token claiming to be any user. The server trusts it because it never checks a real signature.

Vulnerable Code
// BAD: allows attacker to set alg=none and skip signature
jwt.verify(token, secret, { algorithms: ['HS256', 'none'] });
Secure Code
// GOOD: explicitly whitelist only the algorithm you actually use
jwt.verify(token, secret, { algorithms: ['HS256'] });

Real-World Example

CVE-2015-9235 — the original 'alg:none' bypass affected multiple JWT libraries. Auth0 patched their library after researchers showed any user could become an admin by editing the token header.

How to Prevent It

  • Always pass an explicit algorithms whitelist to jwt.verify()
  • Never include 'none', 'RS256' alongside 'HS256', or any algorithm you don't use
  • Prefer a battle-tested library like jose instead of rolling your own verification
  • Run automated scans to catch algorithm misconfigurations before they reach production

Affected Technologies

Node.js

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities