TL;DR
This paper introduces NestedSGX, a novel framework that enables the creation of hardware-backed enclaves within confidential virtual machines (CVMs) on AMD SEV-SNP platforms. By leveraging virtual machine privilege levels (VMPLs), NestedSGX allows existing SGX applications to run securely within CVMs while treating the guest OS as untrusted, offering a more practical and compatible approach to confidential computing.
What Problem Does This Paper Address?
Confidential computing aims to protect sensitive data and code by isolating them within trusted execution environments (TEEs). While Intel SGX provides enclaves for applications, and VM-based TEEs like AMD SEV-SNP offer confidential virtual machines (CVMs) for entire operating systems, a gap exists in securely running enclaves within CVMs. The challenge is that a CVM's guest OS, even if running in a protected environment, can still be a source of compromise. If the guest OS is malicious or compromised, it could interfere with or tamper with code running inside enclaves, undermining the security guarantees. Existing solutions like vSGX emulate SGX instructions in software, leading to significant performance overhead. This paper addresses the need for a hardware-assisted solution that allows enclaves to run within CVMs, providing strong isolation from a potentially untrusted guest OS, while maintaining compatibility with existing SGX tools and applications.
Methods
NestedSGX leverages AMD SEV-SNP's Virtual Machine Privilege Level (VMPL) feature to create a layered protection mechanism. The core idea is to assign different VMPL levels to different components within the CVM:
- VMPL0 (Highest Privilege): The security monitor and the SGX emulation layer run at this level. The security monitor is the root of trust for measurement and attestation, ensuring the integrity of enclaves.
- VMPL1 (Lower Privilege): The guest OS and the untrusted application (App) run at this level.
This separation ensures that the guest OS cannot access the memory of the security monitor or the enclaves. NestedSGX also simulates SGX leaf functions, allowing it to manage the enclave lifecycle (creation, memory management, teardown) and provide compatibility with the Intel SGX SDK. To further enhance compatibility, they've ported the SGX SDK and the Occlum library OS to NestedSGX, enabling the use of existing SGX toolchains and applications.
Datasets
The paper does not introduce new datasets. Instead, it uses standard benchmarks for evaluation, including:
- Micro-benchmarks: SGX leaf instructions, context switches (ECALLs/OCALLs).
- Macro-benchmarks: Linux/Unix nbench, Lmbench, FIO, WolfSSL, Hash Join, SQLite, TLS server, and Redis.
These benchmarks are used to compare NestedSGX's performance against Intel SGX and vSGX, as well as against a baseline (sim mode).
Key Insights and Ideas
- VMPL as a Security Primitive: The paper demonstrates how VMPLs, a hardware feature of SEV-SNP, can be effectively used to create fine-grained isolation between components within a CVM, specifically separating a trusted security monitor and enclaves from a potentially untrusted guest OS.
- Compatibility without Compromise: NestedSGX achieves a good balance between compatibility with existing SGX applications and performance by simulating SGX leaf functions and leveraging hardware features, rather than relying solely on software emulation.
- Performance Gains over vSGX: By avoiding costly cross-VM communication for SGX emulation, NestedSGX offers a significant performance improvement over vSGX, making it more practical for real-world use.
- Untrusted Guest OS is Key: The core security assumption is that the guest OS is untrusted. This is a crucial insight for building secure systems within CVMs, as it acknowledges the inherent risks of complex operating systems.
Key Results
- Context Switch Performance: Context switches in NestedSGX are approximately 1.9x to 2.1x higher than native Intel SGX but are still orders of magnitude faster than vSGX.
- Overhead: NestedSGX incurs minimal overhead in most real-world applications:
- Less than 2% for computation and memory-intensive workloads.
- Less than 15.68% for I/O-intensive workloads.
- SGX Leaf Instructions: Most ENCLS leaf instructions are significantly faster than vSGX due to avoiding cross-VM communication. EGETKEY and EREPORT are slower due to the use of Rust's crypto crate.
- Application Performance: Real-world benchmarks show negligible overhead for Hash Join, ~0.77% for SQLite, ~0.78% for WolfSSL, ~1.3% for nbench, and ~15.68% overhead for Redis under high load.
Limitations and Future Work
- Limitations:
- Features like
user_checkand memory sharing are not currently supported due to separate page tables for the App and enclave.
- Features like
- Swapping enclave memory to disk is not supported.
- The guest OS cannot inject interrupts into VMPL0, which constrains OS scheduling of enclave threads.
- Compatibility is primarily for applications using the SGX SDK and Occlum; applications written directly in SGX instructions without these might not be supported.
- Future Work:
- Support for memory sharing by synchronizing App and enclave page tables.
- Extending NestedSGX to support other TEE abstractions like ARM TrustZone and AMD's TDX.
- Enhancing compatibility for applications written directly in SGX instructions.
- Investigating proactive interrupt request handling from the guest OS.
- Exploring the AEX-notify feature for improved security.
Summary updated