TL;DR
Serberus is the first comprehensive compiler-based mitigation that protects cryptographic code against all five major Spectre speculation primitives on existing hardware. By introducing a stricter "Static Constant-Time" programming model and leveraging lightweight hardware features like Intel CET, it achieves full protection with an average performance overhead of just 21.3%—outperforming less secure state-of-the-art alternatives.
What Problem Does This Paper Address?
Since the discovery of Spectre, speculative execution—a core performance feature of modern CPUs—has become a major security liability. Cryptographers traditionally use constant-time (CT) programming to ensure that secret data doesn't influence execution time or memory access patterns. However, Spectre attacks (like PHT, BTB, RSB, STL, and PSF) allow a processor to "transiently" execute instructions that bypass these CT protections, exfiltrating secrets through side channels before the CPU realizes it made a misprediction.
Existing software mitigations are often a "choose your poison" scenario: they are either incomplete (protecting against only one or two Spectre variants) or incur massive performance penalties (like the ~440% overhead of full fencing). The challenge is to create a defense that is both comprehensive (covering all speculation primitives) and performant enough for real-world use.
Methods
The authors introduce Serberus, a three-pass compiler mitigation implemented in a custom LLVM-based tool called LLSCT. Its approach relies on three pillars:
- Static Constant-Time (CTS): A strengthened programming contract. While standard CT allows passing secrets by value, CTS requires secrets to be passed by reference. This prevents "unexpected secret arguments" from leaking via branch or return address mispredictions.
- ASP Operational Semantics: A novel formal model (Abstract Speculative Processor) that captures how secrets leak through transient execution. This allows the authors to mathematically prove that their mitigation is complete.
- Three Compiler Passes:
- Fence Insertion: Uses a "transient Control Flow Graph" to identify where to place
LFENCEinstructions. It specifically targets "taint primitives"—instructions that could speculatively load a secret into a public register.
- Fence Insertion: Uses a "transient Control Flow Graph" to identify where to place
- Function-Private Stacks (FPS): To mitigate Store-to-Load Forwarding (STL) attacks, Serberus assigns each function its own private stack region. This prevents a function from speculatively "reading" a secret left on the stack by a previous function.
- Register Cleaning: Zeros out non-argument registers before calls and returns to ensure no transient secrets are leaked to a mispredicted target.
Serberus assumes the hardware has Intel CET (Control-flow Integrity) enabled to bound transient control flow and that PSF (Predictive Store Forwarding) is disabled via hardware controls (which has negligible performance impact).
Datasets
The authors evaluated Serberus on widely-used, high-performance cryptographic libraries:
- OpenSSL: (SHA-256, ChaCha20, ECDH Curve25519)
- Libsodium: (Salsa20, SHA-256)
- HACL*: A verified crypto library (ChaCha20, Poly1305, ECDH Curve25519)
These represent the "gold standard" for constant-time code in the industry.
Key Insights and Ideas
- The Four Taint Primitives: The authors prove that all Spectre leaks in CTS code can be reduced to just four types of "taint primitives" (NCAL, NCAS, STKL, and NARG). By breaking the dependency chain between these primitives and "transmitters" (like branches or loads), they can stop the leak.
- Hardware-Software Co-design: A key "aha" moment is that software analysis of transient execution is only tractable if the hardware provides some bounds. Intel CET (Indirect Branch Tracking and Shadow Stack) provides exactly these bounds, making Serberus possible.
- Loop-Aware Fencing: Unlike previous mitigations that blindly insert fences inside loops, Serberus’s transient CFG analysis allows it to place fences outside of performance-critical loops in many cases, drastically reducing overhead for large data buffers.
Key Results
- Performance: Serberus introduces an average runtime overhead of 21.3%. For comparison, the next closest state-of-the-art software mitigation (a combination of SLH, Retpoline, and SSBD) has a 24.9% overhead despite being less secure (it doesn't fully mitigate RSB or STL leaks).
- Efficiency on Large Buffers: On benchmarks with large (8KB) buffers, Serberus’s overhead drops to just 7.1%, nearly half that of the next best mitigation.
- Security: Using the ASP model, the authors formally prove that Serberus eliminates all Spectre-based secret leakage for programs that follow the CTS discipline.
Limitations and Future Work
- Hardware Requirements: Serberus relies on modern CPU features like Intel CET (specifically IBT and SHSTK). While these are becoming standard (e.g., Intel Tiger Lake and newer), the defense cannot be fully backported to older "legacy" hardware without losing security or performance.
- Declassification: The current formal proof does not handle "declassification" (where a secret is intentionally made public, like a ciphertext). The authors suggest this can be handled via a specific auxiliary function and a fence, but leave the formal proof for future work.
- Fragility: As a compiler-based approach, Serberus is sensitive to downstream optimizations. If a later compiler pass reorders instructions or violates the CTS assumptions, the security guarantees could be undermined.
Summary updated