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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -