Skip to content

WDAC & AppLocker

Bypassing WDAC

Reading and writing custom policies

  1. Use Syslifters/wdacparse to decode .cip binaries under C:\Windows\System32\CodeIntegrity\CIPolicies\Active\ into XML.
  2. Review <Allow> rules (paths, publishers, hashes), e.g. <FileRules><Allow ID="ID_ALLOW_A_0001" FilePath="C:\Data\test\*" /></FileRules>.

If we have a signing cert or if the policies are unsigned, we can write our own ones.

  1. Modify the rule you want to update to contain an exclusion.
  2. From XML, generate a new binary with PowerShell ConvertFrom-CIPolicy (module ConfigCI) and copy the .cip to C:\Windows\System32\CodeIntegrity\CIPolicies\Active\.
  3. Run CiTool --update-policy "{GUID}.cip" from that path. Confirm with CiTool.exe -lp.

Concept for restricting PowerShell capabilities

Goal: restrict Microsoft PowerShell functionality on Windows clients and servers to reduce risk in case a Windows device is compromised.

Feasibility and practicality must be validated in a real rollout test before broad deployment.

Measures

Apply the following measures on all Windows clients and servers:

  • Enable Constrained Language Mode via a WDAC policy.
    • This restricts sensitive PowerShell features, making post-compromise privilege escalation harder from within a PowerShell session.
  • Set Script Execution Policy to AllSigned.
    • All scripts intended for execution must be signed.
    • Note: this policy is easy to bypass and mainly prevents accidental execution of unsanctioned scripts.
  • Enable Script Block Logging and Protected Event Logging.
    • PowerShell commands are logged and protected via encrypted logging (requires decryption on a central log collector; if that doesn’t exist, Protected Event Logging can be skipped).
  • Updates
    • Ensure PowerShell version (>= 5) is installed.
  • Disable PowerShell version 2
    • PowerShell v2 lacks key security features such as Constrained Language Mode and can be used to bypass controls.
    • PowerShell v3 and v4 can’t be started if PowerShell (>= 5) is installed, so no extra action is required for those versions.
  • Antivirus
    • Ensure scripts executed via PowerShell (including in-memory) are detected and blocked by AV.

Implementation notes

More information regarding Constrained Language Mode.

Regular effectiveness reviews

  • Perform an effectiveness review after implementation (e.g., by an external assessor).
  • Evaluate improvement opportunities annually and reassess settings (e.g., as part of a pentest or a dedicated review).