Abstract
Information flow analysis is critical for security and program understanding, yet achieving modularity without sacrificing precision remains a significant challenge in traditional imperative languages. This paper presents Flowistry, a static analysis tool for Rust that leverages the language's unique ownership and lifetime system to perform modular information flow analysis. By treating function signatures as semantic contracts, Flowistry achieves high precision comparable to whole-program analysis while only requiring access to dependency signatures. Evaluation on over 280,000 lines of Rust code demonstrates that modular analysis matches whole-program results in 94% of cases, with minimal overhead in the remainder.
Introduction
Determining how data influences other data—information flow analysis—is fundamental to tasks ranging from preventing sensitive data leaks to program slicing. However, in languages like C or C++, modular analysis is notoriously difficult. When a static analyzer encounters a function call f(x, y), it must determine if x might mutate y or if they share underlying pointers. Without the source code for f, the analyzer must make conservative, "worst-case" assumptions. This often leads to a "data-flow explosion," where the resulting dependency sets are so large and noisy that they become useless for practical developer tools.
The authors propose that Rust’s type system, specifically its ownership and lifetime rules, provides a solution. These rules, designed for memory safety, implicitly encode the very pointer and aliasing information that information flow analysis requires.
Methodology: Ownership as a Flow Contract
The core insight of this work is that a Rust function signature is a much stronger semantic contract than its counterparts in other languages. The authors formalize this using Oxide, a model of Rust, extending it with a dependency context ($\Theta$) to track influence between memory locations.
Leveraging Rust's Type System
Flowistry utilizes three key features of the Rust type system:
- Ownership and Mutability: A signature like
fn update(&mut self, data: T)explicitly identifiesselfas a mutable target anddataas an input. In Rust, if a reference is not markedmut, it cannot be used to modify the underlying data (barring interior mutability). - Lifetimes: Rust’s lifetimes (e.g.,
&'a T) indicate potential aliasing. If two references share a lifetime, they might point to the same data; if they do not, the compiler guarantees they cannot alias. This allows Flowistry to resolve pointer ambiguity modularly. - MIR Analysis: The tool is implemented as a flow-sensitive, field-sensitive analysis on Rust’s Mid-level Intermediate Representation (MIR), handling both direct assignments and indirect control flow.
Evaluation and Datasets
To test the practicality and precision of Flowistry, the authors evaluated it against 10 diverse, large-scale open-source Rust projects. These projects span various domains, from low-level infrastructure like rustls to high-level applications like the rg3d game engine.
As shown in Table 1, the dataset comprises nearly 287,000 lines of code and over 435,000 variables, providing a robust benchmark for testing the scalability and accuracy of the modular approach.
Key Results: Precision and the Power of Types
The evaluation focused on comparing the results of Flowistry's modular analysis (using only signatures for dependencies) against a whole-program analysis (using the full source code of all dependencies).
Modular vs. Whole-Program Precision
The results were remarkably consistent. In 94% of the analyzed cases, the modular analysis produced the exact same dependency sets as the whole-program analysis. In the remaining 6% of cases where the modular approach was less precise, the "extra" dependencies reported were minimal, with dependency sets growing by only 7% on average.
Figure 1 illustrates this distribution. The linear scale (left) shows the overwhelming majority of cases have zero difference, while the log scale (right) highlights the small magnitude of differences when they do occur.
The Role of Lifetimes
To understand what drives this precision, the authors performed an ablation study. When they disabled lifetime reasoning (the "Ref-blind" configuration), the size of the dependency sets increased by 56%. This confirms that lifetimes are the essential component that allows Rust to succeed where other languages struggle with modular pointer analysis.
Applications and Limitations
The authors demonstrated the utility of Flowistry by building two practical tools: a VSCode-based program slicer and an Information Flow Control (IFC) checker for identifying security leaks.
Despite its success, Flowistry has limitations:
- Unsafe Code: The analysis relies on the compiler's safety guarantees.
unsafeblocks that bypass ownership rules can lead to unsound results. - Interior Mutability: Types like
RefCellallow mutation through immutable references, requiring Flowistry to make conservative, less precise assumptions. - Collection Granularity: The tool currently treats collections like
Vecas single units, losing precision regarding individual element indices.
Conclusion
Flowistry demonstrates that Rust’s ownership and lifetime systems are not just for memory safety—they are powerful tools for modular program analysis. By leveraging these "free" semantic contracts, Flowistry provides a highly precise and scalable method for tracking information flow in real-world software. Future work aims to integrate formal verification to handle unsafe code and improve the granularity of collection analysis.
Summary updated