Shelving it rather than Ditching it: Dynamically Debloating DEX and Native Methods of Android Applications without APK Modification

Zicheng Zhang, Jiakun Liu, Ferdian Thung, Haoyu Ma, Rui Li, Yan Naing Tun, Wei Minn, Lwin Khin Shar, Shahar Maoz, Eran Toch, David Lo, Joshua Wong, Debin GaoarXiv 2025 · DOI

Abstract

Modern Android applications are often bloated with unused features, creating significant security risks and resource overhead. Traditional debloating methods rely on static APK modification, which breaks security signatures and lacks flexibility. This paper presents 3DNDroid, a dynamic debloating framework that operates at the OS level. By intercepting method calls within a customized Android Runtime (ART), 3DNDroid "shelves" unused DEX and native code without modifying the original APK. Evaluation on 55 real-world apps demonstrates significant attack surface reduction and performance improvements while maintaining app stability and security integrity.

Introduction: The Bloatware Security Gap

Modern Android apps are notoriously bloated; research suggests that up to 80% of features in typical software are rarely used. This "bloat" isn't just a storage issue—it’s a major security liability. Every unused line of code represents a potential entry point for attackers, specifically through Return-Oriented Programming (ROP) gadgets or unpatched vulnerabilities in third-party libraries.

Existing "debloating" tools usually work by statically modifying the app's files (APKs) and repackaging them. This approach has three major flaws:

  1. Security Breaches: Repackaging breaks the Android security model by compromising public key verification and code integrity checks.
  2. Inflexibility: Once a feature is stripped out, it’s gone. You can't easily "turn it back on" without reinstalling the original app.
  3. Native Code Neglect: Most tools focus on Java/DEX code, leaving vulnerable native libraries untouched.
Comparison of 3DNDroid with existing debloating tools

3DNDroid: A Dynamic "Divide-and-Rule" Approach

The authors propose 3DNDroid, a "late-stage" debloating framework that operates at the OS level rather than the file level. It consists of a management app and a customized Android Open Source Project (AOSP) runtime.

The 3DNDroid system architecture and workflow

The system works in two phases:

  • Offline Preparation: It uses static and dynamic analysis tools to generate a "debloating schema"—a list of methods the user wants to disable.
  • Dynamic Debloating: When an app launches, the customized Android Runtime (ART) fetches this schema via a secure ContentProvider.

The "Divide-and-Rule" strategy handles the two types of code differently:

  • DEX Methods: 3DNDroid intercepts the method invocation process in ART. It prevents the interpreter from executing the code and freezes the method's invocation counter to prevent JIT/AOT compilers from generating executable native code.
  • Native Methods: 3DNDroid identifies memory offsets of target methods during library loading. It then "zero-fills" that memory space and inserts a return instruction, neutralizing the code while keeping the app stable.

To prevent crashes, 3DNDroid uses a Graceful Termination strategy, redirecting calls to debloated methods to a safe "Activity" that informs the user why the feature is unavailable.

Key Results and Evaluation

The researchers evaluated 3DNDroid using 55 real-world Android applications from Google Play, including popular apps like Adobe Reader, Discord, and Duolingo.

  • Effectiveness: The tool successfully debloated 187 DEX methods and 30 native methods across the test suite.
  • Attack Surface Reduction: 3DNDroid removed over 13,000 potential ROP gadgets from compiled DEX code and 586 from native libraries.
  • Vulnerability Mitigation: Case studies proved the tool could block known vulnerabilities (CVEs) in libraries like Netty and Bouncy Castle by disabling affected methods.
  • Performance Gains: Debloated apps saw a median reduction in CPU usage of 14.2% (DEX) and 28.8% (Native).

Conclusion and Future Work

3DNDroid offers a reversible, security-compliant alternative to static debloating. By "shelving" code at runtime, it preserves the chain of trust while effectively reducing the attack surface.

The primary hurdle is deployment, as it requires a customized Android OS. Future work explores using eBPF to inject debloating logic into the kernel more easily, potentially allowing for wider adoption through collaboration with device vendors.

Summary updated

BibTeX
@misc{zhang2025shelving,
  author = {Zicheng Zhang and Jiakun Liu and Ferdian Thung and Haoyu Ma and Rui Li and Yan Naing Tun and Wei Minn and Lwin Khin Shar and Shahar Maoz and Eran Toch and David Lo and Joshua Wong and Debin Gao},
  title = {{Shelving it rather than Ditching it: Dynamically Debloating DEX and Native Methods of Android Applications without APK Modification}},
  year = {2025},
  eprint = {2501.04963},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.04963},
}
Figure