Token decoded without verifying
Token decoded without verifying. Reads a token's claims without checking its signature (jwt.decode).
This is how the comment reads inline, under the flagged line.
Why it matters
Anyone can write a JWT. Without signature verification, the claims (user id, role) are whatever the caller wants.
What to do
Use jwt.verify (or decode with the key and allowed algorithms).
Examples
const { sub } = jwt.decode(token);const { sub } = jwt.verify(token, key, { algorithms: ['RS256'] });What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const c = jwt.decode(token);
Left alone
const c = jwt.verify(token, key);
Research
A JWT decoded without verifying its signature. Anyone can write the claims, so user id and role are whatever the caller wants.
- no outside source yet
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"jwt-unverified"
],
"severity": {
"jwt-unverified": "low"
}
}
}