phpsafe 𝕏 GitHub
Official CA 421DTkQ3TSG3n7F9SkNZj9NxvdFGbypwkctPd2uupump This is the only official address.

Shell command execution

Severity: Critical CWE-78 OWASP A03:2021 Injection rule: exec

Why it matters

Input passed to the shell can append extra commands with characters such as ; or |, handing the attacker control of the server. Validate the value strictly and quote every argument.

βœ• Vulnerable
system('ping -c 1 ' . $_GET['host']);
βœ“ Secure
$host = $_GET['host'] ?? '';
if (!filter_var($host, FILTER_VALIDATE_IP)) {
    exit('Invalid address');
}
system('ping -c 1 ' . escapeshellarg($host));

How to fix

Avoid shell calls. If you must, pass each argument through escapeshellarg() and never include user input in the command name.

Scan my code

Paste a file and PHP Safe points to every line that matches this rule.

Scan my code β†’