Environment.IsPrivilegedProcess unexpectedly returns true on Windows
#84.137 geöffnet am 30. März 2023
Repository-Metriken
- Stars
- (17.886 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)
Beschreibung
Description
Environment.IsPrivilegedProcess return True if process is running with runas /trustlevel:0x20000 under local administrator account on Windows.
The main reason is that the local administrator account is excluded from UAC. It is unclear whether this is a bug in the GetTokenInformation. If not, then at the very least Environment.IsPrivilegedProcess behavior should be explicitly documented.
Also, I don't know if there is this problem for Service Accounts. In this case, the problem is more unpleasant and must be corrected.
Reproduction Steps
- Run process under local administrator account
- Run subprocess with
runas /trustlevel:0x20000 - Call Environment.IsPrivilegedProcess in the subprocess
Expected behavior
Environment.IsPrivilegedProcess return FALSE
Actual behavior
Environment.IsPrivilegedProcess return TRUE
Regression?
No response
Known Workarounds
No response
Configuration
.Net 8.0 Preview 2
Other information
No response