-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
escapeshellarg() dangerous on windows (always assumes bash escape rules) #395
Comments
I think this function should just be removed. I mean, what's the correct behaviour on the Web, which has no shell? |
And what about other operating systems that aren't Windows or UNIX? Just throw an error? |
well the php behavior is to check if it's running on Windows, if yes use cmd escape-rules, otherwise use POSIX escape rules.. not sure if we should follow suite or delete the function. anyhow, you can apparently check if you're running on Windows or not by running if((typeof window === "undefined" ? process.platform : window.navigator.platform).toString().indexOf("Win") === 0 ){
// running on Windows
} else {
// Not windows
} |
related to issue locutusjs#395
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
Thanks for reporting, I fixed this in the associated commit |
Description
Windows/cmd has quite different escaping rules from bash, and the current escapeshellarg() function always assumes it's running on bash, even if it's running on windows. this could allow hackers to execute programs on command-line-arguments created from user input. for example:
notepad 'test.txt & dir &;'
which to microsoft's cmd.exe means roughly: open notepad with the argument test.txt and run the command
dir
simultaneously.. escapeshellarg() needs to check if it's running on Windows or not, and then use OS-specific escape rules, at least that's what PHP's escapeshellarg() does.
The text was updated successfully, but these errors were encountered: