UAC Bypass

What is Process Integrity Level?

In Windows Vista and later, processes run at three different levels of integrity:

  • High: administrator rights

  • Medium: standard user rights

  • Low: very restricted rights

What is UAC?

To perform a privileged action, a program must run another program and request the high integrity level at that time. There are four UAC settings:

  • Always Notify

    • This setting is the highest UAC setting. It will prompt the user when any program, including a built-in Windows program wants higher privileges.

  • Notify me only when programs try to make changes to my computer

    • This is the default UAC setting. This setting does not prompt the user when some built-in Windows program want higher privileges. It will prompt the user when any other program wants higher privileges. This distinction is important and it plays into the UAC bypass attack that we will cover in a moment.

  • Notify me only when programs try to make changes to my computer (do not dim my desktop)

    • This is the same as the default setting, except the user’s desktop does not dim when the UAC elevation prompt comes up. This setting exists for computers that lack the computing power to dim the desktop and show a dialog on top of it.

  • Never notify

    • This option takes us back to life before Windows Vista. On Windows 7, if a user is an administrator, all of their programs will run with high integrity. On Windows 8, programs run at the medium integrity level, but anything run by an Administrator that requests elevated rights gets them without a prompt.

Limitations

UAC Notification Levels

The UAC bypass only works when the UAC notification level is set to default value or lower (in which case we don't need to bypass it):

At "Always notify", in which case ConsentPromptBehaviorAdmin = 2 and PromptOnSecureDesktop = 1, UAC bypass will not work.

Caveat: Windows Vista

The Bypass UAC attack does NOT work on Windows Vista.

In Windows Vista, the user has to acknowledge every privileged action. This is the same as the Always Notify option in Windows 7 and later. The UAC settings in Windows 7 came about because UAC became a symbol of what was “wrong” with Windows Vista. Microsoft created UAC settings and made some of their built-in programs auto-elevate by default to prompt the user less often. These changes for user convenience created the loophole described in this post.

Enumeration

Confirm UAC by reading the registry:

reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System

If UAC is enabled, the output will look like this:

Now notice the three highlighted keys above and their values:

  1. EnableLUA tells us whether UAC is enabled. If 0 we don’t need to bypass it at all can just PsExec to SYSTEM. If it’s 1 however, then check the other 2 keys

  2. ConsentPromptBehaviorAdmin can theoretically take on 6 possible values (readable explanation here), but from configuring the UAC slider in Windows settings it takes on either 0, 2 or 5.

  3. PromptOnSecureDesktop is binary, either 0 or 1.

Exploitation (Metasploit)

In Metasploit, the UAC bypass module is:

msf6 > use exploit/windows/local/bypassuac_eventvwr

Note that UAC bypass oftentimes exists in an AD chain. For the OSCP exam, we don't want to waste the only Metasploit chance on AD chain, so we should do it manually.

Exploitation (Manually)

The easiest way of manual UAC bypass is simply uploading bypassuac-x86.exe or bypassuac-x64.exe and execute it. Locate these two executables in your system:

Reference

Last updated