-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
VBS Shell.Application and PowerShell Start-Process do not escape ampersands internally #2419
Comments
@bitcrazed, please would you take a quick look at this. It's easy to reproduce. |
Please don't do that. conhost is not involved in |
@jorangreef Appreciate you filing the issue. It would, at first glance, seem like it's the command-line's job to launch these processes, but it is not! PowerShell's Trying to find someone involved in CreateProcess et al. to help out. Stay tuned. |
Thanks @bitcrazed, appreciate you looking into this and getting people involved. |
Just an update for everyone following this: We're now thinking to work around this simply by copying It's an ugly (but beautiful) hack... It shouldn't be necessary... but it is. @bitcrazed thanks for your help with this, as a last-ditch effort, if there's anyone you can rope in on this it would be much appreciated. |
I am not certain how copying cmd.exe from Windows (which will have the same issues as the ones in-box) will help. Can you explain that a bit more? |
@DHowett @bitcrazed |
I dunno why Rich thought to bring this one to the Terminal repo, I'm pretty sure we have no influence over how VBS escapes its arguments. Also, the original repo that was looking into this looks like it's archived? https://github.com/jorangreef/sudo-prompt. If people are really still interested, I could try digging up the current maintainer of VBS, if there still is one. I suppose it repros even without VBS, with start-process -FilePath .\foo.bat -verb runas (in and that prompted to spawn but yea that seems like somewhere in I'd REALLY recommend not copying |
I don't work on this anymore but why closing it if the issue is not solved ? |
I would agree with @zvin that this shouldn't be closed, at least not until it's handed off correctly to the appropriate team. Especially, since this is probably a latent security issue in how Windows does escaping of the ampersand. I would guess it's also deeper than both VBS and PowerShell since it's common to both. Hopefully, someone can find a team for this to belong to :) |
Environment
Steps to reproduce
Create a directory named
q&a
.Within this directory create a
bat
file namedelevate.bat
with the following contents:vbs
file namedelevate.vbs
with the following contents:Then double-click
elevate.vbs
.Expected behavior
Windows prompts for administrator privileges and then the batch script executes and outputs "hello".
Actual behavior
Windows prompts for administrator privileges but the batch script never executes, because Windows does not escape the ampersand in the current working directory correctly.
The interesting thing here is we are relying on the current working directory to pass the full path to the
elevate.bat
script. This leaves all escaping to Windows.If the full path to these files has no ampersand, i.e.
qa
instead ofq&a
, everything will work.But, if the full path includes an ampersand, Windows itself won't escape the ampersand when ShellExecute expands the path to elevate.bat.
This can also be reproduced using a PowerShell Start-Process script, making me think it's something common to both.
We found this while working through jorangreef/sudo-prompt#97.
The text was updated successfully, but these errors were encountered: