Static Analysis for Extracting Permission Checks of a Large Scale Framework: The Challenges and Solutions for Analyzing Android

Alexandre Bartel, Jacques Klein, Martin Monperrus, Yves Le TraonIEEE Trans. Software Eng 2014 · DOI

Abstract

A common security architecture is based on the protection of certain resources by permission checks (used e.g., in Android and Blackberry). It has some limitations, for instance, when applications are granted more permissions than they actually need, which facilitates all kinds of malicious usage (e.g., through code injection). The analysis of permission-based framework requires a precise mapping between API methods of the framework and the permissions they require. In this paper, we show that naive static analysis fails miserably when applied with off-the-shelf components on the Android framework. We then present an advanced class-hierarchy and field-sensitive set of analyses to extract this mapping. Those static analyses are capable of analyzing the Android framework. They use novel domain specific optimizations dedicated to Android.

Introduction: The Permission Gap

Android's security model relies heavily on permissions to protect sensitive user data and system resources. However, the mapping between an API method (e.g., getGPSLocation()) and its required permission (e.g., ACCESS_FINE_LOCATION) is often opaque or poorly documented. This lack of clarity leads to two significant issues: permission gaps, where developers over-privilege apps "just in case," and app instability, where under-privileged apps crash at runtime.

The mapping between application calls and framework permission checks. Over-privileging occurs when an application declares permissions (like p2) that are not required by its reachable execution paths.

When an app is over-privileged, it presents a larger attack surface. If an attacker exploits a vulnerability like a buffer overflow, they inherit all permissions declared by the app, even those never intended for use. This paper introduces Spark-Android, a tool designed to bridge this gap by precisely mapping API calls to their required permissions.

The Technical Hurdle: Navigating the Binder

While static analysis should theoretically be able to extract these mappings from source code, standard "off-the-shelf" tools struggle with the Android framework's scale and complexity. A primary obstacle is the Binder, Android's Inter-Process Communication (IPC) mechanism.

A service call flow through the Binder. To standard analysis tools, the Binder often appears as a 'black box,' leading to path explosion or missed connections.

To a naive tool, a call to a system service looks like it disappears into a generic transact() method. This can lead to a "path explosion," where the tool incorrectly assumes a single API call might reach every service in the system, rendering the analysis results useless. Furthermore, because standard analysis doesn't see the system's "boot" process, it often assumes system objects are null, discarding up to 96% of framework methods.

Spark-Android: Tailored Static Analysis

To overcome these hurdles, Spark-Android builds on the Soot framework and the Spark points-to analysis engine, introducing several domain-specific optimizations:

  • Service Redirection: Bypasses Binder "glue code" to directly link API callers to specific service implementations.
  • String Analysis: Uses backward flow-sensitive analysis to resolve dynamic permission names that are often not constants.
  • Service Identity Inversion: Identifies and filters out internal framework checks that perform tasks using the service's own identity rather than the caller's.
  • System Simulation: Creates a "fake main" and simulates the Android boot process to ensure services are properly initialized for analysis.

Key Results and Insights

The researchers evaluated Spark-Android against the Android framework (versions 2.2 and 4.0.1) and thousands of market applications, yielding several key insights:

  • Superior Precision: Spark-Android significantly outperformed simpler Class Hierarchy Analysis (CHA) and contemporary tools like PScout, providing more precise permission sets for 37.6% of methods.
  • Identifying the Gap: Analysis of 1,421 real-world apps revealed that 9% suffered from a permission gap, requesting permissions they never actually invoked in their code.
  • Static vs. Dynamic: While dynamic analysis is precise, static analysis proved better at finding permission checks hidden in rare execution paths, such as those triggered only during roaming.

Conclusion

Spark-Android demonstrates that high-precision static analysis of large-scale frameworks is possible when domain-specific architectural knowledge is integrated. By successfully navigating the complexities of the Binder and system initialization, the tool provides a vital map for developers to minimize their app's attack surface and improve security. Future work will focus on integrating native code analysis to provide an even more exhaustive permission mapping.

Summary updated

BibTeX
@article{bartel2014static,
  author = {Alexandre Bartel and Jacques Klein and Martin Monperrus and Yves Le Traon},
  title = {{Static Analysis for Extracting Permission Checks of a Large Scale Framework: The Challenges and Solutions for Analyzing Android}},
  journal = {IEEE Trans. Software Eng.},
  year = {2014},
  doi = {10.1109/tse.2014.2322867},
}
Figure