Why it matters
If any part of that string can be influenced by user input, this is arbitrary code execution in the page or the Node.js process.
How to fix it
Replace eval() with a parser for the specific data format expected (for example JSON.parse for JSON), or restructure the code so no dynamic evaluation is needed.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
function run(input) {
return eval(input);
}function run(input) {
return JSON.parse(input);
}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
- SQL injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-sql-injection - Command injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-command-injection - Path traversal from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-path-traversal - SSRF from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-ssrf - Reflected XSS from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-reflected-xss - DOM XSS from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-dom-xss
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