Why it matters
A caller can write any claims they like.
How to fix it
Verify with jwt.verify(token, key, { algorithms: [...] }) or jose's jwtVerify on the server before trusting any claim.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
import jwt from "jsonwebtoken";
export function currentUser(token: string) {
const claims = jwt.decode(token) as { sub: string };
return claims.sub;
}import jwt from "jsonwebtoken";
export function currentUser(token: string) {
const claims = jwt.verify(token, process.env.JWT_KEY!, { algorithms: ["HS256"] }) as { sub: string };
return claims.sub;
}What TrustIvan reads
Runs on repository scans of TypeScript source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Next.js image SVG allowed (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-next-image-svg-allowed - Token in localStorage (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-token-in-localstorage - Next.js image any host (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-next-image-any-host - Target blank noopener (TypeScript)
TypeScriptSeverity: Low
trustivan-typescript-target-blank-noopener - Next.js public secret (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-next-public-secret - Express render request object (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-express-render-request-object
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation