node-windows
node-windows copied to clipboard
Fix Shell command built from environment values
https://github.com/coreybutler/node-windows/blob/54ac1e382f1cf56bc7278672672aba1342c96c01/lib/binaries.js#L2-L2 https://github.com/coreybutler/node-windows/blob/54ac1e382f1cf56bc7278672672aba1342c96c01/lib/binaries.js#L76-L76
fix the issue the dynamically constructed shell command should be replaced with a safer approach that avoids shell interpretation. Specifically:
- Use
execFileinstead ofexecto execute the command. This allows passing arguments as an array, which prevents the shell from interpreting special characters. - Construct the command and its arguments separately. The executable path (
path.join(bin, 'sudowin', 'sudo.exe')) should be passed as the first argument toexecFile, and the remaining parts (-pandpassword,cmd) should be passed as elements of the arguments array. - Ensure that the
cmdandpasswordvalues are properly handled to avoid unintended behavior.
The changes will be made in the sudo function on line 76.