Repository navigation
Closed
Labels
Area-ServerDown in the muck of API call servicing, interprocess communication, eventing, etc.Down in the muck of API call servicing, interprocess communication, eventing, etc.Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Complex enough to require an in depth planning process and actual budgeted, scheduled work.Product-MetaThe product is the management of the products.The product is the management of the products.Resolution-AnsweredRelated to questions that have been answeredRelated to questions that have been answered
Description
Summary of the new feature/enhancement
Current situation:
- Suppose you are working on something in Powershell, CMD
- You went into some folder
- You built some history
- You find out that you need administrator rights for some command
Currently most console apps (Powershell, CMD) need to start a new session for getting administrator access. This results in a less optimal workflow, because then you lose
- your current working folder (you need to
cdinto it again) - your command history (the administrator session has its own history)
Proposed technical implementation details (optional)
A bit like sudo, started with a button:
- Console sessions in terminal start with default permissions
- Terminal has button with padlock icon / text "upgrade to administrator" in one of the corners
- When you click the button, the current session is upgraded to a session with admin permissions or downgraded again to normal permissions
- Session command history and location (working directory) is kept
Reacted by Thomas Freudenberg, Cai Pengcheng, Leonan, Cary Wagner, Dmego, Reilly Wood, Kuai, Todd Rylaarsdam, Maxi, Tom Bombadil and 18 more
Reacted by eabase
Metadata
Metadata
Assignees
Labels
Area-ServerDown in the muck of API call servicing, interprocess communication, eventing, etc.Down in the muck of API call servicing, interprocess communication, eventing, etc.Issue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Complex enough to require an in depth planning process and actual budgeted, scheduled work.Product-MetaThe product is the management of the products.The product is the management of the products.Resolution-AnsweredRelated to questions that have been answeredRelated to questions that have been answered
Activity
oising commentedon May 27, 2019
Hans Bakker (@hansmbakker) Windows Terminal (or any terminal for that matter) doesn't - and cannot - know anything about sessions, command history, or locations. It's just a (virtual) screen and a (virtual) keyboard that connects to whatever client (cmd, powershell, bash) the user wants to use. The responsibility for managing that information lies with the clients (applications) themselves. I understand what you're asking, and sympathize though. Using
sudoin linux/osx makes life a bit easier at the command line, but unfortunately this isn't the way the Windows operating system is structured. Admin (elevated) processes and regular or restricted processes cannot communicate with each other. If you want something running as administrator, a new process is required.Thanks for your feedback, but I'm going to close this as it's not feasible in the manner you would like.
mdtauk commentedon May 27, 2019
Couldn't each tab run in it's own isolated process - with some being elevated, and others not - but in the same Window?
oising commentedon May 27, 2019
Martin Anderson (@mdtauk) In theory, yes. But (1) this isn't what the op is asking, and (2) I'm not certain if ConPTY is baked enough to allow this yet. At a minimum, I'd imagine the main terminal process would need to be elevated, or at least some kind of proxy process would need to be, but that means we'd then have to create a means of communication between the terminal, the proxy (which is a conpty server) and the elevated app (conpty client.) Things get hairy fast after that.
mdtauk commentedon May 27, 2019
Oisin Grehan (@oising) Thanks for the reply. I think this suggestion has cropped up previously, and was wondering of the feasibility.
Its not as elegant as typing sudo or even elevate. But adding a profile for an elevated prompt which when clicked/tapped - brings up the UAC dialog, and then creates the elevated tab within the window - could be useful.
hansmbakker commentedon May 27, 2019
It's a pity that it is unfeasible, but thank you for your explanation.
DHowett-MSFT commentedon May 27, 2019
Hosting a connection to an elevated process in a window owned by a medium-integrity (that is: not elevated) process is dangerous because any other medium-integrity process could possibly inject input into it or scrape output from it. That’s the sole reason we’ve been given by the windows security team to not endeavour to do this.
hansmbakker commentedon May 27, 2019
Thanks for being transparent about it.
On the technical side, I’m wondering why
sudoworks while what I asked for can cause risks?mdtauk commentedon May 27, 2019
Sudo is a Linux concept, and the way User and Admin concepts are handled between Linux and Windows are very different, and I guess that is what makes it not possible.
sedwards2009 commentedon May 28, 2019
Anytime someone uses
sudoinside a terminal running on their normal Windows account, that scenario happens. It is extremely common. Linux users/admins do it all the time. My web browser also has access to mega-tons of sensitive data and accounts which I care about, but the browser itself is also just a normal process subject to the attack described above.I'm not really familiar with the Windows security model and what is possible, but is it an idea for the terminal process to run protected from injection and scraping by default?
zadjii-msft commentedon May 28, 2019
Dustin L. Howett (MSFT) (@DHowett-MSFT) do we have a sudo megathread that combines all the 100 ways we've said no? Because we really should at this point
[-]Feature Request: Ability to upgrade existing session to session with admin rights[/-][+]Megathread: sudo, runas, mixed elevation of tabs, etc.[/+]13 remaining items
alefranz commentedon Aug 23, 2019
I have a maybe related question.
Would hosting a process of a powershell running on a remote machine through RemoteApp not be feasible for similar reason?
yllekz commentedon Nov 15, 2019
Could Windows Terminal instead treat the tabs as individual processes running as whatever user you choose? The host WindowsTerminal.exe could run as the current user but the tabs could have options to run as a separate user.
Honestly the lack of this feature will probably make or break my decision to even use this because I have a need to run PS as different users to properly secure environments and fulfill RBACs.
gerardog commentedon Jan 16, 2020
For the brave, let me introduce you a workaround based on
gsudo, my open-sourcesudo for windowsimplementation. (MIT License)Install gsudo, then add a new profile to Windows Terminal:
This allows Windows Terminal to mix elevated and non-elevated consoles. Also, you can use
gsudoto elevate simple commands from a non-elevated console.gsudohas an experimental ConPty mode, not enabled by default (usegsudo --vt [command]) that works pretty much that way. It spans the elevated process in a PseudoConsole and streams VT sequences to the non-elevated console.According to that criteria, is it safe to
ssh root@otherserverfrom a non elevated console? Other non-elevated process could also inject or scrape ssh or the console.Anyway, I've read this advice seriously and while I've already taken all security meassures that I could think of, I am totally open to criticism, advice, suggestions or bug reports.
EDIT: looks like

