Web Security · Middle · Question 65 of 75
Which Node.js call is most dangerous with user input?
- 1
execFile('convert', [fileName, 'out.png']) - ✓Correct answer:
exec('convert ' + fileName + ' out.png') - 3
fs.readFile(safePath)with a validated path
Explanation
exec passes the string to a shell, so ; rm -rf / in the name becomes a command. execFile with an argument array avoids the shell.