Explainability-Guided Adversarial Attacks on Transformer-Based Malware Detectors using Control Flow Graphs

Andrew Wheeler, Kshitiz Aryal, Maanak Gupta · 2026

Read Explainability-Guided Adversarial Attacks on Transformer-Based Malware Detectors using Control Flow Graphs by Andrew Wheeler, Kshitiz Aryal, Maanak Gupta (2026) 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-2604-03843.txt.

Introduction

Andrew Wheeler and colleagues showed that explainability tools can arm attacks on transformer malware detectors built from control flow graphs. Their white-box attack used integrated-gradients attributions to find the most influential function calls, then swapped them for synthetic external imports without changing overall program structure. Tests on small and large Windows executable sets reliably induced misclassification, even for highly accurate models. The work warns that interpretability features can expose new attack surfaces.

Catalog record

CREATORAndrew Wheeler, Kshitiz Aryal, Maanak Gupta
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE41389
LICENSEhttp://creativecommons.org/licenses/by-sa/4.0/
RIGHTSCC BY SA
SOURCEarXiv

Source: https://arxiv.org/abs/2604.03843

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Explainability-Guided Adversarial Attacks on Transformer-Based Malware Detectors using Control Flow Graphs Andrew Wheeler, Kshitiz Aryal, Maanak Gupta Abstract Transformer-based malware detection systems operating on graph modalities such as CFG achieve strong performance by modeling structural relationships in program behavior. However, their robustness to adversarial evasion attacks remains underexplored. This paper examines the vulnerability of a RoBERTa-based malware detector that linearizes CFG into sequences of function calls, a design choice that enables transformer modeling but may introduce token-level sensitivities and ordering artifacts exploitable by adversaries. By evaluating evasion strategies within this graph-to-sequence framework, we provide insight into the practical robustness of transformer-based malware detectors beyond aggregate detection accuracy. This paper proposes a white-box adversarial evasion attack that leverages explainability mechanisms to identify and perturb most influential graph components. Using token- and word-level attributions derived from integrated gradients, the attack iteratively replaces positively attributed function calls with synthetic external imports, producing adversarial CFG representations without altering overall program structure. Experimental evaluation on small- and large-scale Windows Portable Executable (PE) datasets demonstrates that the proposed method can reliably induce misclassification, even against models trained to high accuracy. Our results highlight that explainability tools, while valuable for interpretability, can also expose critical attack surfaces in transformer-based malware detectors. I Introduction and Motivation The increasing volume and sophistication of malware has motivated the adoption of ML ( ML )-based techniques for automated malware detection. Traditional antivirus systems primarily rely on signature-based detection, which identifies malware by matching known byte patterns or hashes associated with previously analyzed samples. While effective for known threats, this approach struggles to detect new or modified malware variants because it requires signatures to be created and distributed before detection is possible. ML -based malware detection addresses this limitation by learning statistical and behavioral patterns that distinguish malicious software from benign programs. Consequently, ML -driven detection systems have become an increasingly important component of modern cybersecurity defenses, particularly for identifying zero-day threats and evolving malware families in dynamic environments. A major factor when training a malware detection system using ML is determining how the binary executable file will be represented, a choice commonly referred to as selecting the modality . This modality defines the form and structure of the features that will be extracted from an executable, and has important implications for the overall design of the detection pipeline. The selected representation not only dictates the feature extraction framework, but also influences the choice of model architecture itself, since different modalities are best handled by different types of models ( e.g. convolutional neural networks and image processing). There are modalities, such as raw byte sequences of binary executable, that needlessly consume superfluous data that is not relevant to the classification tasks. This is also the case with images as well, which are often derived from the raw byte sequences of executable files. Control Flow Graphs ( \Acp CFG) solve this issue by reducing the amount of information that is extracted from the executable file while still maintaining structural characteristics. Among the various modalities available, CFG have emerged as a particularly promising representation. CFG model the executable as a directed graph in which nodes correspond to basic blocks of code and edges represent possible execution paths, thus preserving both the structural layout of the program and important aspects of its runtime behavior. This ability to reflect program control flow makes CFG especially useful for distinguishing benign from malicious behavior in executable code, as can be seen in [ 19 ] and [ 6 ] . One of the recent advancement in ML, the transformer architecture is a powerful model intended for language-based tasks, such as NLP ( NLP ) and sentiment analysis [ 25 ] . However, due to model flexibility, it can be adapted for other tasks it originally wasn’t designed for, such as malware detection. In malware analysis, CFG naturally contain textual information in the form of function names and external imports, allowing them to be linearized into text sequences derived from program call graphs and processed as a text classification task by transformer-based models. Mathematically, we can represent a binary program as a graph G with a set of vertices V(G) corresponding to executable components of the program and a set of directed edges \overrightarrow{E}(G) representing some relationship between elements of V(G) . A single vertex v\in V(G) typically represents some executable portion of the program. This portion can be as small and atomic as a single assembly instruction, or it can be abstracted to higher levels, such as functions in the original source code. For every element v\in V(G) there is at least one e\in\overrightarrow{E}(G) for which it is an endpoint for. The directed edge connecting two program components typically represents a point at which the flow of execution is handed off from one component to the next. Organizing an executable program in this fashion allows for concise and simple representation of the program while still preserving the general control flow and form. Additionally, it allows for abstracting away from file format-specific structuring, such as if a program is formatted as a PE ( PE ) for Windows or ELF ( ELF ) for Linux. In graph based ML malware detection systems, structural and semantic information derived from vertices and edges, such as node features, instruction sequences, or connectivity patterns, are used as inputs to a learning model [ 16 , 19 , 6 ] . By leveraging both the structural relationships encoded in \overrightarrow{E}(G) and the semantic information contained in V(G) , graph-based models can capture program behavior more effectively than flat feature representations, enabling improved generalization to previously unseen malware samples. Adversarial Attacks on Malware Detector: While ML-based malware detectors enable zero-day malware detection, they open up a threat surface for adversarial evasion (AE) attacks. Such AE attacks are performed by introducing a carefully crafted adversarial perturbations to the test samples such that malware is identified as benign by detectors while it still preserves its malicious functionality. Existing adversarial evasion attacks against malware detectors have largely focused on byte-based or feature-vector representations of binaries. In these approaches, adversaries typically manipulate raw byte sequences, inject benign byte patterns, or modify extracted features in order to evade detection while preserving program functionality [ 11 , 3 , 4 , 5 ] . Such attacks have been widely studied in the context of deep learning models that operate directly on binary byte streams or static feature representations, demonstrating that small perturbations can significantly reduce detection accuracy while maintaining executable behavior. These techniques, however, are closely tied to the representation used by the detector and therefore do not directly translate to models that operate on structural program representations. While graph based malware detection approaches capture richer semantic and behavioral information than byte-level representations, adversarial evasion attacks against them remain relatively limited. Existing work on graph-based attacks typically focuses on modifying graph structure or node attributes to influence model predictions, but these studies often target graph neural networks rather than transformer-based architectures [ 16 , 19 , 6 ] . As a result, there remains a gap in understanding how adversarial evasion strategies can be applied to malware detectors that leverage transformer models over graph-derived representations. Our work addresses this gap by

Read the complete text