Abstract
While graph-based Android malware classifiers achieve over 94% accuracy on standard benchmarks, they exhibit a significant generalization gap under distribution shift, suffering up to 45% performance degradation when encountering unseen malware variants from known families. This work systematically investigates this critical yet overlooked challenge for real-world deployment by introducing a benchmarking suite designed to simulate two prevalent scenarios: MalNet-Tiny-Common for covariate shift, and MalNet-Tiny-Distinct for domain shift. Furthermore, we identify an inherent limitation in existing benchmarks where the inputs are structure-only function call graphs, which fails to capture the latent semantic patterns necessary for robust generalization. To verify this, we construct a semantic enrichment framework that augments the original topology with function-level attributes, including lightweight metadata and LLM-based code embeddings. Empirical evaluations confirm the effectiveness of our data-centric methodology, with which classification performs better under distribution shift compared to model-based approaches, and consistently further enhances robustness when used in conjunction.
The Generalization Gap in Malware Detection
Graph Neural Networks (GNNs) have become a standard for detecting Android malware by analyzing Function Call Graphs (FCGs). In these graphs, nodes represent functions and edges represent calls between them. While these models perform exceptionally well on standard, well-shuffled datasets, they often fail in real-world scenarios where malware constantly evolves. This "generalization gap" occurs because models are typically evaluated on in-distribution data, failing to account for distribution shifts—such as new variants (covariate shift) or entirely new malware families (domain shift).
Existing benchmarks like MalNet-Tiny often strip away semantic information (e.g., function names or code content) for security reasons, leaving only structural features like node degrees. Without semantic context, GNNs tend to memorize local graph structures rather than learning malicious behavior, making them brittle when deployed against novel threats.
Semantic Enrichment Framework
To address the limitations of structure-only graphs, we propose a data-centric semantic enrichment framework. Instead of relying purely on topology, we extract rich features directly from the decompiled malware code to provide the model with behavioral context:
- Metadata Features: Lightweight statistics including access flags, string statistics, and Android-specific behaviors (e.g., storage access).
- LLM Source Code Embeddings: Dense vector representations of function bodies generated using CodeXEmbed, a code-specific Large Language Model.
Because real-world decompilation is often incomplete, we introduce three collation strategies to handle missing node features: Trim (removing non-universal feature dimensions), Zero (padding missing values with zeros), and Prune (discarding nodes with incomplete features). Our findings suggest that while traditional Message Passing NNs (GCN/GIN) benefit from Pruning, Graph Transformers (GPS/Exphormer) are more robust and perform best with the Zero-padding strategy.
Benchmarking Distribution Shift
We introduce two new benchmarks built upon MalNet-Tiny to evaluate model robustness:
- MalNet-Tiny-Common (Covariate Shift): Training and test samples share malware families but differ in subtypes, simulating novel approaches to existing attack paradigms.
- MalNet-Tiny-Distinct (Domain Shift): Test samples are drawn from entirely unseen malware families, simulating zero-day threats.
Results and Analysis
Our empirical results confirm that the generalization gap is a significant hurdle. Baseline models trained on structural features alone saw accuracy drop from ~90% to approximately 47-48% when faced with covariate shift in the MalNet-Tiny-Common dataset.
As shown in the figure above, our data-centric semantic enrichment significantly boosts robustness. For instance, a GCN's accuracy on shifted data improved from 48.1% to 60.3% using the Prune strategy. Furthermore, combining these enriched features with model-centric adaptation techniques (like finetuning) yielded the best results, with accuracies reaching 91-98% on shifted datasets. This suggests that semantic features provide a much stronger foundation for models to adapt to new, evolving threats.
Conclusion
This work highlights that structural information alone is insufficient for robust malware detection. By providing a benchmarking suite for distribution shifts and a framework for semantic enrichment, we demonstrate that a data-centric approach—focusing on "what a function does" rather than just "who it calls"—is essential for closing the generalization gap. We release our datasets and pipeline to facilitate the development of more resilient malware detection systems.
Summary updated