child_process.exec()
The node:child_process function that runs a whole command string through a shell and buffers all its output in memory.
Building an exec() command from user input lets attackers run any command with your service's permissions.
In more detail
Because the shell interprets the string, any user input pasted into it can add extra commands. Output larger than maxBuffer kills the child.
Related terms
- execFile() — The node:child_process function that runs a program directly, without a shell, and buffers its output.
- command injection — An attack where input meant as data, such as a file name or form field, gets run as commands because a program built code from it.
- shell — The program that reads the commands you type, runs them and shows the results; sh and bash are common ones.
Taught in
- Child Processes: spawn, execFile, fork & IPC — Node.js Internals & Backend Services