How to Enable Arbitrary Code Guard in Regedit
This article explains how to enforce Arbitrary Code Guard (ACG) on specific executable files using the Windows Registry Editor. ACG is an exploit mitigation feature in Windows that blocks dynamic code generation and modification, preventing malicious actors from executing unmanaged or injected code in memory. By adding specific registry keys and mitigation flags under Image File Execution Options, administrators can enforce ACG on targeted applications.
Prerequisites and Caution
Modifying the Windows Registry can affect system stability. Ensure you back up the registry before proceeding. Note that enforcing ACG on applications that rely on Just-In-Time (JIT) compilation (such as specific web browsers, Node.js, or Java runtimes) may cause those applications to crash or malfunction.
Step-by-Step: Enforcing ACG via Registry Editor
1. Open the Registry Editor
- Press
Windows Key + Rto open the Run dialog. - Type
regeditand pressEnter. - Select Yes if prompted by User Account Control (UAC).
2. Navigate to Image File Execution Options
In the Registry Editor address bar, navigate to the following path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
3. Create a Key for the Target Executable
- Right-click on the
Image File Execution Optionskey. - Select New > Key.
- Name the key with the exact file name of the application you want to
target (for example,
testapp.exeornotepad.exe).
4. Add the MitigationOptions Value
- Right-click the newly created key (e.g.,
testapp.exe). - Select New > QWORD (64-bit) Value (or Binary Value depending on your Windows version).
- Name this new value:
MitigationOptions
5. Set the Mitigation Flag for ACG
- Double-click the
MitigationOptionsvalue to modify it. - Set the base to Hexadecimal.
- Enter the value corresponding to dynamic code prohibition (ACG).
- To enable ACG (Disallow Dynamic Code), set the bitmask value to
0x100(or0000000000000100in 64-bit hex format). - To also enforce thread dynamic code prohibition, combine it with strict ACG policies by setting the appropriate mask bits.
- To enable ACG (Disallow Dynamic Code), set the bitmask value to
- Click OK to save the changes.
Verifying the Configuration
To confirm that ACG is active on the application:
Open PowerShell as an Administrator.
Run the following command (replace
testapp.exewith your executable name):Get-ProcessMitigation -Name testapp.exeLocate the
DynamicCodesection in the output.Verify that
ProhibitDynamicCodeis set toON.