Microsoft has introduced a series of technical recommendations to bolster the security of Virtualization-Based Security (VBS) enclaves, a key component of trusted execution environments (TEE).
VBS enclaves leverage the hypervisor’s Virtual Trust Levels (VTLs) to isolate sensitive memory and code execution within a user-mode process, safeguarding critical data such as encryption keys from even highly privileged actors.
However, this architecture introduces a unique trust boundary between the VTL1 enclave and the VTL0 host process, necessitating a paradigm shift in how developers approach security.
Unlike traditional trust boundaries such as those between kernel drivers and user-mode processes or network servers and clients the VBS enclave’s trust boundary exists internally within the host process.
This internal separation means that while the host cannot access the enclave’s memory, the enclave can interact with the host’s memory, creating potential vulnerabilities.
Microsoft’s recommendations aim to address these challenges by emphasizing robust validation practices, secure data handling, and careful design patterns.
Key Recommendations for Developers
One of the primary guidelines is to never trust data from the VTL0 host process.

Developers are advised to validate pointers passed from the host to ensure they reside outside the enclave’s memory range.
Using APIs like EnclaveGetEnclaveInformation
during initialization can help define enclave boundaries and prevent unauthorized memory access.
Additionally, developers should create local copies of data structures in VTL1 before performing further operations to mitigate race conditions, commonly known as Time-of-Check-Time-of-Use (TOCTOU) vulnerabilities.
Another critical recommendation is to avoid reentrancy whenever possible.
Reentrancy occurs when an enclave calls back into the host process, which can then re-enter the enclave through another exported function.
This pattern can lead to use-after-free bugs or other concurrency issues.
Microsoft suggests using SRW locks instead of CRITICAL_SECTION locks to prevent recursive locking scenarios that could compromise data integrity.
To further enhance security, sensitive data such as encryption keys should always be generated within the enclave itself and never exposed outside its boundaries unless securely communicated to trusted entities.
For example, Microsoft recommends using attestation services like Azure Attestation or Host Guardian Service to verify the integrity of an enclave before securely exchanging keys with external parties.
Embracing Safer Development Practices
Given the limited runtime environment of VBS enclaves, developers are encouraged to adopt safer coding practices and avoid reinventing standard functionalities.
While C is the officially supported language for enclave development, Microsoft highlights alternative approaches such as leveraging C++ standard libraries or even exploring Rust for its advanced memory safety features.
By constraining unsafe behavior and utilizing tools like Rust’s borrow checker, developers can minimize vulnerabilities inherent in low-level programming environments.
Microsoft’s latest recommendations underscore the importance of adapting security practices to address the unique challenges posed by VBS enclaves.
By validating inputs, avoiding reentrancy pitfalls, securely managing sensitive data, and adopting safer coding patterns, developers can significantly enhance the resilience of their enclaves against common vulnerabilities.
As trusted execution environments continue to evolve, these guidelines serve as a critical roadmap for building robust and secure applications in today’s increasingly complex threat landscape.
Are you from SOC/DFIR Teams? – Analyse Malware Incidents & get live Access with ANY.RUN -> Start Now for Free.