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: MEDIUM auth.jwt.no-audience

JWT is being verified without checking the aud (audience) claim.

Why AI tools produce this: AI coding tools produce this regularly, typically when prompted for a shortcut or a quick fix.

Why this matters

A token issued for one of your services (e.g. an internal worker) can then be replayed against another service that trusts the same key, leading to confused-deputy attacks.

Pass { audience: 'your-api' } to jwt.verify (or validate the aud claim manually) on every verification path.

RFC 7519 §4.1.3 defines the aud claim explicitly for this use case.

VULNERABLE
vulnerable.ts
import jwt from 'jsonwebtoken';

// ruleid: auth.jwt.no-audience
export function verifyBad(token: string) {
  return jwt.verify(token, process.env.JWT_PUBLIC_KEY!, { algorithms: ['RS256'] });
}

// ruleid: auth.jwt.no-audience
export function verifyBad2(token: string) {
  return jwt.verify(token, process.env.JWT_PUBLIC_KEY!);
}

// ruleid: auth.jwt.no-audience -- callback form without audience
export function verifyBad3(token: string) {
  jwt.verify(token, process.env.JWT_PUBLIC_KEY!, { algorithms: ['RS256'] }, (_e, _d) => {});
}
SAFE
safe.ts
import jwt from 'jsonwebtoken';

// ok: auth.jwt.no-audience
export function verifyGood(token: string) {
  return jwt.verify(token, process.env.JWT_PUBLIC_KEY!, {
    algorithms: ['RS256'],
    audience: 'example-api',
  });
}

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-audience -- <reason>

References

https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3 ↗