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

Stefano Calzavara, Ilya Grishchenko, Adrien Koutsos, Matteo Maffei

Abstract

Static analysis of Android applications often struggles with the trade-off between soundness and precision, particularly regarding heap modeling in concurrent environments. This paper introduces fsHornDroid, a tool that utilizes a flow-sensitive heap abstraction based on recency. By distinguishing between the most recently allocated object and older instances, fsHornDroid allows for precise "strong updates" while maintaining soundness through a novel "lifting" mechanism for shared objects. Experimental results on DroidBench and real-world applications show that fsHornDroid achieves perfect recall and superior precision compared to previous state-of-the-art analyzers.

Introduction

Android security relies heavily on static analysis to detect sensitive data leaks. However, the complexity of the Android heap and its concurrent execution model—comprising threads, callbacks, and intents—poses significant challenges. Most existing tools are flow-insensitive, leading to "taint" persistence even after data is overwritten. This paper addresses the need for a sound, flow-sensitive analysis capable of performing strong updates in a concurrent setting.

Methodology: Flow-Sensitive Heap Abstraction

The core of the proposed approach is the extension of recency abstraction to a concurrent environment. The authors built their solution on three main pillars: recency-based heap splitting, a lifting mechanism for shared data, and logic-based modeling using Horn clauses.

Recency and Strong Updates

Standard analyses group all objects from a single allocation site into one abstract object, necessitating "weak updates" (merging new data with old). fsHornDroid splits these into two categories:

  1. Most Recently Allocated (FS): Represents exactly one concrete object, allowing for strong updates (overwriting data).
  2. Non-Flow Sensitive (NFS): A pool for all older objects, handled via conservative weak updates.

Handling Concurrency and Sharing

To maintain soundness in Android's multi-threaded environment, the authors implement a lifting mechanism. If an object might be shared between threads or accessed via multiple callbacks, it is "lifted" from the precise FS heap to the conservative NFS heap. This ensures that concurrent modifications do not invalidate the analysis's assumptions.

Table VI: Syntax and Informal Semantics of Selected Statements, including Android-specific operations like intents and thread management.

Formal Modeling

The analysis is formalized using Horn clauses and solved with the Z3 theorem prover. The semantic domains, including heaps ($H$) and local configurations ($\Sigma$), provide the mathematical foundation for tracking state across method calls and thread boundaries.

Semantic domains used in the formalization of the Android analysis framework.

Evaluation and Results

The tool was evaluated against DroidBench (115 apps) and a set of 64 real-world apps from Google Play.

  • Precision and Recall: fsHornDroid achieved a sensitivity (recall) of 1.0 on DroidBench, catching all documented leaks. Its specificity (precision) was 0.79, significantly higher than FlowDroid (0.58) and its predecessor (0.68).
  • Real-World Performance: The flow-sensitive approach eliminated 18% of false alarms in real-world apps compared to previous sound analyzers.
  • Efficiency: Analysis times remained practical, with a median of 1 second for DroidBench and an average of 17 minutes for complex real-world applications.

Discussion and Future Work

While fsHornDroid represents a significant step forward, limitations remain. The reliance on library stubs for "black box" Android system code can lead to gaps. Furthermore, the tool does not currently account for implicit flows or native code execution via JNI. Future work will focus on expanding library coverage and incorporating declassification rules to better handle intentional data flows.

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