Abstract
To ensure that secure applications do not leak their secrets, they are required to uphold several security properties such as spatial and temporal memory safety as well as cryptographic constant time. Existing work shows how to enforce these properties individually, in an architecture-independent way, by using secure compiler passes that each focus on an individual property. Unfortunately, given two secure compiler passes that each preserve a possibly different security property, it is unclear what kind of security property is preserved by the composition of those secure compiler passes. This paper is the first to study what security properties are preserved across the composition of different secure compiler passes. Starting from a general theory of property composition for security-relevant properties (such as the aforementioned ones), this paper formalises a theory of composition of secure compilers. Then, it showcases this theory a secure multi-pass compiler that preserves the aforementioned security-relevant properties. Crucially, this paper derives the security of the multi-pass compiler from the composition of the security properties preserved by its individual passes, which include security-preserving as well as optimisation passes. From an engineering perspective, this is the desirable approach to building secure compilers.
Introduction
Modern software security relies on a gauntlet of properties, including spatial and temporal memory safety, constant-time execution, and resilience against speculative execution attacks like Spectre. While individual compiler passes have been developed to enforce these properties, real-world compilers are complex pipelines. The central challenge lies in composition: if Pass A ensures memory safety and Pass B ensures constant-time execution, does their combination (A ∘ B) guarantee both? Furthermore, can standard optimization passes inadvertently undermine security guarantees established earlier in the pipeline?
Formalizing Robust Composition
The authors address these questions by extending the Robust Compilation framework. In this context, "robust" implies that security properties are maintained even when compiled code interacts with arbitrary, potentially malicious external code. The framework defines security properties as sets of "admissible behaviors" or traces. For instance, a trace containing a "Use-After-Free" event would be considered inadmissible under Temporal Memory Safety.
A key technical contribution is the definition of Well-Formed Trace Relations. These relations ensure that the transformation of program behavior across different languages in the pipeline is "well-behaved" enough to preserve the semantic integrity of security properties. Universal Image Projections are then used to translate these properties across the different languages of the pipeline.
The core result is the Sequential Composition Theorem, which proves that if two compilers are secure and their trace relations are compatible, their composition preserves the intersection of their security properties. This allows complex properties like Speculative Memory Safety (SpecMS) to be treated as the intersection of simpler, more manageable properties.
Secure Optimizations
A significant insight of this work is that standard optimizations, such as Dead Code Elimination (DCE) and Constant Folding (CF), can be formally proven to robustly preserve security properties. These optimizations are secure provided they do not introduce new observable behaviors that violate safety definitions.
The authors identify the "Indifference" Principle: for two passes to be swappable (e.g., running Optimization before Security vs. Security before Optimization), they must be indifferent to the trace changes made by the other. This ensures that the removal of code by DCE doesn't invalidate the safety checks inserted by a previous pass, allowing developers to build efficient and secure pipelines without resorting to monolithic "mega-passes."
Case Study: A Verified 6-Pass Compiler
To demonstrate the theory, the authors implemented and verified a 6-pass compiler in the Coq proof assistant. The pipeline includes:
- Temporal Memory Safety (TMS): Dynamic checks for use-after-free.
- Spatial Memory Safety (SMS): Bounds checks for buffer overflows.
- Optimizations: Dead Code Elimination and Constant Folding.
- Strict Constant Time (sCCT): Hardware-level data-independent timing.
- Speculative Safety (SS): Barriers to mitigate branch prediction attacks.
The entire framework and case study are fully formalized, ensuring mathematical soundness and proving that the multi-pass compiler robustly preserves the intersection of these critical security properties.
Conclusion
This research provides the first formal foundation for reasoning about the composition of secure compiler passes. By treating security as an intersection of properties and proving the robustness of both security-enhancing and optimization passes, the authors enable a modular, "divide and conquer" approach to building secure compilers. Future work will focus on reducing performance overhead and extending the model to cover more complex micro-architectural side channels.
Summary updated