Skip to content

launch: what an elevated WinRust starts gets the session's own token - #142

Open
Tkyoxx wants to merge 1 commit into
Lemxy:mainfrom
Tkyoxx:pr/15-launch-session-token
Open

Tkyoxx wants to merge 1 commit into
Lemxy:mainfrom
Tkyoxx:pr/15-launch-session-token

Conversation

@Tkyoxx

@Tkyoxx Tkyoxx commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What

The bar runs as admin (its task has the highest run level) and so does the installer. common::launch::program gave what they started a runas /trustlevel:0x20000 token made from their admin one. That token says it is elevated (High integrity, TokenElevationTypeFull) while the Administrators group is deny-only, and UAC cannot raise it: an app started that way that asked for admin rights quietly got another copy without them (on a PC set to elevate without prompting; with a prompt it fails too). reshell and rs-launcher carried it after every install or update until the next sign-in, and so did rust-explorer opened from the bar or with Win+E.

From a caller that really is admin (IsUserAnAdmin), program() now borrows the token of the session's sihost.exe (Explorer's when it is missing) through CreateProcessWithTokenW: the token a program started from the desktop gets, Medium integrity, a split token UAC can raise. rtaskmgr's profiles already start programs this way (sys::run_unelevated). Other callers keep runas /trustlevel.

Test

  • cargo test -p winrust-common
  • Install or update rust-search and topbar, then look at the tokens. Before: reshell and rs-launcher were TokenElevationTypeFull / High / Administrators deny-only. After: Limited / Medium, like Explorer (checked on Windows 10 21H2).

The bar runs as admin and the installer does too; program() gave what they
started a runas /trustlevel "basic user" token made from their admin one.
That token reports itself elevated (High integrity) with the
Administrators group deny-only, and UAC cannot raise it: an app started
that way that asked for admin rights quietly got a copy without them.
reshell and rs-launcher carried it after every install or update until the
next sign-in, and so did rust-explorer opened from the bar or with Win+E.

From a caller that is really admin, program() now borrows the token of the
session's sihost.exe (Explorer's when it is missing), the token a program
started from the desktop gets, through CreateProcessWithTokenW. Other
callers keep runas /trustlevel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant