dotnet/runtime

Environment.IsPrivilegedProcess unexpectedly returns true on Windows

Open

#84,137 建立於 2023年3月30日

在 GitHub 查看
 (5 留言) (2 反應) (0 負責人)C# (5,445 fork)batch import
area-System.Runtimedocumentationhelp wantedos-windows

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

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

  1. Run process under local administrator account
  2. Run subprocess with runas /trustlevel:0x20000
  3. 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

貢獻者指南