Repository navigation
Description
Issue
I am not sure whether this actually qualifies as a security vulnerability (especially because it is apparently accepted as normal behavior) but I think it is not correct that by default (for Windows servers and where the Execution Policy is lowered) the profile between a standard user account and elevated administrator account is unnoticeable shared and invoked.
User Account Control
User Account Control (UAC) helps prevent malware from damaging a PC and helps organizations deploy a better-managed desktop. With UAC, apps and tasks always run in the security context of a non-administrator account, unless an administrator specifically authorizes administrator-level access to the system. UAC can block the automatic installation of unauthorized apps and prevent inadvertent changes to system settings.
For Windows servers and where the Execution Policy is lowered, malware might easily copy itself to the user's profile ($PROFILE.CurrentUserCurrentHost) and proceed (unnoticed!) with elevated rights whenever the user starts PowerShell from the explorer 'Run as Administrator' context menu.
Expected behavior
Foreign scripts should not be able to pass UAC and execute unseen by piggybacking on other domestic scripts as the $Profile.
Actual behavior
PowerShell is able to silently copy and invoke (possible malicious) code accepted by the standard user account in an elevated administrator account.
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Propose
As a practical workaround, I would recommend to restrict the Execution Policy when PowerShell is ran as administrator by setting the $PROFILE.AllUsersAllHosts as a standard (knowing administrators should be able to consciously change this).
Basically (from an elevated prompt):
Set-Content $PROFILE.AllUsersCurrentHost { # or $PROFILE.AllUsersAllHosts?
$WindowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$WindowsPrincipal = [System.Security.Principal.WindowsPrincipal]::new($WindowsIdentity)
if ($WindowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) {
Set-ExecutionPolicy -ExecutionPolicy AllSigned -Scope Process
}
}This would require the user to (re)sign the $Profile when modified. Signing should be limited to a specific "CodeSigners" group and self-signing can only be done with elevated rights.
(Other possibilities to achieve the same results might be using a separate user/admin execution policies and/or changing the explorer context menu)
This will cause user profiles to be disabled if not signed when running as an elevated administrator:

(not sure how this whole issue would apply to other operating systems)
Activity
jhoneill commentedon Apr 14, 2022
This is a very good aim.
However.
None of the above is meant to say this is non-problem, but there is a lot more to it, which needs to be considered in seeking a solution.
PaulHigin commentedon Apr 18, 2022
@WG-Security
Since you think this may be a security vulnerability, please report it through Secure@. Please see PowerShell Security Policy.
iRon7 commentedon Apr 19, 2022
Done:
#17148 Profiles shouldn't unnoticeable shared through UAC CRM:0461307699iRon7 commentedon Nov 15, 2023
Please either mark this issue with something like Resolution-Declined or put it on a kind of wishlist "Issue we would like to prioritize, but we can't commit we will get to it yet"
microsoft-github-policy-service commentedon May 13, 2024
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.