MalLoc: Toward Fine-grained Android Malicious Payload Localization via LLMs
Tiezhu Sun, Marco Alecci, Aleksandr Pilgun, Yewei Song, Xunzhu Tang, Jordan Samhi, Tegawendé F. Bissyandé, Jacques Klein University of Luxembourg, Luxembourg {firstname.lastname}@uni.lu · 2025
Read MalLoc: Toward Fine-grained Android Malicious Payload Localization via LLMs by Tiezhu Sun, Marco Alecci, Aleksandr Pilgun, Yewei Song, Xunzhu Tang, Jordan Samhi, Tegawendé F. Bissyandé, Jacques Klein University of Luxembourg, Luxembourg {firstname.lastname}@uni.lu (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2508-17856.txt.
Introduction
Tiezhu Sun and seven co-authors use large language models to pinpoint the harmful code inside Android malware. Flagging an app as bad is not enough; analysts need to know which lines do the damage. Malware often hides with scrambled code and delayed triggers, which defeats older tools. Their 2025 system, MalLoc, reads the code with a language model that can follow what each part does. It marks the payload at a fine level of detail.
Tests showed the approach can find the harmful parts with useful accuracy. Clear marks help analysts grasp how an attack works, step by step. That grasp supports fixes aimed at the exact weak spot rather than the whole app. The authors also point to future work on tracking how the threats change over time.
Catalog record
| CREATOR | Tiezhu Sun, Marco Alecci, Aleksandr Pilgun, Yewei Song, Xunzhu Tang, Jordan Samhi, Tegawendé F. Bissyandé, Jacques Klein University of Luxembourg, Luxembourg {firstname.lastname}@uni.lu |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 25 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2508-17856
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
MalLoc: Toward Fine-grained Android Malicious Payload Localization via LLMs Tiezhu Sun, Marco Alecci, Aleksandr Pilgun, Yewei Song, Xunzhu Tang, Jordan Samhi, Tegawendé F. Bissyandé, Jacques Klein University of Luxembourg, Luxembourg {firstname.lastname}@uni.lu Abstract The rapid evolution of Android malware poses significant challenges to the maintenance and security of mobile applications (apps). Traditional detection techniques often struggle to keep pace with emerging malware variants that employ advanced tactics such as code obfuscation and dynamic behavior triggering. One major limitation of these approaches is their inability to localize malicious payloads at a fine-grained level, hindering precise understanding of malicious behavior. This gap in understanding makes the design of effective and targeted mitigation strategies difficult, leaving mobile apps vulnerable to continuously evolving threats. To address this gap, we propose MalLoc , a novel approach that leverages the code understanding capabilities of large language models (LLMs) to localize malicious payloads at a fine-grained level within Android malware. Our experimental results demonstrate the feasibility and effectiveness of using LLMs for this task, highlighting the potential of MalLoc to enhance precision and interpretability in malware analysis. This work advances beyond traditional detection and classification by enabling deeper insights into behavior-level malicious logic and opens new directions for research, including dynamic modeling of localized threats and targeted countermeasure development. I Introduction Android powers billions of mobile devices worldwide [ 1 ] , enabling a vast ecosystem of applications (apps) that enhance our productivity, entertainment, and daily life. However, the widespread adoption and open nature of the Android platform have made it an attractive target for attackers seeking to exploit users and systems through malicious apps. Over time, Android malware has evolved rapidly, adopting sophisticated techniques such as code obfuscation [ 2 ] , dynamic behavior triggering [ 3 ] , and payload repackaging [ 4 ] to evade traditional detection mechanisms [ 5 , 6 ] . These evolving threats pose critical challenges to the maintenance and evolution of secure mobile apps, requiring continuous advancements in malware analysis and mitigation strategies. While malware detection techniques have improved in identifying whether an app is malicious or benign [ 7 , 8 , 9 , 10 , 11 , 12 ] , and malware family classification techniques can further categorize malicious apps into known families [ 13 , 14 , 15 , 16 , 17 ] , these advances still fall short of providing actionable insights at the code level. Specifically, most existing models lack the capability for fine-grained localization of malicious payloads, making it difficult to accurately identify the specific code locations responsible for harmful behaviors. This limitation impedes the understanding of how malware operates and evolves, and it prevents researchers from extracting high-quality, behaviorally meaningful features that could strengthen detection models and improve long-term resilience. In addition, many learning-based detection and classification models act as black boxes, offering little insight into their decision-making processes. This lack of transparency hinders analysts’ ability to validate predictions, understand model limitations, and derive actionable countermeasures—ultimately limiting their utility in real-world, security-critical contexts. A few existing works [ 18 , 19 ] have attempted to localize malicious payloads at the class level. However, they suffer from limited localization precision, making it difficult to precisely pinpoint the actual code implementing malicious behaviors. Moreover, they lack the ability to provide specific behavior descriptions that explain how the identified payloads operate. To the best of our knowledge, our approach MalLoc is the first to explore fine-grained malicious payload localization along two key dimensions: ❶ Method-level localization , which focuses on identifying the small executable code units (Smali methods) responsible for malicious behaviors, improving precision over class-level approaches; ❷ Detailed behavioral explanations , which provides human-readable insights into the specific actions and intent of the localized malicious payloads, supporting explainability and analyst validation. To achieve this, MalLoc innovatively leverages malware family knowledge as guidance, incorporates LLM-powered semantic reasoning, and employs a two-phase approach to progressively and precisely localize malicious methods and identify their behavioral roles. Fig. 1: The overview of different stages of Android malware analysis. To enable a reliable evaluation of MalLoc , we developed a demo Android app, MalApp , from scratch. It implements several common malicious behaviors observed in real-world malware, such as privacy theft and aggressive advertising, and provides fine-grained ground truth for controlled and quantitative assessment of localization capabilities. In addition, we evaluate MalLoc on a real-world Android malware sample from MalRadar [ 20 ] and manually analyze its predictions to validate their correctness. Experimental results highlight the potential of MalLoc to advance malware analysis toward more precise and explainable behavior localization. We believe this work can inform future research directions, such as dynamic analysis of localized payloads, the development of interpretable malware detection models, and the design of targeted mitigation strategies grounded in behavior-level insights. The contributions of this work are summarized as follows: • We propose MalLoc , a novel LLM-driven approach for fine-grained localization of malicious payloads in Android malware, simultaneously generating corresponding behavioral explanations. • We develop a demo app and analyze a real-world malware sample, enabling preliminary empirical evaluation at the method level and demonstrating the potential of MalLoc to advance analysis precision and explainability. • To support reproducibility and future research, we publicly release the dataset and source code of MalLoc at: https://github.com/Trustworthy-Software/MalLoc II Background Android Malware Analysis. Machine learning-based approaches [ 7 , 21 , 22 , 9 , 23 , 24 ] for Android malware analysis have been extensively explored over the past decade. More recently, researchers have begun investigating the potential of applying LLMs to this domain [ 25 ] . However, the majority of prior work remains focused on early-stage tasks—namely, malware detection (Stage 1 in Figure 1 ) and family classification (Stage 2 in Figure 1 ). Despite their importance, these early-stage techniques fall short of fulfilling the ultimate goal of malware analysis: enabling effective malware defense. This includes tasks such as dynamic modeling of malicious behavior, robustness testing of detection systems, and the design of targeted countermeasures. Bridging the gap between detection/classification and actionable defense requires a deeper, more granular understanding of how malicious behaviors are implemented and triggered within an application. A critical missing bridge in this process is fine-grained malicious payload localization (Stage 3 in Figure 1 )—the ability to identify and interpret specific methods or code segments responsible for malicious actions. Without this capability, security analysts are left with limited insight into the internal workings of malware, hindering both interpretability and mitigation efforts. The mission of MalLoc is to close this gap by advancing malware analysis beyond coarse-grained classification: fine-grained localization and behavioral explanation represent the core novelty of our work . MalLoc paves the way for more precise, explainable, and actionable malware analysis. Smali Code. Android apps are primarily written in Java or Kotlin and compiled into DEX (Dalvik Executable) bytecode [ 26 ] , which is stored in .dex files within APKs (Android Package files that bundle the compiled code and resources for distribution). Since these packages usually do not include the original source code, direct access to high-level code is not feasible. To enable analysis, tools such as ApkTool [ 27 ] can decompile the bytecode into Smali, a low-level, human-readable representation of DEX