Why it matters
One cross-site scripting flaw anywhere on the origin is then enough to steal the token and use the account from elsewhere.
How to fix it
Keep session tokens in an HttpOnly, Secure, SameSite cookie set by the server.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
export function onLogin(accessToken: string) {
localStorage.setItem("access_token", accessToken);
}export function onLogin(theme: string) {
localStorage.setItem("theme", theme);
}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
- JWT decode unverified (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-jwt-decode-unverified - Target blank noopener (TypeScript)
TypeScriptSeverity: Low
trustivan-typescript-target-blank-noopener - Next.js image SVG allowed (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-next-image-svg-allowed - Express render request object (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-express-render-request-object - Next.js image any host (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-next-image-any-host - Error stack in response (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-error-stack-in-response
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