Command Injection
Command Injection
Category: Injection
Severity: Critical
Description
Command injection is an attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable application. Command injection attacks are possible when an application passes unsafe user supplied data (forms, cookies, HTTP headers etc.) to a system shell.
Impact
The attacker extends the default functionality of a vulnerable application, causing it to pass commands to the system shell, without needing to inject malicious code. In many cases, command injection gives the attacker greater control over the target system.
Remediation
Set up input validationโto prevent attacks like XSS and SQL Injection.
Create a white listโof possible inputs, to ensure the system accepts only pre-approved inputs.
Use only secure APIsโwhen executing system commands such as execFile()
Use execFile() securelyโprevent users from gaining control over the name of the program. You should also map user input to command arguments in a way that ensures user input does not pass as-is into program execution.
Last updated