highLogins, sessions and access
JWT Strategy Weakened
The JWT configuration accepts expired tokens or uses a secret written in the code.
Why it matters
Expiry is what limits the damage of a stolen token; ignoring it turns a one-hour leak into a permanent one. A secret in the source is in every clone and every build log. A fallback like process.env.JWT_SECRET || 'dev-secret' is the same thing in production if the variable is ever missing.
What it looks like
This is the shape of code that triggers the rule. AI tools produce it because it works, and nothing tells them it is unsafe.
ignoreExpiration true
import { Strategy, ExtractJwt } from 'passport-jwt';
super({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), ignoreExpiration: true, secretOrKey: config.get('JWT_SECRET') });The smallest fix
minimal patch
// jwt.strategy.ts
super({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: config.getOrThrow<string>('JWT_SECRET'),
});The better fix
If you have a few more minutes, this is the approach that holds up as the app grows.
safe alternative
// Use ConfigService with validation so the app refuses to start without
// JWT_SECRET, and keep access tokens short-lived with a refresh flow.Let your AI tool fix it
When the scanner finds this in your project, it fills in the file and line for you. This is the prompt it gives you to paste into Claude Code, Cursor or whatever you use.
In [the file] at line [the line number] the JWT configuration is weakened: [the flagged code]. Set ignoreExpiration to false, read the secret from ConfigService.getOrThrow('JWT_SECRET') with no string fallback, and add JWT_SECRET to .env.example. If a secret was committed, rotate it.
How to check the fix worked
1. Sign a token with an exp in the past and confirm a 401. 2. Start the app without JWT_SECRET and confirm it fails to boot.