PingPoint uptime checker injection
A network uptime checker. The host field is concatenated straight into a shell ping command.
2 solves
User input reaching a shell command unescaped, letting an attacker append a second command of their own.
OS command injection happens when user input reaches a shell command unescaped, letting an attacker append their own commands to the one the application meant to run.
$output = shell_exec("ping -c 1 " . $_GET['host']);
Shell metacharacters in $_GET['host'], such as ; whoami, don't get
interpreted as part of the hostname; the shell reads them as command
syntax, so 8.8.8.8; whoami runs the ping and then whoami as a second,
independent command.
Full remote code execution as whatever user the web server runs as, one shell metacharacter away.
$output = shell_exec('ping -c 1 ' . escapeshellarg($host)); // better still: validate the expected shape before it goes anywhere near a shell $output = shell_exec('ping -c 1 ' . filter_var($host, FILTER_VALIDATE_IP));
Escape shell arguments properly, or better, avoid invoking a shell at all when a direct system call or library can do the job, and validate the input's actual expected shape before it goes anywhere near a command.
A network uptime checker. The host field is concatenated straight into a shell ping command.
2 solves
A personal backup tool. The folder name is properly escaped; the files inside it aren't.
0 solves