This rule is deprecated, and will eventually be removed.
Reading Standard Input is security-sensitive. It has led in the past to the following vulnerabilities:
It is common for attackers to craft inputs enabling them to exploit software vulnerabilities. Thus any data read from the standard input (stdin)
can be dangerous and should be validated.
This rule flags code that reads from the standard input.
Ask Yourself Whether
- data read from the standard input is not sanitized before being used.
You are at risk if you answered yes to this question.
Recommended Secure Coding Practices
Sanitize all data read from the standard input before using it.
Sensitive Code Example
// The process object is a global that provides information about, and control over, the current Node.js process
// All uses of process.stdin are security-sensitive and should be reviewed
process.stdin.on('readable', () => {
const chunk = process.stdin.read(); // Sensitive
if (chunk !== null) {
dosomething(chunk);
}
});
const readline = require('readline');
readline.createInterface({
input: process.stdin // Sensitive
}).on('line', (input) => {
dosomething(input);
});
See