Code Injection via eval() and Function constructor
Description
Detects user input flowing to code execution functions like eval() or Function constructor.
What Shoulder detects
How to fix
Use JSON.parse for data or predefined function maps instead of eval().
```javascript
const data = JSON.parse(userInput);
// Or use a function map
const ops = { add: (a,b) => a+b };
ops[action]?.(x, y);
```
Learn more: https://shoulder.dev/learn/javascript/cwe-94/code-injection
Applies to
Languages
Frameworks
express
fastify
References
Scan for this issue
Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=javascript-code-injection .
Real-world examples
Known CVEs in the Code Injection vulnerability class that this rule helps detect.