Aper: Evolution-Aware Runtime Permission Misuse Detection for Android Apps

Sinan Wang, Yibo Wang, Xian Zhan, Ying Wang, Yepang Liu, Xiapu Luo, Shing-Chi CheungarXiv 2022

TL;DR

Android’s runtime permission model protects user privacy but introduces subtle bugs when permissions are checked asynchronously or when API requirements change across OS versions. This paper introduces Aper, a static analyzer designed to catch these evolution- and asynchrony-induced permission misuses, significantly outperforming existing tools and uncovering dozens of real-world bugs.

What Problem Does This Paper Address?

Since Android 6.0, users can revoke app permissions at any time from system settings. This means developers can no longer assume a permission granted at install time remains granted; they must check the permission status immediately before invoking "dangerous" APIs.

However, writing safe permission code is surprisingly difficult for two reasons:

  1. Asynchrony: Developers often check permissions in one callback or component (e.g., MainActivity) but invoke the dangerous API in another (e.g., a button click handler or a separate Service).
  2. API Evolution: Android's permission specifications are a moving target. APIs frequently change their required permissions across Android framework versions. An app targeting a newer SDK might trigger a SecurityException and crash on an older device if it fails to guard the call with a runtime version check.

Existing static analysis tools are blind to these nuances. They either assume permission checks must happen synchronously right before an API call (leading to massive false alarms on safe asynchronous code) or completely ignore how permission requirements evolve across Android versions.

Methods

The authors developed Aper, a static analyzer that explicitly models both asynchronous permission management and API evolution.

Figure 6: Overview of Aper

Aper's pipeline consists of three main components:

  • Context Extractor: Traverses the app's Call Graph (CG) to map out the relationships between dangerous API calls and permission check sites. Crucially, it handles Inter-Component Communication (ICC) to track permissions across different app screens and services.
  • Dataflow Analyzer: Operates on an Inter-procedural Control-Flow Graph (ICFG) to resolve string literals (identifying exactly which permission is being checked) and tracks runtime version checks (e.g., Build.VERSION.SDK_INT).
  • Misuse Detector: Uses dominator analysis to verify if a dangerous API call is safely guarded by the correct permission check or version check. It flags two types of bugs: Type-1 (missing permission checks) and Type-2 (incompatible permission usage across different platform versions).

Datasets

The authors evaluated their approach using three distinct datasets:

  1. Empirical Study Dataset: 13,352 popular Google Play apps across 32 categories, used to analyze real-world developer permission practices.
  2. ARPfix Benchmark: A newly introduced, ground-truth benchmark created by the authors. It contains 60 real Android Runtime Permission (ARP) bugs (35 Type-1, 25 Type-2) and their corresponding patches collected from open-source GitHub projects.
  3. In-the-Wild Dataset: 214 open-source Android applications pulled from F-Droid to evaluate Aper's ability to find previously unknown bugs.

Key Insights and Ideas

  • Asynchrony is the Norm: Google's documentation implies developers should use simple, synchronous check-then-call patterns. In reality, the empirical study revealed that 86.0% of apps manage permissions asynchronously across different callbacks or components to optimize user experience and reuse code.
  • The Specifications are Shifting: Permission requirements are highly unstable. Between Android 6.0 and 11, over 76% of dangerous APIs underwent specification changes. APIs are frequently restricted further in newer versions, meaning old code can easily break on newer devices.
Table 1: Distribution and evolution of permission specification
  • Context-Insensitivity Kills Precision: Prior tools suffer from low precision because they perform flow-insensitive analysis or fail to track ICC. By explicitly modeling the temporal execution order of Android callbacks and component boundaries, Aper drastically reduces false positives.

Key Results

  • Benchmark Superiority: On the ARPfix benchmark, Aper significantly outperformed existing tools. For Type-1 bugs, it achieved an 81.25% $F_1$-score (a 43.5% improvement over the best academic baseline, RevDroid). For Type-2 bugs, it achieved an 85.19% $F_1$-score, vastly outperforming Android Studio's built-in Lint tool.
  • Average Improvement: Across both bug types, Aper improved the $F_1$-score by an average of 46.3% compared to existing tools.
  • Real-World Impact: When run on 214 open-source apps, Aper successfully uncovered 34 real, previously unknown ARP bugs. Most of these bugs could cause immediate app crashes. At the time of the paper's publication, developers had confirmed 17 of these bugs and fixed 7, including vulnerabilities lurking inside popular third-party libraries like ACRA.

Limitations and Future Work

While highly effective, Aper has a few limitations:

  • Incomplete Mappings: Aper relies on extracting permission specifications from framework annotations and Javadocs. It can miss undocumented permission requirements (such as Camera.open(), which requires permissions in practice but lacks explicit code annotations).
  • Content Providers: The tool currently cannot analyze permission behaviors related to Android Content Providers.
  • Future Directions: The authors plan to expand Aper's capabilities to detect library-induced permission bugs (where a third-party SDK breaks the host app) and device-specific bugs caused by hardware manufacturer customizations.

Summary updated

BibTeX
@misc{wang2022aper,
  author = {Sinan Wang and Yibo Wang and Xian Zhan and Ying Wang and Yepang Liu and Xiapu Luo and Shing-Chi Cheung},
  title = {{Aper: Evolution-Aware Runtime Permission Misuse Detection for Android Apps}},
  year = {2022},
  eprint = {2201.12542},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2201.12542},
}
Figure