On Benchmarking Code LLMs for Android Malware Analysis

Yiling He, Hongyu She, Xingzhi Qian, Xinran Zheng, Zhuo Chen, Zhan Qin, Lorenzo CavallaroISSTA Companion 2025 · DOI

TL;DR

This paper introduces CAMA, a novel framework for evaluating how well Large Language Models (LLMs) trained on code can analyze Android malware. By defining structured outputs and domain-specific metrics, the authors reveal the current strengths and weaknesses of these models in identifying malicious functions and summarizing malware behavior, highlighting the potential of instruction-tuned models.

What Problem Does This Paper Address?

The increasing sophistication of Android malware poses a significant challenge for security analysts. Manually sifting through decompiled code, which is often obfuscated and lacks clear function names, is a time-consuming and error-prone process. While Large Language Models (LLMs) have shown promise in understanding and generating code, their effectiveness in the specialized domain of Android malware analysis remains largely unexplored. Decompiled code presents unique difficulties for LLMs due to its inherent messiness and the absence of reliable ground truth for maliciousness. This paper aims to bridge this gap by providing a systematic way to benchmark Code LLMs for this critical task.

Methods

The core contribution of this paper is the CAMA (Code LLM for Android Malware Analysis) benchmarking framework. CAMA is designed to systematically evaluate Code LLMs by focusing on two key downstream tasks:

  1. Malicious Function Identification: Pinpointing suspicious code segments within an application.
  2. Malware Purpose Summarization: Generating concise descriptions of an app's overall malicious objectives.

To achieve this, CAMA defines a structured output format for LLMs, which includes:

  • Refined Function Names: Suggesting more descriptive names for decompiled functions.
  • Concise Function Summaries: Providing high-level descriptions of a function's purpose.
  • Maliciousness Scores: Quantifying the potential harm of a function on a scale of 0-10.

The framework then employs three domain-specific evaluation metrics:

  • Consistency: Measures the stability of LLM outputs (names and scores) under self-referential prompting.
  • Fidelity: Assesses how much structured outputs contribute to accurate malware classification by measuring the impact of removing top-k malicious functions on a classifier's confidence.
  • Semantic Relevance: Evaluates how well LLM-generated application descriptions align with ground-truth descriptions, using metrics like BLEU, METEOR, and ROUGE-L.

The authors also detail prompt engineering strategies for instruction-tuned models and instruction tuning for text-to-text models to guide LLMs towards producing the desired structured outputs. For models lacking direct maliciousness score generation capabilities (like CodeT5 and PLBART), they propose a two-step approach using external models for score prediction.

Datasets

The paper introduces a new benchmark dataset specifically for this research. This dataset consists of:

  • 118 Android malware samples collected from recent years, spanning 6 categories and 13 families.
  • Over 7.5 million decompiled Java functions extracted from these samples.

This dataset was constructed using the LAMD dataset for ground-truth application purpose summaries and the Androguard tool for decompilation. The authors also performed de-duplication to ensure diversity and representativeness.

Key Insights and Ideas

  • Instruction-tuned models shine: GPT-style instruction-tuned models (like CodeLlama and StarChat) significantly outperform traditional Seq2Seq models (CodeT5, PLBART) in generating structured outputs and performing malware analysis tasks.
  • Function renaming is a double-edged sword: While LLM-suggested function names improve consistency and fidelity (making it easier to identify malicious functions), they can sometimes decrease semantic clarity when aggregating information for overall app purpose summarization.
  • Malware analysis is hard for LLMs: Despite advancements, LLMs still struggle with accurately assessing the maliciousness of code, especially when dealing with obfuscated or incomplete decompiled functions.
  • The need for structured outputs: The paper strongly advocates for structured outputs (names, summaries, scores) as a crucial step towards making LLM analysis interpretable and actionable for security analysts.
  • Ground truth is a bottleneck: The scarcity of reliable, fine-grained ground truth data for malware function-level analysis is a significant challenge that CAMA attempts to mitigate through its evaluation metrics.

Key Results

  • Consistency: StarChat achieved the highest maliciousness consistency score (0.813), significantly outperforming CodeLlama (0.628). For name consistency, CodeLlama led with 0.499, followed closely by StarChat (0.575).
  • Fidelity: StarChat demonstrated superior fidelity across different top-k values (k=2, 5, 8), indicating its structured outputs are more effective for malicious function identification. For example, MFS(2) for StarChat was 0.298, compared to 0.158 for CodeLlama.
  • Semantic Relevance: StarChat also led in semantic relevance metrics (BLEU, METEOR, ROUGE-L), suggesting its generated app descriptions were more aligned with ground truth.
  • Impact of Renaming (RQ2): Renaming original function names with LLM suggestions led to substantial improvements in fidelity for both CodeLlama+ (183.7% increase) and StarChat+ (168.5% increase). Consistency also saw moderate improvements. However, semantic relevance slightly decreased.

Limitations and Future Work

  • Ground Truth Scarcity: The paper acknowledges the fundamental challenge of obtaining reliable function-level ground truth for malware analysis. Their fidelity metric relies on counterfactual methods, and summarization uses techniques from LLM-driven detection, which can introduce noise.
  • External Models for Scores: For models like CodeT5 and PLBART, maliciousness scores were generated by external models, which might influence their performance evaluation.
  • Future Directions:
    • Developing more high-quality, fine-grained ground truth datasets for malware analysis.
  • Exploring methods to calibrate LLM scores to better reflect confidence.
  • Explicitly encoding more robust knowledge about malware semantics into LLMs.
  • Adapting CAMA for broader research, including studies on malware concept drift and generalization to other programming languages or security domains.
  • Guiding the selection, pretraining, or fine-tuning of Code LLMs specifically for malware tasks.

Summary updated

BibTeX
@inproceedings{he2025benchmarking,
  author = {Yiling He and Hongyu She and Xingzhi Qian and Xinran Zheng and Zhuo Chen and Zhan Qin and Lorenzo Cavallaro},
  title = {{On Benchmarking Code LLMs for Android Malware Analysis}},
  booktitle = {ISSTA Companion},
  year = {2025},
  doi = {10.1145/3713081.3731745},
}
Figure