Kuboid
Open Luck·Kuboid.in

Virtualization-Based (In)Security: Weaponizing VBS Enclaves

DEFCONConference401 views36:296 months ago

This talk demonstrates techniques for weaponizing Windows Virtualization-Based Security (VBS) Enclaves by exploiting vulnerabilities in the enclave loading process and abusing debuggable enclave modules. The research focuses on bypassing memory isolation and integrity protections to achieve arbitrary code execution within the secure VBS environment. The speaker introduces 'Mirage,' a novel memory evasion technique that leverages VBS enclave capabilities to hide shellcode and bypass EDR monitoring. The presentation includes a proof-of-concept exploit for CVE-2023-36880, illustrating how to achieve code execution in a secure enclave.

Weaponizing VBS Enclaves: Bypassing Memory Isolation with Mirage

TLDR: Windows Virtualization-Based Security (VBS) enclaves are designed to protect sensitive data by isolating it from the kernel, but they are not impenetrable. This research demonstrates how to weaponize these enclaves by exploiting vulnerabilities in the loading process and abusing debuggable modules to achieve arbitrary code execution. Pentesters can use the Mirage technique to hide shellcode and evade EDR monitoring, turning a security feature into a stealthy persistence mechanism.

Virtualization-Based Security (VBS) is the cornerstone of modern Windows security, moving critical secrets and policy enforcement into a hypervisor-isolated environment. For years, we have treated the ring 0/3 boundary as the ultimate line of defense. VBS changes the game by introducing Virtual Trust Levels (VTLs), effectively creating a secure, isolated sandbox within the operating system. If you are a red teamer, you know that when Microsoft introduces a new "secure" boundary, it is only a matter of time before someone finds a way to turn it into a playground.

The Mechanics of VBS Enclaves

VBS enclaves are isolated regions of memory within a process that reside in VTL1. Because VTL1 is more privileged than the normal kernel (VTL0), the operating system cannot directly read or write to the enclave's memory. The only way to interact with an enclave is by invoking exported methods via the CallEnclave API. This architecture is intended to protect sensitive assets like API keys or encryption secrets from a compromised kernel.

However, the enclave loading process is a complex dance between the user-mode process and the secure kernel. If you can compromise the loader or find a way to load a malicious, signed enclave module, you gain a foothold in an environment that EDRs struggle to inspect. The research highlights two primary attack vectors: exploiting vulnerabilities in the enclave loading process, such as CVE-2024-49076, or abusing debuggable enclave modules.

Mirage: Stealthy Memory Evasion

The most compelling part of this research is the introduction of Mirage, a memory evasion technique that leverages the enclave's unique position to hide malicious activity. EDRs typically monitor memory for suspicious patterns, but they lack visibility into VTL1. By placing shellcode inside an enclave, you effectively move your payload out of the reach of standard monitoring tools.

The technique works by using the enclave as a secure vault. During the "sleep" phase of the payload, the shellcode is stored in a non-executable or encrypted state within the enclave. When the payload needs to execute, it triggers a vulnerability to write the shellcode into a VTL0 buffer, executes it, and then immediately overwrites the buffer with benign data. Because the interaction happens across the VTL boundary, the EDR sees nothing but a series of legitimate-looking API calls.

Exploiting Debuggable Modules

While nation-state actors might hunt for zero-days in the loader, there is a more accessible path for the average pentester: debuggable enclave modules. When a developer compiles an enclave with debugging enabled, the secure kernel exposes specific exceptions, such as SkmmDebugReadWriteMemory and SkmmDebugProtectVirtualMemory. These are intended for development, but they provide a primitive for arbitrary read/write access to the enclave's memory.

If you can obtain a signed, debuggable enclave module—which is often possible through supply chain compromises or by finding vulnerable third-party drivers—you can load it into your own process. Once loaded, you can use these debug exceptions to bypass the enclave's internal protections.

// Example of using debug exceptions to modify enclave memory
if (SkmmDebugReadWriteMemory(enclave_handle, address, buffer, size)) {
    // Arbitrary read/write access achieved
}

This approach effectively turns the enclave into a persistent, stealthy execution environment. During a red team engagement, this allows you to maintain a presence on the host that survives standard memory forensics. Even if an analyst suspects the process is compromised, they will find it nearly impossible to dump the enclave's memory or place breakpoints without triggering the enclave's own anti-debugging checks.

Defensive Considerations

Defending against VBS-based attacks is difficult because the isolation is enforced at the hypervisor level. The most effective mitigation is to enforce strict code signing policies for all enclave modules. If you are a blue teamer, focus on monitoring the CallEnclave API calls and auditing the loading of any third-party DLLs that claim to be enclave modules. The OWASP guidelines on broken access control are highly relevant here; ensure that your environment does not allow the loading of unsigned or untrusted modules into high-privilege processes.

VBS enclaves are a powerful tool for security, but they introduce a new surface for advanced persistent threats. As more applications adopt this technology, we will inevitably see more "bring your own vulnerable enclave" (BYOVE) attacks. Start looking at how your organization handles enclave signing and consider whether your current EDR stack has the visibility required to detect activity occurring within these isolated VTL1 environments. The future of red teaming is moving into the hypervisor, and it is time to start paying attention.

Talk Type
exploit demo
Difficulty
expert
Category
red team
Has Demo Has Code Tool Released


DEF CON 33 Main Stage Talks

98 talks · 2025
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in