
Proof of concepts demonstrating some aspects of the Windows kernel shadow stack mitigation.
This project aims to highlight certain aspects of the shadow stack mitigation implemented by Microsoft in Windows 11. The code is specifically focused on Windows 11 24H2. It may not work on other version of Windows 11, due to the kernel offset management.
The project is divided into two parts: a client and a driver. Communication between them is handled through the IOCTL mechanism. The client requests the driver to perform actions at the kernel level.
CR4 register, leading to a BSODtry/except and shadow stack behaviors during a division by zeroUse build.bat.
As a prerequisite, the following kits have to be for the same Windows build:
Note:
The POC have been tested with the version 10.0.26100.0 of the kits.
To activate the kernel shadow stack mitigation, the following values have to be added or set in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceGuard\ key:
| Name | Type | Data |
|---|---|---|
| EnableVirtualizationBasedSecurity | REG_DWORD | 1 |
| Scenarios\HypervisorEnforcedCodeIntegrity\Enabled | REG_DWORD | 1 |
| Scenarios\KernelShadowStacks\Enabled | REG_DWORD | 1 |
Also, in order to load a test-signed driver, the following command have to be run in an administrator console:
bcdedit /set testsigning on
Then, a reboot is required.
To load the driver, the following commands have to be entered in an administrator console:
sc create shadow type= kernel binPath= ABSOLUTE_PATH_TO_THE_DRIVER
sc start shadow
The client has the following options:
SergiusTheBest for its FindWDK.
| Option | Description |
|---|
| inc | Increment the return address to the caller by 1 |
| skip | Patch RSP in order to point on the previous stack frame |
| cdisable | Disable CET in CR4 |
| cenable | Enable CET in CR4 |
| wrmsr REGISTER VALUE | Write the REGISTER with the given VALUE |
| wrshsk | Write into the shadow stack |
| wrshskpte | Rewrite the shadow stack PTE |
| div DIVIDEND DIVISOR | Perfom integer division in kernel space |