Exploit Analysis: The JWT Algorithm 'none' Attack (And the Guard)

A technical analysis of the most dangerous auth misconfiguration. How to engineering static analysis guards to eliminate 'none' exploits.

4 min read
Exploit Analysis: The JWT Algorithm 'none' Attack (And the Guard)

A single line of configuration can forge a JWT. Here is the technical analysis of the 'none' algorithm attack, and the automated static analysis guard that eliminates this architectural risk.

JWT authentication is everywhere. It's also one of the most misconfigured security mechanisms.

One line of code can compromise everything.

The Vulnerable Code

javascript
// โŒ This looks fine...
const decoded = jwt.verify(token, secret, {
  algorithms: ['HS256', 'none'], // ๐Ÿ’€ The vulnerability
});

The Attack

javascript
// 1. Attacker takes a valid JWT:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiIxMjM0NTYiLCJyb2xlIjoidXNlciJ9.
signature_here

// 2. Modifies the header to use "none" algorithm:
eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.
eyJzdWIiOiIxMjM0NTYiLCJyb2xlIjoiYWRtaW4ifQ.
// No signature needed!

// 3. Server accepts it because "none" is in algorithms list
// Attacker is now admin

Real CVEs

CVELibraryImpact
CVE-2015-2951jwt-simpleAlgorithm confusion
CVE-2016-10555jose2goNone algorithm bypass
CVE-2018-0114node-joseKey confusion

The Fix

javascript
// โœ… Explicitly whitelist algorithms
const decoded = jwt.verify(token, secret, {
  algorithms: ['HS256'], // Only what you use!
});

All JWT Vulnerabilities

1. Algorithm None

javascript
// โŒ Dangerous
jwt.verify(token, secret, { algorithms: ['none'] });

// โœ… Safe
jwt.verify(token, secret, { algorithms: ['HS256'] });

2. Algorithm Confusion

javascript
// โŒ Dangerous: RS256 token verified with symmetric secret
jwt.verify(token, publicKey);

// โœ… Safe: Explicit algorithm
jwt.verify(token, publicKey, { algorithms: ['RS256'] });

3. Weak Secret

javascript
// โŒ Dangerous: Brute-forceable
jwt.sign(payload, 'password123');

// โœ… Safe: Strong secret
jwt.sign(payload, process.env.JWT_SECRET); // 256+ bits

4. Missing Expiration

javascript
// โŒ Dangerous: Token valid forever
jwt.sign({ userId: 123 }, secret);

// โœ… Safe: Short expiration
jwt.sign({ userId: 123 }, secret, { expiresIn: '1h' });

5. Sensitive Payload

javascript
// โŒ Dangerous: Password in token (tokens can be decoded!)
jwt.sign({ userId: 123, password: 'secret' }, key);

// โœ… Safe: Only IDs
jwt.sign({ userId: 123 }, key);

ESLint Coverage

javascript
// eslint.config.js
import jwtPlugin from 'eslint-plugin-jwt';

export default [jwtPlugin.configs.recommended];

13 JWT Rules

RuleCWEWhat it catches
no-algorithm-noneCWE-347Algorithm "none" allowed
no-algorithm-confusionCWE-327RS/HS confusion attacks
no-weak-secretCWE-326Brute-forceable secrets
no-hardcoded-secretCWE-798Secrets in code
no-sensitive-payloadCWE-312PII in tokens
require-expirationCWE-613Missing exp claim
require-algorithm-whitelistCWE-327No explicit algorithms
require-issuer-validationCWE-345Missing iss check
require-audience-validationCWE-345Missing aud check
no-decode-without-verifyCWE-347jwt.decode() misuse
require-issued-atCWE-613Missing iat claim
require-max-ageCWE-613No maxAge in verify
no-timestamp-manipulationCWE-345Clock skew exploits

Error Messages

bash
src/auth.ts
  15:3  error  ๐Ÿ”’ CWE-347 CVSS:9.8 | JWT algorithm 'none' is allowed
               Risk: Attackers can forge tokens without a signature
               Fix: Remove 'none' from algorithms: ['HS256']

Quick Install

::dev-to-cta{url="https://npmjs.com/package/eslint-plugin-jwt in 60 seconds. 13 rules. Full JWT security. Zero false positives.**


๐Ÿ“ฆ npm: eslint-plugin-jwt ๐Ÿ“– Rule: no-algorithm-none

โญ Star on GitHub


The Interlace ESLint Ecosystem Interlace is a high-fidelity suite of static code analyzers designed to automate security, performance, and reliability for the modern Node.js stack. With over 330 rules across 18 specialized plugins, it provides 100% coverage for OWASP Top 10, LLM Security, and Database Hardening.

Explore the full Documentation

ยฉ 2026 Ofri Peretz. All rights reserved.


Build Securely. I'm Ofri Peretz, a Security Engineering Leader and the architect of the Interlace Ecosystem. I build static analysis standards that automate security and performance for Node.js fleets at scale.

ofriperetz.dev | LinkedIn | GitHub

Built with Nuxt UI โ€ข ยฉ 2026 Ofri Peretz