A Sound Flow-Sensitive Heap Abstraction for the Static Analysis of Android Applications

Stefano Calzavara, Ilya Grishchenko, Adrien Koutsos, Matteo Maffei

TL;DR

This paper introduces the first static analysis for Android applications that is both flow-sensitive on the heap and provably sound. By extending "recency abstraction" to a concurrent setting, the authors allow their tool, fsHornDroid, to perform precise "strong updates" on data structures without missing potential security leaks.

What Problem Does This Paper Address?

Static analysis tools for Android face a grueling "Soundness vs. Precision" trade-off. Android is inherently concurrent; multiple components (Activities, Services) run simultaneously, and their execution order is driven by unpredictable user interactions like button clicks.

Most existing tools choose one of two paths:

  1. Unsoundness: They assume a specific execution flow to stay precise, but this allows clever attackers to hide malicious leaks in unexpected control paths.
  2. Over-conservatism: Tools like the original HornDroid are sound (they don't miss leaks) but use "flow-insensitive" heap abstractions. This means they treat the entire heap as a single "blob" where data can only be added, never overwritten. This leads to a flood of false positives—alarms raised on perfectly benign code.

The authors tackle the challenge of allowing strong updates (the ability to prove that a sensitive value in memory has been overwritten by a non-sensitive one) in a concurrent environment while maintaining a mathematical proof that no real leaks are missed.

Methods

The researchers formulated their analysis using a set of Horn clauses—logical rules that over-approximate how an app behaves. They then used the Z3 SMT solver to check if any "leak" state is reachable.

The Concurrent Recency Abstraction

The core innovation is a dual-heap model inspired by "recency abstraction," adapted for concurrency:

  • Flow-Sensitive (FS) Heap: This tracks the "most recently allocated" object at a specific point in the code. Crucially, the analysis proves these objects are local to a single thread. Because they aren't shared, the tool can safely perform strong updates on them.
  • Flow-Insensitive (NFS) Heap: This acts as a fallback. It stores objects that are older or might be shared between threads. This part of the heap only supports "weak updates" (adding information rather than replacing it) to remain sound.

The "Lifting" Mechanism

When the analysis detects that a thread-local object might be shared with another thread or overwritten in a loop, it performs lifting. The object is moved from the precise FS heap to the conservative NFS heap. This ensures that the analysis stays as precise as possible for as long as possible.

Basic Syntactic Categories of the formal model

To support this, the authors extended the formal semantics of the Android platform to include multi-threading, exception handling, and complex synchronization primitives like monitors and "join" statements.

Semantic domains for the local reduction model

Datasets

The authors evaluated their tool, fsHornDroid, using two primary sources:

  1. DroidBench: A standard industry benchmark consisting of 115 small apps designed to test the limits of taint trackers.
  2. Real-World Apps: A set of 64 popular applications pulled from the Google Play Store to test the tool's scalability and performance in the wild.

Key Insights and Ideas

  • Thread Locality is the Key to Precision: The "aha moment" here is realizing that you don't need to be flow-insensitive for the entire heap just because the app is concurrent. As long as you can prove an object hasn't escaped its parent thread, you can treat it with the same precision as a sequential program.
  • Soundness via Over-approximation: By using Horn clauses, the tool doesn't just "guess" paths; it creates a logical model that covers all possible executions. If the solver says no leak is possible in the model, it is mathematically impossible in the actual app.
  • Context-Sensitivity Matters: By tracking the calling context (who called which method), the tool significantly reduces "ghost" aliases that typically plague static analysis.

Key Results

The results show that adding flow-sensitivity significantly boosts precision without sacrificing the "zero-miss" guarantee:

  • Perfect Sensitivity: On DroidBench, fsHornDroid maintained a sensitivity of 1.0, meaning it detected 100% of the actual leaks.
  • Superior Specificity: It achieved a specificity (precision) of 0.79, outperforming the original HornDroid (0.68) and other popular tools like FlowDroid (0.58) and DroidSafe (0.47).
  • Real-World Impact: In a sample of potentially leaky real-world apps, the flow-sensitive analysis eliminated 18% of false alarms compared to the original tool.
  • Efficiency: Despite the added complexity, the tool remains fast, with a median analysis time of just 2 minutes for real-world applications.

Limitations and Future Work

While a major step forward, the authors note several areas for improvement:

  • Analysis Stubs: The tool still struggles with "unknown methods" (API calls where the source code isn't available), requiring manual stubs.
  • Implicit Flows: The current version only tracks direct data leaks, not "implicit" leaks (where data is leaked via control flow logic).
  • Native Code: Like most static analysers, it only examines Dalvik bytecode and cannot see what happens inside native C/C++ libraries.
  • Declassification: The tool is currently very conservative; it doesn't have a way to recognize "intended" information flows (e.g., a user intentionally sharing their location), which can still lead to false positives in complex apps.

Summary updated

BibTeX
@inproceedings{calzavara2017sound,
  author = {Stefano Calzavara and Ilya Grishchenko and Adrien Koutsos and Matteo Maffei},
  title = {{A Sound Flow-Sensitive Heap Abstraction for the Static Analysis of Android Applications}},
  booktitle = {CSF},
  year = {2017},
  doi = {10.1109/csf.2017.19},
}
Figure