the_open_door
coffee
ESEN
← Back to index

AppLocker Bypass

ATT&CKT1218

AppLocker is Windows application control: an allowlist of what may run, defined by path, hash or publisher signature. It is almost always deployed with the rules it ships with, and that is the problem, because those rules allow everything under C:\Windows and C:\Program Files out of the box.

Mechanism. The default rules are path based, and C:\Windows is not a uniform directory: it contains folders an unprivileged user can write to. Drop your own binary in one of them and it falls under a rule that allows it. The other route needs no writing at all: use a system binary signed by Microsoft that can execute foreign code, which is what is known as a LOLBIN.

The first step is reading the effective policy, not the one that is supposed to be there:


Get-AppLockerPolicy -Effective -Xml
Get-ChildItem C:\Windows\Tasks, C:\Windows\Temp, C:\Windows\Tracing   # classic writable paths
<FilePathRule Id="921cc481-6e17-4653-8f75-050b80acca20" Name="(Default Rule) All files located in the Windows folder"
              Description="Allows members of the Everyone group to run applications in the Windows folder"
              UserOrGroupSid="S-1-1-0" Action="Allow">
  <Conditions><FilePathCondition Path="%WINDIR%\*" /></Conditions>
</FilePathRule>

That rule, exactly as shipped, allows anything under %WINDIR%, including the folders the user can write to.

Requirements. Code execution on the host as any user. AppLocker does not distinguish privilege: it applies the same list to everyone unless rules are defined per group.

How to detect it. AppLocker's own log is the source: 8004 (execution blocked) and above all 8003 (allowed only because the policy is in audit mode). An 8003 is an alarm, not a note. Beyond that, what gives the bypass away is context: a binary executing from C:\Windows\Tasks or C:\Windows\Temp, or a signed LOLBIN launched with arguments that do not look like its normal use and with an odd parent process, such as a console or an office application.

Defence. Do not deploy the default rules without reviewing them: explicitly exclude the writable paths under C:\Windows, or better, replace path rules with publisher and hash rules. Add the LOLBINs Microsoft publishes as dangerous to the block list. And as the structural fix, move to WDAC, which applies the policy to the .NET engine and to scripts too, not only to the executable.