Broken Contracts in the DirectX Kernel: Local Elevation of Privilege & Hyper-V Guest-to-Host Remote Code Execution
b2ahex (Independent Security Researcher), Zhu Qing (Security Researcher · Snowrock)
BlueHat Asia 2026 · Day 1 · Main Stage
Overview
This talk, presented by independent security researcher b2ahex (Rai) and Snowrock's Zhu Qing, delves into a series of critical vulnerabilities discovered within the DirectX kernel and the Hyper-V graphics stack. The core theme revolves around "broken contracts" – implicit security rules governing object lifecycle, identity, and cleanup that, when violated, lead to severe security flaws. The researchers uncovered a total of 32 related bugs, with 26 receiving CVE IDs, demonstrating a systemic issue within these Windows components.

Key moments
- 0:00 Introduction and impact of vulnerabilities
- 4:30 Local EoP: D3D Handle Table Race (Double Free)
- 11:30 Guest-to-Host RCE: Hyper-V host attack surface
- 14:30 Host-side object creation mismatch vulnerability
- 20:00 Turning findings into a reusable audit checklist
- 22:50 AI's future role in security research (2026)
Broken Contracts in the DirectX Kernel: Local Elevation of Privilege & Hyper-V Guest-to-Host Remote Code Execution
Speakers: b2ahex (Independent Security Researcher); Zhu Qing (Security Researcher, Snowrock)
Conference: BlueHat Asia
YouTube: https://www.youtube.com/watch?v=S0Jz0dCIAVY
Overview
This talk, presented by independent security researcher b2ahex (Rai) and Snowrock's Zhu Qing, delves into a series of critical vulnerabilities discovered within the DirectX kernel and the Hyper-V graphics stack. The core theme revolves around "broken contracts" – implicit security rules governing object lifecycle, identity, and cleanup that, when violated, lead to severe security flaws. The researchers uncovered a total of 32 related bugs, with 26 receiving CVE IDs, demonstrating a systemic issue within these Windows components.
The implications of these findings are far-reaching. Locally, the vulnerabilities can lead to Local Privilege Escalation (LPE) on Windows systems, allowing a low-privileged attacker to gain SYSTEM-level access. More critically, the Hyper-V bugs enable Guest-to-Host Remote Code Execution (RCE), permitting an attacker to escape a virtual machine and execute arbitrary code on the underlying host system. This latter class of vulnerability is particularly significant in cloud environments, such as Microsoft Azure, which heavily rely on Hyper-V and GPU virtualization for their services, posing a direct threat to cloud tenant isolation and infrastructure integrity.
The research highlights the complex interplay of multi-threading, object management, and cross-boundary interactions in kernel-mode drivers. Despite the increasing buzz around AI for bug hunting, the speakers emphasized that all their findings stemmed from traditional, "old-school" manual review and debugging, underscoring the enduring value of human expertise in deep kernel security analysis. Their work provides a comprehensive audit methodology and a checklist for identifying similar classes of bugs, offering invaluable insights for both defenders and fellow security researchers.
Background
▶ Watch: Introduction and impact of vulnerabilities (0:00)
The concept of "broken contracts" forms the bedrock of this research. In the context of kernel security, a contract refers to a set of implicit rules or invariants that must consistently hold true across the entire call chain involving an object. These rules include:
- Object Identity: If code checks an object and later uses it, it must be the same object. The object's identity, as referenced by a handle or pointer, should not change unexpectedly.
- Object Lifetime: An object must remain alive and valid for the entire duration it is actively being used by the code. References must correctly manage its lifecycle, preventing premature deallocation.
- Cleanup Consistency: If an initialization process is started but fails midway, the cleanup routine must precisely undo only the work that was successfully completed, avoiding actions on uninitialized data or double-freeing resources.
The speakers noted that while individual functions might appear secure in isolation, vulnerabilities often emerge only when tracing an object's complete lifecycle, from creation to destruction, across multiple threads and protection boundaries. This intricate dance of object management, particularly in multi-threaded kernel environments, creates subtle windows for race conditions and logical flaws.
The researchers dedicated two months to this investigation, observing a significant improvement in AI's capabilities for bug hunting during their timeline, though their reported bugs were found manually. Their prior work and continuous engagement with the Microsoft Security Response Center (MSRC) provided a strong foundation for this deep dive into the DirectX kernel and Hyper-V's graphics stack. Their findings consistently pointed to recurring patterns of contract violations: using a different object than the one tracked, premature termination of lifetime protection, and mismatched cleanup operations after failures.
Key Findings
▶ Watch: Guest-to-Host RCE: Hyper-V host attack surface (11:30)
The research uncovered a total of 32 related vulnerabilities, with 26 subsequently assigned CVEs, categorized broadly into issues affecting the local Windows system and those impacting the Hyper-V guest-to-host boundary.
On the local attack surface, the researchers identified seven distinct bugs, primarily falling into three groups:
- DFX Handle Table Races: These involved scenarios where a handle's underlying object could change due to reuse, while older code paths still operated under the assumption of the original object, leading to double-free conditions.
- Reference Lifetime Issues: Bugs where an object's handle was published, making it accessible to other threads, before the creating thread had properly acquired its own reference to keep the object alive. This created a window for another thread to prematurely free the object, resulting in Use-After-Free (UAF) vulnerabilities.
- Concurrent Object Destruction: Cases where a single object could enter two separate destruction or cleanup paths simultaneously, without proper synchronization. If one path freed the object, the other path could continue to use a stale pointer, leading to UAF or double-free.
For the Hyper-V host attack surface, a more extensive set of 18 bugs (plus two additional off-site cases) were reported, also categorized into three main areas:
- Object Creation Mismatches: The host's DirectX kernel could be influenced by the guest to create objects using different underlying mechanisms (e.g., raw C++
newvs.ObCreateObjectfor Windows Object Manager-managed objects). Subsequent operations expecting a specific object model would then lead to host crashes or memory corruption. - Object Lookup Inconsistencies: These involved race conditions during object lookups where the host combined information from different points in time or failed to validate object relationships. This could result in the host operating on an object with an incorrect type or associating an object with the wrong parent device, causing UAFs.
- Flawed Error Handling, Resource Limits, and Reply Data: Issues included cleanup routines that failed to match the actual state of initialization, leading to uninitialized data access; lack of resource limits allowing guests to exhaust host resources; and information disclosure vulnerabilities where host kernel addresses were leaked back to the guest in replies.
Collectively, these vulnerabilities enabled a spectrum of severe impacts, including Local Privilege Escalation (LPE) on Windows, Guest-to-Host Remote Code Execution (RCE) in Hyper-V, Host Denial of Service (DoS), and Host Information Disclosure.
Technical Deep Dive
▶ Watch: Host-side object creation mismatch vulnerability (14:30)
The talk meticulously detailed several representative vulnerabilities from both the local and Hyper-V guest-to-host attack surfaces, illustrating the "broken contract" principle.
Local Attack Surface Vulnerabilities
1. Race in the DFX Handle Table (Double Free)
This complex race condition highlights how the reuse of a handle ID can lead to a double free. A handle in the kernel acts as an ID to locate an entry in a table, which then stores the actual object pointer, its type, and validation flags. One crucial flag is the 0x2000 bit, denoting a "destroyed" state. When this bit is set, normal lookups cannot retrieve the object, but it does not prevent the object from being kept alive or released by paths that already hold a pointer.
The scenario unfolds as follows:
- Initial State: A handle
Hpoints toObject A. - Thread A (Destroy Path): Initiates destruction of
Object A. It sets the0x2000bit forhandle Hto1. Critically, this bit is cleared later, after Thread A leaves a protected section. During this gap, a race window opens. - Thread B (Concurrent Release): Already holds a pointer to
Object A(obtained beforedestroyedbit was set). It proceeds to releaseObject A. - Handle Reuse: After
Object Ais released, the system reuseshandle Hfor a newly createdObject B.handle Hnow points toObject B, and itsdestroyedbit is0. - Thread A (Completes Old Clear): Thread A returns to clear the
destroyedbit. It operates onhandle H, which now points to Object B. It clears thedestroyedbit forObject B(setting it to0).Object Bis currently undergoing its own release (initiated by another request forhandle Hwhich now points to B, setting itsdestroyedbit to 1 again), but the handle table entry is now accessible for lookups. - Thread A (Second Release): Thread A, still following its original path (but now operating on
handle Hwhich points toObject B), performs a release operation onObject B. This is the first release forObject Bthrough this specific path. - Thread B (Second Release): Thread B, which was also releasing
Object B(from the new request), completes its destruction path and releasesObject Bagain. This constitutes a double free.
The analogy provided by the speakers was that of a hotel room number: Guest A checks out, but the same room number is quickly assigned to Guest B. However, an older instruction for that room number (remembering the number, not Guest A) eventually processes, changing the state of Guest B's room, potentially causing issues when Guest B's actual checkout process occurs.
2. Object Freed Before Initialization Finishes (Use-After-Free)
This vulnerability centers on a race condition during object creation and handle management within the Windows Object Manager. When a graphics application requests a new allocation (e.g., a texture or buffer), the D3D kernel initiates its creation. This involves setting up an event object and adding it to the Windows Object Manager using ObInsertObject. The host obtains an empty handle for this event.
The critical flaw lies in a lifetime gap:
- The handle for the event object is published (made available to other threads) as soon as
ObInsertObjectis called. - However, the creating thread (Thread A) does not immediately acquire its own reference to keep the object alive. It still needs to call
ObReferenceObjectByHandleto get this reference.
During this gap, another thread (Thread B) can close the handle before Thread A obtains its reference. If this is the last reference to the object, Thread B's closure can free the event object prematurely. Thread A, still holding a saved pointer to the now-freed object, will subsequently attempt to use it, resulting in a Use-After-Free (UAF). The contract here is that an object should not be freed while its creating thread still expects it to be valid and before it has established its own protective reference.
3. Two Cleanup Paths, Same Object (Use-After-Free/Double Free)
This issue arises from the lack of synchronized cleanup paths for a single object. A sync object, used to track GPU task completion, might be linked to multiple parent objects (e.g., a device or a swap chain). This means there are potentially multiple code paths that could initiate its destruction.
The problem:
- A caller might directly destroy the sync object.
- Concurrently, a parent object's cleanup routine (e.g., a swap chain's cleanup) might also call the destruction code for the same sync object.
Without a shared lifetime rule or proper synchronization mechanisms (like locks), both destruction paths can operate on the same object simultaneously. If one path finishes first, it performs the final release and frees the object. The other path, still holding a stale pointer, continues to operate on the now-freed memory, leading to a Use-After-Free (UAF). In some cases, if both paths proceed to the final release, it could also result in a double free. The contract broken here is the expectation of exclusive or synchronized destruction.
Hyper-V Host Attack Surface Vulnerabilities
The Hyper-V specific vulnerabilities highlight the challenges of maintaining security boundaries when untrusted guest input influences kernel operations on the host. Guest graphics operations involve requests sent via the Virtual Machine Bus (VMBus) to the host's DirectX kernel, which then processes them and interacts with the physical GPU.
1. Object Creation Mismatch (Host Crash/Memory Corruption)
This vulnerability focuses on how the host creates objects based on guest requests. The host has two primary methods for object creation:
ObCreateObject: This function creates an object that is managed by the Windows Object Manager, including associated metadata for reference counting, type information, and security descriptors.operator new: This is a standard C++ memory allocation that simply reserves raw memory, without the Object Manager's overhead or management data.
The guest, though unable to pass direct host pointers, can influence which creation path the host takes. The core problem is that subsequent host code might receive a pointer from operator new but then treat it as an object created by ObCreateObject. Specifically, if a pointer from operator new is passed to ObInsertObject (which expects an ObCreateObject-style managed object), the Object Manager will read invalid data from the raw memory location. This can lead to host crashes or memory corruption during insert, close, or release operations, as the Object Manager attempts to access non-existent management structures. This pattern was found in code paths related to shader resources, sync objects, and bundles. The analogy given was ordering a sandwich but receiving a pizza, then having a waiter try to pack it in a sandwich box – something will inevitably go wrong.
2. Object Lookup Inconsistencies
This category covers two distinct types of lookup issues:
- Type and Body Mismatch: The guest sends a handle
H, which initially points toResource A(type: Resource). The host looks upHand correctly records its type. However, before the host usesH,Resource Ais destroyed, and the same handleHis reused forSync Object B. When the host looks upHagain, it retrievesObject B, but critically, it still uses the older, cached type information (Resource) associated withObject A. The host then attempts to operate onSync Object Busing the memory layout and methods expected forResource A, potentially passing incorrect values to subsequent functions and leading to host UAF or corruption. The contract of consistent object type and body is broken.
- Device and Context Mismatch: In functions like
VM bus BLT, the guest sendsDevice AandContext B. The host's critical failure is that it does not check the relationship betweenContext BandDevice A.Context Bmight actually belong toDevice B. The host code proceeds, protectingDevice Awith a lock, but then usesContext B. If, concurrently, another thread cleans upDevice B,Context Bmay be freed. TheVM bus BLTpath then continues to use the freedContext B, causing a host Use-After-Free (UAF). The contract of consistent object ownership and relationships is violated. The analogy here was of two VIP guests, Alice and Bob, arriving together; security checks both names, then places a barricade around Alice, leaving Bob in the unprotected crowd.
3. Error Handling, Resource Limits, and Reply Data
These issues highlight the importance of robust post-failure state management and strict data sanitization for guest-facing interfaces.
- Failure Paths: If an initialization process fails midway, the cleanup routine must precisely match the steps that actually finished. Too much cleanup can touch uninitialized fields, leading to crashes. Too little cleanup can leave created resources behind. An example cited was the
VM bus gather register casefunction: it allocates a reply buffer, but if the allocation fails, the code still uses the uninitialized pointer before completing the reply, leading to a host crash. - Resource Limits: A malicious guest can repeatedly create requests, causing the host to continuously allocate resources without a total limiter. If these resources are not properly reclaimed after the guest disconnects or if the host lacks proper quotas, a guest can exhaust host memory or other resources, leading to Host Denial of Service (DoS).
- Reply Data: The
OPM path(Output Protection Manager) was found to leak internal kernel addresses from OPM records into the output data returned to the guest. This constitutes a Host Information Disclosure vulnerability, providing an attacker with valuable information for bypassing Address Space Layout Randomization (ASLR) and constructing more reliable exploits. The rule is simple: clean up the right state, control resource use, and keep internal data out of replies.
Demo / Proof of Concept
▶ Watch: Turning findings into a reusable audit checklist (20:00)
While the talk provided extensive technical details on the identified vulnerabilities and their underlying mechanisms, it did not feature a live demonstration of an exploit or specific proof-of-concept code being executed during the presentation. Instead, the speakers focused on thoroughly explaining the conditions that lead to Local Privilege Escalation and Hyper-V Guest-to-Host Remote Code Execution, the types of memory corruption (UAF, double-free), and information disclosure that were achieved through these "broken contracts." The 32 reported bugs, 26 of which received CVE IDs, serve as concrete evidence of the feasibility and impact of these findings.
Defensive Implications
▶ Watch: AI's future role in security research (2026) (22:50)
The research presented by b2ahex and Zhu Qing offers critical insights for defenders, particularly those managing Windows systems and Hyper-V virtualization environments. The overarching defensive strategy must revolve around meticulous object lifecycle management, robust input validation, and comprehensive multi-threading safety.
For the DirectX Kernel and local attack surface:
- Atomic Handle Table Operations: Developers must ensure that updates to handle table entries, especially those involving state flags like "destroyed" and the underlying object pointer, are atomic or properly synchronized. The object identity associated with a handle must remain consistent across all operations within a logical transaction, even if the handle ID itself is reused.
- Synchronized Object Creation and Referencing: The publishing of an object handle must be tightly coupled with the acquisition of a protective reference by the creating thread. The "lifetime gap" identified must be eliminated, ensuring that an object cannot be freed by another thread before its primary creator has secured its reference.
- Unified and Coordinated Cleanup: All potential destruction paths for an object must be identified and synchronized. A single, shared lifetime rule should govern when an object is finally released, preventing concurrent destruction efforts that lead to Use-After-Free or double-free conditions. This often requires robust reference counting mechanisms and careful use of locks.
For the Hyper-V Host and guest-to-host attack surface:
- Strict Object Creation Path Separation: The host kernel must rigorously distinguish between objects created via
ObCreateObject(managed by the Object Manager) and those allocated viaoperator new(raw C++ memory). These should never be conflated, and any code expecting a managed object must validate its origin, preventing memory corruption when raw pointers are misinterpreted. - Comprehensive Guest Input Validation: All guest-provided handles and parameters must undergo meticulous validation. This includes checking not only the validity of the handle itself but also the type of the object it points to, its ownership (e.g., belonging to the correct device or context), and its relationship to other objects passed in the same request. This validation must occur at every lookup and before combining any object-related information.
- Robust Error Handling and Resource Management: Cleanup routines must precisely match the state of initialization. If an operation fails mid-way, only the completed steps should be undone, avoiding access to uninitialized fields or leaving persistent resources behind. Furthermore, the host must implement strict resource quotas and effective reclamation mechanisms for all guest-initiated allocations to prevent Denial of Service attacks.
- Strict Reply Data Sanitization: All data returned to the guest must be thoroughly sanitized to prevent information disclosure. Internal kernel addresses, sensitive configuration details, or uninitialized memory contents should never be leaked across the guest-host boundary.
Overall, the research underscores that developers of complex kernel components, especially those involving multi-threading and virtualization, must prioritize secure object management, rigorous state tracking, and a deep understanding of potential race conditions. The "broken contract" checklist provided by the speakers serves as an excellent framework for auditing such code.
Key Takeaways
- Object Identity and Lifetime are Critical Security Contracts: The fundamental expectation that a handle or pointer refers to the same, valid object throughout its use is a core security boundary. Violations lead directly to Use-After-Free and double-free vulnerabilities.
- Race Conditions in Object Management are Pervasive LPE Vectors: Issues like handle table reuse races, premature handle publishing, and unsynchronized cleanup paths create subtle windows for attack, enabling local privilege escalation on Windows systems.
- Hyper-V Guest-to-Host Security Demands Meticulous Validation: The guest-host boundary is highly sensitive. The host must rigorously validate all guest-provided input, including object types, relationships, and ownership, to prevent guest influence over host object management and subsequent remote code execution.
- Mismatched Object Creation and Inconsistent Lookups are Key G2H RCE Vectors: Whether it's conflating managed and raw memory allocations or looking up an object with an outdated type, these inconsistencies allow attackers to manipulate host memory and execution flow from within a guest VM.
- Robust Error Handling and Resource Control are Essential: Incomplete cleanup, lack of resource limits, and information leakage in replies are common pitfalls that can lead to host Denial of Service and aid in exploit development.
- Manual Code Review Remains Vital: Despite advancements in AI for bug hunting, this research demonstrates that deep, manual security analysis and debugging are still indispensable for uncovering complex, multi-threaded kernel vulnerabilities.
About the Speaker(s)
b2ahex (Rai) is an independent security researcher with a strong focus on vulnerability research and bug hunting. He has a history of collaborating with the Microsoft Security Response Center (MSRC), submitting numerous vulnerability reports. This talk at BlueHat Asia marked his first presentation at the conference, showcasing his expertise in deep Windows kernel security.
Zhu Qing is a Security Researcher at Snowrock. He is recognized as an outstanding security engineer with significant experience in Windows development and kernel security. His work, alongside b2ahex, highlights his interest and proficiency in uncovering complex vulnerabilities within Windows operating systems and virtualization platforms like Hyper-V. Both researchers share a common passion for exploring and securing the Hyper-V attack surface.
Reviews
Dr. Zero (Offensive Security Researcher) — MUST SEE
This is the kind of research that justifies conference attendance. 32 bugs, 26 CVEs, spanning local LPE to Hyper-V guest-to-host RCE — and they walked through the actual race conditions and object lifecycle failures that make each class work. Real kernel work, real impact, no filler.
Heather Calloway (CISO) — STRONG ACCEPT
Thirty-two bugs, 26 CVEs, and a guest-to-host escape path in Hyper-V. This is the kind of research that changes procurement conversations and cloud risk assessments. Every CISO running Azure workloads or on-prem Hyper-V needs to know this attack surface exists.