linux sudohas always beenvulnerablein this way. (I've only tested using WSL)ossdesign commentedon Apr 4, 2020
Gerardo Grignoli (@gerardog) Thanks for sharing the "gsudo" workaround (and for putting it together!!) I gave it a try, and it works well enough for my needs at this point. I don't know enough about how the security stuff works to know how big off on an issue it is to launch a new tab like this.
I have historically (and still do) use ConsoleZ, which really is a just a "wrapper" to launch hidden (launched off-screen at some large negative (-XXXXX, -XXXXX) coordinates, and then does some trickery with what is available to read and write to it (I have read there is screen scraping involved to read, but do not know the details.) This being the case, I assume each tab really is just interacting with its own Cmd, PowerShell, whatever process. I assume ConEmu and others do something similar.
I guess the question is, it sounds like Windows Terminal does not just wrap other processes. I know knowing about the evolving low-level Windows plumbing involved with this, so I don't know the issues involved. And I don't know for sure what the security concerns may be using "gsudo" as you outline above. For my usage cases, it gives me a quick elevated Cmd (or PowerShell) tab to get something, and then get out. Either way, thanks!
grave0x commentedon May 1, 2020
would something like this work? https://github.com/lukesampson/psutils/blob/master/sudo.ps1
tho i have no idea how you'd run it without Powershell
matthew4850 commentedon Jun 22, 2020
When you do
echo test > /dev/tty2it first runs the echo command and then writes its output to/dev/tty2so while it is possible for a lesser privileged process to write to attyused by a high privileged process, it is not possible for the lesser privileged process to run a command with higher privileges.DHowett commentedon Jun 22, 2020
I'm more concerned about whatever X11 allows than "i can write to a tty device" (which only impacts the output stream)
Spec for Windows Terminal Process Model 2.0 (#7240)
darealshinji commentedon Feb 14, 2021
Glenn Sarti (@glennsarti):
Create a fresh shortcut (right click desktop -> new shortcut) and enter
wt.exeas the target. That will allow you enable "Run as Administrator". You can find an icon to use here in the directoryressylveon commentedon May 28, 2021
Random thought: wouldn't it be possible, in Windows, to allow unelevated app to opt-in to UIPI (via the app manifest, for example) so that they are effectively isolated like admin apps, while still not actually running as admin?
That would resolve the scraping/injection concern, opening up the possibility to run mixed tabs elevation.
zadjii-msft commentedon May 28, 2021
Charles Milette (@sylveon) That's maybe possible, though I don't know about that too much. Would that break screen readers or other accessibility tools? Or even IMEs? I'd love to see a proof-of-concept!
sylveon commentedon May 28, 2021
Screen readers, IMEs and other accessibility tools already use UI Access to punch a hole in UIPI, so there shouldn't be much of an issue here.
However I can't come up with a PoC because it would require platform support (afaik) and I'm not a Windows developer yet ;)
zadjii-msft commentedon May 28, 2021
Huh. Shame I'm on leave for the next month, otherwise I'd give it a go. Maybe when I get back...
Oh wait, nevermind. That's why this won't work:
so the problem here is
OH I see - you're suggesting that we modify UIPI to enable this scenario, rather than "this is something that you can do as an app developer today". Okay. That makes more sense. I'm all over the place today. Sorry for the confusion.
sylveon commentedon May 28, 2021
Indeed, I was suggesting modifying UIPI in the OS itself to support this scenario: blocking the communication between malicious.exe and wt.exe even at the same (or lower) IL
Spec for Elevation QOL improvements (#8455)