Abstract
New trusted computing primitives such as Intel SGX have shown the feasibility of running user-level applications in enclaves on a commodity trusted processor without trusting a large OS. However, the OS can still compromise the integrity of an enclave by tampering with system call return values. A subclass of these attacks, called Iago attacks, enables arbitrary logic execution in enclave programs. Existing enclave systems have very large Trusted Computing Bases (TCB) and implement ad-hoc checks at the system call interface which are hard to verify for completeness. We present BesFS—the first filesystem interface which provably protects enclave integrity against a completely malicious OS. We prove 167 lemmas and 2 key theorems in 4625 lines of Coq proof scripts, directly proving the safety properties of the BesFS specification. BesFS comprises 15 APIs with compositional safety and is expressive enough to support 31 real-world applications.
Introduction
In the landscape of secure computing, Intel SGX and other Trusted Execution Environments (TEEs) provide "secure enclaves"—isolated execution environments that protect code and data from a potentially compromised host Operating System (OS). However, enclaves are not entirely autonomous; they must interact with the untrusted OS for essential services like filesystem access. This interaction point, typically handled via "OCALLs," introduces a significant security vulnerability.
BesFS, presented at USENIX Security '20, addresses this gap by providing the first filesystem interface with mechanized formal proofs. It ensures that even a fully malicious OS cannot subvert an enclave's integrity through manipulated filesystem API responses.
The Threat: Iago Attacks
A malicious OS can execute Iago attacks by providing deceptive return values for system calls. Rather than just stealing data, the OS manipulates the enclave's control flow. For instance, if an enclave attempts to open a critical log file, the OS might falsely report that the file does not exist (ENOENT). This could force the enclave into an unvetted error-handling path, potentially leading to arbitrary logic execution.
Existing frameworks like Graphene-SGX or the Intel SGX SDK rely on ad-hoc, hand-coded checks to mitigate these risks. As shown in the comparison below, these systems often have a significantly larger Trusted Computing Base (TCB) compared to BesFS, making their security properties difficult to verify for completeness.
Formal Verification Methodology
BesFS models the filesystem as a state-transition system. The verification process involves three main components:
- State Properties (SP): The authors define a "Good State" for the filesystem using five core properties (SP1-SP5), ensuring unique path mappings, valid file cursors, and consistent metadata.
- Transition Relations (TP): Each of the 15 core POSIX-style APIs (e.g.,
fs_open,fs_read) is defined by a transition relation. These relations specify the pre-conditions required for a call and how the system state evolves upon successful execution. - Sequential Composition Safety Theorem: The primary contribution is a mathematical proof that if the system starts in a "good" state, any sequence of BesFS API calls will always transition the system into another "good" state.
The authors used the Coq proof assistant to verify 167 lemmas and 2 core theorems across 4,625 lines of proof scripts. To handle non-determinism (where the same call might return different values), they introduced an implicit global counter in their model to ensure the proof assistant treats each call as a distinct event.
Implementation and Evaluation
While the design is formally verified in Coq, the authors manually translated it into 1,449 lines of C code for deployment, as current tools for automatically extracting executable code from Coq are not yet optimized for SGX constraints (such as the lack of a garbage collector).
Expressiveness and Performance
BesFS was evaluated against 31 diverse applications to test expressiveness, compatibility, and performance, including Tor, OpenSSL, and the Privado neural network framework.
- Compatibility: BesFS proved expressive enough to support these complex applications with minimal code changes (e.g., only 20 lines of code changed in the Privado framework).
- Overhead: On CPU-intensive tasks (SPEC CINT 2006), BesFS added an average overhead of 12.22%. On I/O-intensive tasks, there was a 4.8x slowdown in bandwidth. However, the authors noted that the vast majority of this overhead comes from the necessary AES-GCM encryption/decryption of file blocks, not the formal verification checks themselves.
Security Efficacy
In attack simulations, BesFS successfully detected and blocked 100% of 687 manually crafted "bad" OS responses. Furthermore, the formal verification process uncovered significant flaws in existing frameworks like Panoply and the Intel SGX SDK, including incorrect error code handling and potential stack overflow vulnerabilities.
Conclusion
BesFS represents a significant step toward a "Verified TCB," moving enclave security away from "best-effort" checks toward rigorous, mathematical guarantees. By proving that safety is maintained across any sequence of calls, BesFS allows developers to build higher-level library functions on top of core APIs without needing to re-verify the entire stack.
Summary updated