Skip to content

Profiles shouldn't unnoticeable shared through UAC #17148

Closed

Description

@iRon7

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.0

Propose

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:
2022-04-13_17h25_53

(not sure how this whole issue would apply to other operating systems)

Activity

  1. added
    Needs-Triage
    on Apr 13, 2022
  2. added
    WG-Security
    on Apr 14, 2022
  3. jhoneill commented on Apr 14, 2022

    @jhoneill

    Foreign scripts should not be able to pass UAC and execute unseen by piggybacking on other domestic scripts as the $Profile.

    This is a very good aim.

    However.

    1. What is the definition of "Foreign" and "Domestic". We know it is common to use the remote signed execution policy but how many unsigned scripts immediately have "downloaded from the internet" flag removed. If an attacker is inside already they can sign scripts, and make the them look "domestic": when I worked for the the Formula 1 team I gave this pseudo code example that I could put in a signed all-users-all-hosts script (And they said when I was leaving that if something clever and malicious happened they'd blame me!).
    if ((james acccount is not present or not enabled) -and (timing looks nasty) -and (account is priviledged) {
    get-adComputer | foreach-object -parallel -throttlelimit 10000 {stop-computer $_.name -force}
    }
    
    1. If I have the access needed to modify your profile, then I can see that it is signed, and I probably have the access I need to sign my version with your certificate. A feature that adds work for me on the basis that if I'm attacked, the attacker will also need to do that work isn't going to win me over. And only a small subset of those who gain access for malice will use this kind of attack, a less oblique attack is much more likely ( IMHO )
    2. UAC edits the Administrators group out of the access token on the shell when a user (other than the default admin) logs on interactively and "run as admin" creates a process with the unedited token (some process are automatically trusted and others go via a UAC prompt). Things like scheduled tasks don't do UAC each time, and some roles give privileges to non admin accounts, so the UAC prompt isn't the be-all and end all.
    3. A group policy setting which allowed "require AllSigned for admin users" would help: perhaps something which specified paths (with wildcards) which must be signed that could be applied to specific users or specific computers would be better. But we know the people who need it are the ones who don't do security well, and so they are the ones who won't use it. The ones who will use it are doing security well enough that they are very unlikely to need it. Catch-22 :-)

    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.

  4. PaulHigin commented on Apr 18, 2022

    @PaulHigin
    Contributor

    @WG-Security
    Since you think this may be a security vulnerability, please report it through Secure@. Please see PowerShell Security Policy.

  5. iRon7 commented on Apr 19, 2022

    @iRon7
    Author

    Since you think this may be a security vulnerability, please report it through Secure@

    Done: #17148 Profiles shouldn't unnoticeable shared through UAC CRM:0461307699

  6. removed
    Needs-Triage
    on May 2, 2022
  7. added
    Resolution-No Activity
    on Nov 15, 2023
  8. iRon7 commented on Nov 15, 2023

    @iRon7
    Author

    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"

  9. removed
    Resolution-No Activity
    on Nov 15, 2023
  10. added
    Resolution-No Activity
    on May 13, 2024
  11. microsoft-github-policy-service commented on May 13, 2024

    @microsoft-github-policy-service
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityWG-Security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions