Why it matters
Anyone who can read the repository can mint tokens the service accepts.
How to fix it
Read the key from the environment or a secret manager, and rotate the one that was committed.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
const jwt = require("jsonwebtoken");
function issue(user) {
return jwt.sign({ sub: user.id }, "change-me-before-launch", { expiresIn: "1h" });
}const jwt = require("jsonwebtoken");
function issue(user) {
return jwt.sign({ sub: user.id }, process.env.JWT_SIGNING_KEY, { expiresIn: "1h" });
}What TrustIvan reads
Runs on repository scans of JavaScript 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 none algorithm (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-jwt-none-algorithm - CORS reflected origin with credentials (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-cors-reflected-origin-with-credentials - Insecure random secret (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-insecure-random-secret - Cookie HttpOnly disabled (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-cookie-httponly-disabled - Weak cipher (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-weak-cipher - PostMessage wildcard origin (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-postmessage-wildcard-origin
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