Abstract
Android's security model effectively sandboxes applications but fails to regulate malicious activity within the application's own process space, particularly from third-party native libraries. These libraries, often used for performance or code reuse, run with the same permissions as the host app and can bypass Java-level security checks. This paper presents NativeProtector, a system that secures Android applications by isolating native libraries into a separate "server" process and intercepting critical system calls. By combining process isolation with fine-grained mediation via Global Offset Table (GOT) hooking, NativeProtector prevents data leakage and unauthorized actions without compromising legitimate app functionality.
Introduction
The Android ecosystem relies heavily on the Java Native Interface (JNI) to allow Java/Kotlin code to interact with native C/C++ libraries. While this enables high-performance computing and cross-platform code reuse, it introduces a significant security "black box." Native libraries operate with the host application's full permissions and can access the entire process address space. Malicious or compromised libraries can thus steal sensitive data (e.g., IMEI, location) or perform unauthorized network activities, bypassing the standard Android permission system.
Previous attempts to sandbox these libraries often resulted in application crashes because they stripped all permissions from the isolated process. NativeProtector addresses this by maintaining permissions while implementing fine-grained interception of system calls.
System Architecture and Methods
NativeProtector transforms a standard Android application into a hardened version through a multi-step process involving isolation and interception.
1. Apk Repackaging and Process Splitting
Using tools like apktool, NativeProtector disassembles the target APK. It identifies native function calls within the Java bytecode and replaces them with Inter-Process Communication (IPC) calls. The original application is then split into two distinct entities:
- Client App: Retains the original Java bytecode and resources, serving as the user-facing interface.
- Server App: An Android service that houses the original native libraries and "wrapped" bytecode designed to handle incoming IPC requests from the client.
2. Fine-Grained Interception and Policy Management
Unlike previous solutions, the Server App is granted the original application's permissions to ensure compatibility. To prevent abuse, NativeProtector injects "stub libraries" that employ GOT (Global Offset Table) hooking. By overwriting GOT entries, the system intercepts critical system calls to external libraries (like libc), such as ioctl() for hardware access and connect() for networking.
An integrated Policy Manager evaluates these intercepted calls against predefined whitelists or blacklists. For example, it can block connections to known malicious IP addresses or prevent the retrieval of the device's IMEI while allowing legitimate hardware interactions.
Evaluation
The authors evaluated NativeProtector's effectiveness, compatibility, and performance using a custom malicious application and 20 popular real-world apps (e.g., Twitter, Firefox, DuoLingGo).
- Effectiveness: In tests with a custom malicious app, NativeProtector successfully blocked location data theft and unauthorized network connections while maintaining the app's core functionality.
- Compatibility: The system successfully processed 15 out of 20 popular apps. The five failures were linked to limitations in the disassembly tool (
apktool) rather than the NativeProtector logic itself. - Performance: Performance overhead varies by workload. In a worst-case scenario involving frequent context switching (Zlib compression of 1KB segments), overhead reached 81.79%. However, for typical API-heavy tasks, the overhead was approximately 50%.
Discussion and Conclusion
NativeProtector demonstrates that isolation alone is insufficient for securing native libraries; "permission mediation" is required. By performing static instrumentation at the bytecode level, the system avoids the need for rooted devices or custom ROMs, facilitating easier deployment.
However, challenges remain. The system's reliance on apktool makes it vulnerable to failures in disassembling heavily obfuscated apps. Additionally, the current model assumes the Java component of the app is trustworthy. Future work may focus on optimizing the IPC mechanism to reduce performance overhead for "chatty" applications and expanding the trust model to cover the entire application lifecycle.
Summary updated