Rule Definition
The software receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax before using the input in a dynamic evaluation call.
Remediation
If possible, refactor your code so that it does not need to use setTimeout() at all.
Violation Code Sample
setTimeout(function(){ alert("Hello"); }, 3000);
Fixed Code Sample
function delayedFunction() {
alert("This is a delay");
}
// safe - direct call of the function
window.setTimeout(delayedFunction, 100);
Reference
http://cwe.mitre.org/data/definitions/95.html
https://www.owasp.org/index.php/Top_10_2013-A1-Injection
https://www.w3schools.com/js/js_best_practices.asp
Related Technologies
Technical Criterion
CWE-95 - Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection')
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.