Droidetec: Android Malware Detection and Malicious Code Localization through Deep Learning

Zhuo Ma, Haoran Ge, Zhuzhu Wang, Yang Liu, Ximeng Liu · DOI

Abstract

Android malware detection is a critical step towards building a security credible system. Especially, manual search for the potential malicious code has plagued program analysts for a long time. In this paper, we propose Droidetec, a deep learning based method for android malware detection and malicious code localization, to model an application program as a natural language sequence. Droidetec adopts a novel feature extraction method to derive behavior sequences from Android applications. Based on that, the bi-directional Long Short Term Memory network is utilized for malware detection. Each unit in the extracted behavior sequence is inventively represented as a vector, which allows Droidetec to automatically analyze the semantics of sequence segments and eventually find out the malicious code. Experiments with 9616 malicious and 11982 benign programs show that Droidetec reaches an accuracy of 97.22% and an F1-score of 98.21%. In all, Droidetec has a hit rate of 91% to properly find out malicious code segments.

Introduction

The rapid proliferation of Android malware has created a significant challenge for security analysts. Traditional automated detection tools often struggle with two primary issues: a lack of execution context and the "black box" nature of classification. Many tools rely on static features like permission lists without considering the logical flow of the program. Furthermore, simply labeling an app as "malicious" without identifying the specific offending code forces analysts into a time-consuming manual search. Droidetec addresses these gaps by treating program behavior as a natural language sequence, enabling both high-accuracy detection and precise malicious code localization.

Methodology

The Droidetec framework models program execution as a sequence of behaviors, similar to sentences in a language. The pipeline consists of four primary stages: preprocessing, sequence generation, API vectorization, and detection/localization.

Overview of the Droidetec framework pipeline, from APK preprocessing to malware detection and code localization.

Sequence Feature Extraction

Unlike simple static scans, Droidetec performs a depth-first invocation traversal of the bytecode. By following the calling relationships between methods, it reconstructs the logical flow of the program, focusing on invoke- opcodes (API calls). This process transforms the complex graph of method calls into a linear behavior sequence.

Example of depth-first invocation traversal used to extract API sequences from root methods.

Semantic Vectorization and Modeling

To capture the functional relationships between different API calls, Droidetec employs a Skip-gram model (similar to Word2Vec) to convert API identifiers into dense 100-dimensional vectors. These vectors are then processed by a Bi-directional Long Short-Term Memory (Bi-LSTM) network. The Bi-LSTM is crucial as it reads sequences in both directions, capturing the full context of an API call—both what preceded it and what it triggered.

Attention-Based Localization

The "secret sauce" for localization is an attention mechanism. The attention layer assigns weights to different units in the sequence based on their contribution to the final classification. High weights indicate suspicious APIs, which the system then maps back to the original decompiled source code to provide a report of suspicious methods and segments.

Experimental Results

The system was evaluated using a dataset of 21,598 applications, including 9,616 malicious samples from the AMD dataset and 11,982 benign samples from Google Play.

  • Detection Performance: Droidetec achieved an accuracy of 97.22% and an F1-score of 98.21%, outperforming baseline methods like Droid-Sec.
  • Localization Accuracy: The model demonstrated a 91% hit rate in correctly identifying malicious code segments. By focusing on the top 9 most suspicious methods identified by the attention weights, the system maintains a high balance of precision and recall.
  • Robustness: High detection rates were maintained across various malware families (e.g., FakeInst, Fusob), though performance slightly dipped for families with sparse training data.

Conclusion and Future Work

Droidetec successfully bridges the gap between malware detection and manual analysis by providing explainable results through attention-based localization. While highly effective, current limitations include a lack of visibility into native code (.so files) and the computational overhead of feature extraction (averaging 1.26s per app). Future research will focus on multi-classification for malware family identification and refining localization precision to provide even more granular code ranges.

Summary updated

BibTeX
@misc{ma2020droidetec,
  author = {Zhuo Ma and Haoran Ge and Zhuzhu Wang and Yang Liu and Ximeng Liu},
  title = {{Droidetec: Android Malware Detection and Malicious Code Localization through Deep Learning}},
  year = {2020},
  eprint = {2002.03594},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.03594},
}
Figure