OS command injection High

OS command injection is a critical vulnerability that can lead to a full system compromise as it may allow an adversary to pass in arbitrary commands or arguments to be executed.

Detector ID
php/os-command-injection@v1.0
Category
Common Weakness Enumeration (CWE) external icon

Noncompliant example

1$username = $_COOKIE['username'];
2// Noncompliant: Incorporating variable into command strings
3exec("wto -n \"$username\" -g", $ret);

Compliant example

1$fullpath = $_POST['fullpath'];
2// Compliant: escapeshellarg() is used to prevent command injection
3$filesize = trim(shell_exec('stat -c %s ' . escapeshellarg($fullpath)));