Implementing Memory Protection with DEP and ASLR
When to Use
Use this skill when hardening endpoints against memory-based exploits by configuring DEP, ASLR, CFG, and Windows Exploit Protection system-wide and per-application mitigations.
Common Misconfigurations & Verification
- DEP left at OptIn: the default
nx OptIn only protects Windows components, leaving most apps unprotected. Confirm bcdedit /enum {current} shows nx AlwaysOn (or OptOut with a justified, documented exclusion list) — not OptIn.
- Per-process ASLR opt-out: an app shipping its own
.exe.config or a registry MitigationOptions value under Image File Execution Options can disable ForceRelocateImages/BottomUp just for itself, silently reopening fixed-address ROP. Run Get-ProcessMitigation -Name <app>.exe and verify ASLR.ForceRelocateImages and BottomUp are ON, not NOTSET/OFF.
- Mandatory ASLR needs both flags: system-wide mandatory ASLR is only effective with BottomUp randomization enabled too; ForceRelocateImages alone leaves predictable layouts.
- CFG assumed universal: CFG only applies to binaries compiled with
/guard:cf. Get-ProcessMitigation -Name <app>.exe may show CFG ON while the loaded module has no CFG metadata — it cannot be retrofitted, so legacy DLLs remain exploitable.
- Verification:
Get-ProcessMitigation -System should report DEP, BottomUpASLR, HighEntropyASLR, SEHOP as ON; spot-check each hardened app with Get-ProcessMitigation -Name <app>.exe to confirm the deployed XML actually applied and wasn't overridden locally.
Prerequisites
- Windows 10/11 or Windows Server 2016+ with administrative privileges
- Group Policy management access for enterprise-wide deployment
- Understanding of memory corruption attack techniques (buffer overflow, ROP chains)
- Test environment for validating application compatibility with exploit mitigations
Workflow
Step 1: Configure System-Level Mitigations
# Enable system-wide DEP (Data Execution Prevention)
# Boot configuration: OptIn (default), OptOut (recommended), AlwaysOn
bcdedit /set nx AlwaysOn
# Verify ASLR status (enabled by default on modern Windows)
Get-ProcessMitigation -System
# MandatoryASLR, BottomUpASLR, HighEntropyASLR should be ON
# Enable all system-level mitigations
Set-ProcessMitigation -System -Enable DEP,SEHOP,ForceRelocateImages,BottomUp,HighEntropy
Step 2: Configure Per-Application Mitigations
# Harden high-risk applications (browsers, Office, PDF readers)
Set-ProcessMitigation -Name "WINWORD.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
Set-ProcessMitigation -Name "EXCEL.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
Set-ProcessMitigation -Name "AcroRd32.exe" -Enable DEP,SEHOP,ForceRelocateImages,CFG
Set-ProcessMitigation -Name "chrome.exe" -Enable DEP,CFG,ForceRelocateImages
Set-ProcessMitigation -Name "msedge.exe" -Enable DEP,CFG,ForceRelocateImages
# Export configuration for deployment
Get-ProcessMitigation -RegistryConfigFilePath "C:\exploit_protection.xml"
# Deploy via Intune or GPO
Step 3: Deploy via Intune/GPO
Intune: Endpoint Security → Attack Surface Reduction → Exploit Protection
Import exploit_protection.xml template
GPO: Computer Configuration → Admin Templates → Windows Components
→ Windows Defender Exploit Guard → Exploit Protection
→ "Use a common set of exploit protection settings" → Enabled
→ Point to XML file on network share
Key Concepts
| Term |
Definition |
| DEP |
Marks memory pages as non-executable to prevent shellcode execution in data regions |
| ASLR |
Randomizes memory addresses of loaded modules to defeat hardcoded ROP gadgets |
| CFG |
Validates indirect call targets at runtime to prevent control flow hijacking |
| SEHOP |
Validates SEH chain integrity to prevent SEH-based exploitation |
Tools & Systems
- Windows Exploit Protection: Built-in per-process mitigation management
- EMET (legacy): Enhanced Mitigation Experience Toolkit (predecessor, now deprecated)
- ProcessMitigations PowerShell: Get/Set-ProcessMitigation cmdlets
Common Pitfalls
- DEP compatibility: Legacy 32-bit applications may crash with DEP AlwaysOn. Use OptOut with exceptions.
- Mandatory ASLR breaking apps: Some applications are not ASLR-compatible. Test before enforcing ForceRelocateImages.
- CFG limited to compiled-in support: CFG only works for applications compiled with /guard:cf. Cannot be retroactively applied.
1---2name: implementing-memory-protection-with-dep-aslr3description: Implements memory protection mechanisms including DEP (Data Execution Prevention), ASLR (Address Space Layout Randomization), CFG (Control Flow Guard), and other exploit mitigations to prevent memory corruption attacks. Use when hardening endpoints against buffer overflow exploits, ROP chains, and code injection. Activates for requests involving memory protection, exploit mitigation, DEP, ASLR, or CFG configuration.4license: Apache-2.05---6# Implementing Memory Protection with DEP and ASLR
7
8## When to Use
9
10Use this skill when hardening endpoints against memory-based exploits by configuring DEP, ASLR, CFG, and Windows Exploit Protection system-wide and per-application mitigations.
11
12## Common Misconfigurations & Verification
13
14- **DEP left at OptIn:** the default `nx OptIn` only protects Windows components, leaving most apps unprotected. Confirm `bcdedit /enum {current}` shows `nx AlwaysOn` (or `OptOut` with a justified, documented exclusion list) — not `OptIn`.
15- **Per-process ASLR opt-out:** an app shipping its own `.exe.config` or a registry `MitigationOptions` value under `Image File Execution Options` can disable ForceRelocateImages/BottomUp just for itself, silently reopening fixed-address ROP. Run `Get-ProcessMitigation -Name <app>.exe` and verify `ASLR.ForceRelocateImages` and `BottomUp` are `ON`, not `NOTSET`/`OFF`.
16- **Mandatory ASLR needs both flags:** system-wide mandatory ASLR is only effective with BottomUp randomization enabled too; ForceRelocateImages alone leaves predictable layouts.
17- **CFG assumed universal:** CFG only applies to binaries compiled with `/guard:cf`. `Get-ProcessMitigation -Name <app>.exe` may show CFG `ON` while the loaded module has no CFG metadata — it cannot be retrofitted, so legacy DLLs remain exploitable.
18- **Verification:** `Get-ProcessMitigation -System` should report DEP, BottomUpASLR, HighEntropyASLR, SEHOP as ON; spot-check each hardened app with `Get-ProcessMitigation -Name <app>.exe` to confirm the deployed XML actually applied and wasn't overridden locally.
19
20## Prerequisites
21
22- Windows 10/11 or Windows Server 2016+ with administrative privileges
23- Group Policy management access for enterprise-wide deployment
24- Understanding of memory corruption attack techniques (buffer overflow, ROP chains)
25- Test environment for validating application compatibility with exploit mitigations
26
27## Workflow
28
29### Step 1: Configure System-Level Mitigations
30
31```powershell
32# Enable system-wide DEP (Data Execution Prevention)
33# Boot configuration: OptIn (default), OptOut (recommended), AlwaysOn
34bcdedit /set nx AlwaysOn
35
36# Verify ASLR status (enabled by default on modern Windows)
37Get-ProcessMitigation -System
38# MandatoryASLR, BottomUpASLR, HighEntropyASLR should be ON
39
40# Enable all system-level mitigations
41Set-ProcessMitigation -System -Enable DEP,SEHOP,ForceRelocateImages,BottomUp,HighEntropy
42```
43
44### Step 2: Configure Per-Application Mitigations
45
46```powershell
47# Harden high-risk applications (browsers, Office, PDF readers)
48Set-ProcessMitigation -Name "WINWORD.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
49Set-ProcessMitigation -Name "EXCEL.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
50Set-ProcessMitigation -Name "AcroRd32.exe" -Enable DEP,SEHOP,ForceRelocateImages,CFG
51Set-ProcessMitigation -Name "chrome.exe" -Enable DEP,CFG,ForceRelocateImages
52Set-ProcessMitigation -Name "msedge.exe" -Enable DEP,CFG,ForceRelocateImages
53
54# Export configuration for deployment
55Get-ProcessMitigation -RegistryConfigFilePath "C:\exploit_protection.xml"
56# Deploy via Intune or GPO
57```
58
59### Step 3: Deploy via Intune/GPO
60
61```
62Intune: Endpoint Security → Attack Surface Reduction → Exploit Protection
63 Import exploit_protection.xml template
64
65GPO: Computer Configuration → Admin Templates → Windows Components
66 → Windows Defender Exploit Guard → Exploit Protection
67 → "Use a common set of exploit protection settings" → Enabled
68 → Point to XML file on network share
69```
70
71## Key Concepts
72
73| Term | Definition |
74|------|-----------|
75| **DEP** | Marks memory pages as non-executable to prevent shellcode execution in data regions |
76| **ASLR** | Randomizes memory addresses of loaded modules to defeat hardcoded ROP gadgets |
77| **CFG** | Validates indirect call targets at runtime to prevent control flow hijacking |
78| **SEHOP** | Validates SEH chain integrity to prevent SEH-based exploitation |
79
80## Tools & Systems
81- **Windows Exploit Protection**: Built-in per-process mitigation management
82- **EMET (legacy)**: Enhanced Mitigation Experience Toolkit (predecessor, now deprecated)
83- **ProcessMitigations PowerShell**: Get/Set-ProcessMitigation cmdlets
84
85## Common Pitfalls
86- **DEP compatibility**: Legacy 32-bit applications may crash with DEP AlwaysOn. Use OptOut with exceptions.
87- **Mandatory ASLR breaking apps**: Some applications are not ASLR-compatible. Test before enforcing ForceRelocateImages.
88- **CFG limited to compiled-in support**: CFG only works for applications compiled with /guard:cf. Cannot be retroactively applied.