url - cleaning untrusted inputs that build os commands in PHP? -
how remove untrusted inputs build os commands url in php?
when running automatic testing zaproxy, getting alert of p1 inputs building os commands. want know how clean commands.
use escapeshellarg()
, escapeshellcmd()
escape data usage shell command or argument.
// escapes single argument // sample input: "/foo/bar/" $argument = escapeshellarg($userinput1); exec("ls $argument"); // escapes special characters [];{} usage in command line // sample input: "ls -l; rm -rf /" $command = escapeshellcmd($userinput2); exec($command);
you should use both commands prevent users executing arbitrary commans on server.
documentation:
http://php.net/manual/en/function.escapeshellarg.php http://php.net/manual/en/function.escapeshellcmd.php
Comments
Post a Comment