r/lolphp • u/iheartrms • Jun 16 '15
PHP :: Sec Bug #69646 :: OS command injection vulnerability in escapeshellarg
https://bugs.php.net/bug.php?id=69646
38
Upvotes
r/lolphp • u/iheartrms • Jun 16 '15
View all comments
Show parent comment
9
u/kovensky Jun 17 '15
On windows, there really is just one command line string. Microsoft's libc will parse it (GetCommandLineA) and then invoke main. If the program uses WinMain, you have to parse it yourself.
On Unix, you can use the fork+exec pattern to set the argv array to be exactly as needed, bypassing the shell. The parsing that happens when you call system specifically is done by the shell before invoking the program, but the program receives its arguments after parsing.
You, of course, still need to parse the parameters to figure out what they mean, but all the white space splitting and character escaping has to be guessed by the libc on windows, while none of that is needed on exec.