Windows driver registry type confusion can be turned into a kernel write primitive
The missing RTL_QUERY_REGISTRY_TYPECHECK flag in the driver’s registry handler can be exploited to achieve a kernel write primitive and local privilege escalation.
Security & privacy Trail of Bits 5 May 2026 Disclosure Prototype evidence
Published as “Escalating a Windows driver registry bug to a kernel write primitive”
Why it matters
It demonstrates that missing type-check flags in driver registry code can be turned into kernel write primitives, underscoring the need for strict validation in kernel drivers.
Summary
The writeup examines a Windows driver that uses RtlQueryRegistryValues without the RTL_QUERY_REGISTRY_TYPECHECK flag. By supplying crafted REG_BINARY values, the authors cause the driver to write arbitrary data onto its stack, overwriting a function pointer. This yields a semi-controlled write-what-where primitive that can be used for local privilege escalation. The exploit is demonstrated in a lab environment with a single driver and synthetic registry keys.
Caveats 4
- The bugcheck code is KERNEL_SECURITY_CHECK_FAILURE, which isn’t really what we would expect if we successfully overwrote some of the stack.
- This downgrades us from a potential kernel privilege escalation bug to a local denial of service.
- This depends on stack alignment, however, and it would not be surprising if the 32-bit readValue variable ended up 64-bit aligned, leaving a gap, so this approach may not get us far in practice.
- Whether or not the driver’s request endpoint can be called from a low IL is a different matter, but this is just for fun and style points, so let’s ignore that for now.
What’s new here 4
- Identifies missing RTL_QUERY_REGISTRY_TYPECHECK flag as a kernel-mode type-confusion bug
- Shows how REG_QWORD, REG_SZ, and REG_BINARY values can be leveraged to gain kernel write primitives
- Demonstrates discovery of writable keys in trusted system hives using Get-AccessibleKey
- Introduces a Claude c-review skill for automated C/C++ security checklist enforcement