TL;DR
This paper introduces Cocoon, a novel Rust library that enables static information flow control (IFC) without modifying the Rust language or compiler. By leveraging Rust's type system and procedural macros, Cocoon enforces noninterference, ensuring high-secrecy values don't leak to low-secrecy values, with no runtime performance impact.
What Problem Does This Paper Address?
Confidentiality is crucial for secure computing. Information Flow Control (IFC) is a powerful mechanism to ensure this by preventing high-secrecy data from influencing low-secrecy data. However, existing fine-grained IFC approaches often require language modifications, custom compilers, or incur significant runtime overhead, hindering their adoption. This paper tackles the challenge of providing robust, static IFC for a mainstream, high-performance language like Rust, using only its existing tooling.
Methods
Cocoon employs a static, type-based IFC approach using Rust's type system and procedural macros to build an "effect system." This system tracks side effects and enforces noninterference. Key techniques include:
- Secret Blocks: Lexically scoped regions where operations on secret data are permitted. These blocks have associated secrecy labels, and Cocoon statically checks that operations within them adhere to these labels.
- Procedural Macros: These are used extensively to transform code at compile time. They enforce secrecy rules, manage side effects, and ensure that only "side-effect-free" functions are called within secret blocks.
- Effect System: Cocoon simulates an effect system by annotating functions and types. This allows it to track and restrict side effects that could lead to information leaks.
- Secret Values: Data with secrecy labels is wrapped in a
Secret<Type, Label>type. Access to these values is strictly controlled through specific interfaces. - Declassification: Explicit operations to reveal secret data are allowed but must be explicitly marked and audited, as they represent a trusted part of the system.
Datasets
Not discussed in the paper. The paper focuses on evaluating Cocoon on existing Rust applications and benchmarks.
Key Insights and Ideas
- Leveraging Rust's Type System and Macros: The core innovation is demonstrating that Rust's powerful type system and procedural macro capabilities can be used to implement a sophisticated static IFC system without language or compiler modifications. This significantly lowers the barrier to adoption.
- No Runtime Overhead: A key finding is that Cocoon's static checks are optimized away by the Rust compiler, resulting in no detectable runtime performance impact. This is a major advantage over dynamic IFC solutions.
- Rudimentary Effect System: Cocoon's approach to managing side effects within secret blocks effectively creates a rudimentary effect system, a feature not typically found in mainstream imperative languages.
- Incremental Deployment: The library is designed to be incrementally deployable, meaning developers can apply it to specific parts of their codebase dealing with secrets, rather than requiring a full rewrite.
Key Results
- No Runtime Performance Impact: Performance evaluations showed no statistically significant difference in runtime between original and Cocoon-enabled applications. In some cases, Cocoon-enabled versions even showed a slight performance improvement, attributed to compiler optimizations.
- Modest Compile-Time Overhead: While compile times increased, the overhead was generally modest, especially for applications where only a fraction of the code handled secrets. For applications where the entire computation was wrapped in secret blocks, compile-time overheads were higher but still manageable.
- Small Programmer Burden: Integrating Cocoon into existing applications like Spotify TUI involved modifying a relatively small percentage of the codebase (e.g., 167 lines of code added/modified in a 12,000-line codebase for Spotify TUI).
- Demonstrated Utility: Cocoon was successfully applied to two real-world Rust applications (Spotify TUI and Servo) and a Battleship game, demonstrating its practical applicability for enforcing confidentiality policies.
Limitations and Future Work
- Static Secrecy Labels Only: Cocoon currently supports only static secrecy labels, not integrity labels or dynamic labels.
- Restrictions on Language Features: Cocoon disallows the use of overloaded operators and custom dereference/destructor operations within secret blocks. While these are considered less restrictive for most applications, they are noted limitations.
- Macro Limitations: Cocoon cannot inspect the expansion of arbitrary application macros within secret blocks, which could potentially hide side effects.
- Trusted Codebase: Allowlisted Rust Standard Library functions are assumed to be side-effect-free, requiring trust in these components.
- Future Work: The authors suggest extending Cocoon to support integrity labels, dynamic labels, and potentially inferring labels for applications. They also mention the possibility of extending macro support to handle known macros like
vec!.
Summary updated