v0.14 is out: a mobile auth pack for Swift/iOS and Android, catching insecure token storage, cleartext traffic, and OAuth in embedded WebViews. Read more →
MEDIUM AI PREVALENCE: HIGH auth.jwt.no-algorithms-allowlist

jwt.verify(...) is called without an explicit algorithms allowlist.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

Without pinning the accepted algorithms, a token signed with an unexpected algorithm (or even alg: none on older versions) can be accepted, opening the door to algorithm-confusion attacks.

Always pass the algorithm(s) you actually expect, e.g. { algorithms: ['RS256'] }.

VULNERABLE
vulnerable.ts
import jwt from 'jsonwebtoken';

// ruleid: auth.jwt.no-algorithms-allowlist
export const claims1 = jwt.verify(token, process.env.JWT_SECRET!);

// ruleid: auth.jwt.no-algorithms-allowlist
export const claims2 = jwt.verify(token, publicKey, {
  audience: 'https://api.example.com',
  issuer: 'https://auth.example.com',
});

// ruleid: auth.jwt.no-algorithms-allowlist
export const claims3 = jwt.verify(token, secret, {});

// ruleid: auth.jwt.no-algorithms-allowlist
export const claims4 = jwt.verify(token, secret, { ignoreExpiration: true });
SAFE
safe.ts
import jwt from 'jsonwebtoken';
import { jwtVerify } from 'jose';

// ok: auth.jwt.no-algorithms-allowlist
export const claims1 = jwt.verify(token, publicKey, { algorithms: ['RS256'] });

// ok: auth.jwt.no-algorithms-allowlist -- algorithms + audience pinned together
export const claims2 = jwt.verify(token, publicKey, {
  algorithms: ['RS256'],
  audience: 'https://api.example.com',
});

// ok: auth.jwt.no-algorithms-allowlist -- signing is out of scope
export const signed = jwt.sign({ uid: 1 }, secret, { algorithm: 'HS256' });

// ok: auth.jwt.no-algorithms-allowlist -- jose has its own verification API
export const joseClaims = await jwtVerify(token, key);

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

// oauthlint-disable-next-line auth.jwt.no-algorithms-allowlist -- <reason>

References

https://datatracker.ietf.org/doc/html/rfc7518#section-3.1 ↗https://owasp.org/www-project-api-security/ ↗