NatiDroid: Cross-Language Android Permission Specification

Chaoran Li, Xiao Chen, Ruoxi Sun, Jason Xue, Sheng Wen, Muhammad Ejaz Ahmed, Seyit Camtepe, Yang XiangarXiv 2021

Abstract

Android security relies on a robust permission system to protect sensitive data and hardware. However, the lack of an official mapping between APIs and required permissions has led to the development of automated tools that predominantly analyze the Java framework. This paper introduces NATIDROID, the first security tool to perform cross-language static analysis (Java and C/C++) to uncover permission enforcement within native libraries. Our findings reveal a significant "Native Gap," identifying over 450 undocumented permission-protected APIs and demonstrating that existing security benchmarks suffer from substantial inaccuracies.

Introduction

Android's permission system is the cornerstone of its security model. Because Google provides no official, comprehensive list mapping specific APIs to the permissions they require, developers and researchers rely on reverse-engineering tools like AXPLORER. However, these state-of-the-art tools are often "blind" to the native layer of the Android framework. In reality, many critical functions—especially those interacting with hardware sensors and cameras—are implemented in native C/C++ libraries. This visibility gap leads to false positives in over-privilege detection and false negatives in vulnerability detection.

The "Native Gap" in Android Security

The enforcement of hardware-centric permissions (like CAMERA and RECORD_AUDIO) often occurs deep within the native layer. When a Java application requests access to a resource, the call stack frequently descends through the Java API Framework into native libraries via the Java Native Interface (JNI).

Figure 2: A cross-layer call stack showing a permission check for the camera occurring within the native C++ library, illustrating the "Native Gap."

As shown in the example above, a request to open the camera initiated in the Java layer eventually reaches CameraService::connectDevice in the native library. It is only at this level that the android.permission.CAMERA check is performed. Tools that only analyze Java code would conclude that the initial API call requires no permission, leading to significant mapping errors.

Methodology: The NATIDROID Pipeline

NATIDROID addresses this challenge by constructing a unified Control Flow Graph (CFG) that follows execution paths as they jump from Java into native libraries. The system operates in three main stages:

Figure 3: The three-stage workflow of NATIDROID: Pre-processing, Entry Point Identification, and Cross-language CFG Generation.
  1. Pre-processing: The system extracts intermediate artifacts, such as .jar files for Java and Clang compile commands for C++, from the Android Open Source Project (AOSP) codebase.
  2. Entry-Point Identification: NATIDROID models two primary communication channels: JNI for direct calls between Java and C++, and AIDL (Android Interface Definition Language) for Inter-Process Communication (IPC) between system services.
  3. Cross-Language CFG Generation: By building a unified CFG, NATIDROID can trace paths to security checkpoints (like checkPermission calls) within native code to create an accurate API-to-permission mapping.

Key Results and Impact

Evaluating NATIDROID against four versions of AOSP and over 11,000 apps yielded several critical insights:

  • New Mappings: NATIDROID identified between 449 and 464 new API-permission mappings missed by previous tools.
  • Correcting the Record on Over-privilege: Previous studies suggested that ~96% of apps were over-privileged. NATIDROID reveals that 71% of these flags were false positives because the required permission checks were hidden in native code (e.g., INTERNET checks within the MediaPlayer library).
  • Vulnerability Discovery: The tool identified 24 vulnerable components misidentified as safe by traditional benchmarks. These "Native-triggered" vulnerabilities allow unauthorized access to native resources via exported app components. The researchers disclosed these 24 previously unknown vulnerabilities to major vendors including Samsung, Huawei, Xiaomi, and LG.

Conclusion

NATIDROID demonstrates that the "Native Gap" is a substantial hurdle for Android security analysis. By bridging the divide between Java and native code, NATIDROID provides a more accurate foundation for permission specification and vulnerability detection, proving that hardware-centric security cannot be audited by looking at the Java layer alone.

Summary updated

BibTeX
@misc{li2021natidroid,
  author = {Chaoran Li and Xiao Chen and Ruoxi Sun and Jason Xue and Sheng Wen and Muhammad Ejaz Ahmed and Seyit Camtepe and Yang Xiang},
  title = {{NatiDroid: Cross-Language Android Permission Specification}},
  year = {2021},
  eprint = {2111.08217},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.08217},
}
Figure