Manuscript Offprint

arXiv:2608.28499

REPLICANT: Learning Policies for Evading and Hardening Malware Detectors

Shae McFadden, Ilias Tsingenopoulos, Mario D'Onghia, Alexander Herzog, Myles Foley, Chris Hicks, Lorenzo Cavallaro, Fabio Pierazzi

Abstract

To determine the real-world effectiveness of machine learning based malware detection, it is vital to evaluate its robustness against highly capable adversaries. However, state-of-the-art attacks do not effectively model realistic adversaries, as they often assume access to privileged information such as the training data, feature space, or confidence scores of the target. In this work, we present REPLICANT, a deep reinforcement learning framework that learns the realistic task of evasion under a strict label-only black-box threat model. REPLICANT learns a reusable policy on how to modify a malware sample and when to query the target, which transfers across samples, detectors, and feature spaces. Across seven Android malware detectors and three feature spaces, REPLICANT is the strongest and most query-efficient approach achieving a mean attack success rate of 78.8%, a relative improvement of 20.9%–39.2% over the state-of-the-art. Furthermore, when used for adversarial training, REPLICANT also outperforms the state-of-the-art by producing detectors with more generalizable robustness. With REPLICANT we demonstrate that learning the task of evasion not only results in stronger attack performance but, crucially, provides a better signal for hardening malware detectors.

1 Introduction

Machine Learning (ML) classifiers have become a key line of defence against malware, with extensive research focusing on improving their performance and robustness to drift [4, 6, 16, 39, 46, 47, 51, 57, 80, 82] and Android being an ideal target for malware as it is the most widely used mobile operating system globally [72]. However, the field of Adversarial Machine Learning (AML) has repeatedly demonstrated the brittleness of ML-based systems under targeted modifications [8, 9, 14, 33]. Although well established, this vulnerability is often underpinned with strong assumptions, such as access to confidence scores; therefore, the question most relevant for risk assessment is not whether these detectors can be evaded, but how general and efficient an attack can be under realistic constraints.

Most evasion research operates in the feature space, directly modifying the input that is fed into ML systems [9, 14, 33]. Although sufficient to evade systems such as image detection, these approaches are not applicable to crafting evasive malware due to the inverse mapping problem: a change to the feature vector does not necessarily correspond to any realizable and function-preserving change in the application [11, 19, 35, 59, 61, 65, 69]. Alternatively, problem-space attacks avoid this problem by modifying the application directly while enforcing syntactical and semantic constraints; therefore, every adversarial example is a valid program by construction.

Despite the shift towards more realistic problem-space evasion, the Android evasion literature is still fragmented with three major limitations. First, existing works optimize individual samples against a single target classifier and feature space, relying on confidence scores and search heuristics or greedy selection [11, 35, 59]. As a result, these attacks optimize on a per-sample basis without retaining knowledge from past evasions, capping their query efficiency and limiting their transferability to new targets. Second, existing literature often conflates two separate components of problem-space attacks: (i) the capability set, which defines modifications available to the attacker that can be made while preserving problem-space constraints; and, (ii) the strategy, which selects from the capability set in order to modify a sample to evade a target. Therefore, when both components are proposed together and not evaluated in isolation, it is unclear if the new attack has discovered a better strategy for evasion, or if a potentially suboptimal strategy is being carried by a stronger capability set. This ambiguity is a form of the gain attribution pitfall raised by [50]. Finally, these approaches are evaluated only on a single temporal snapshot, ignoring the impact that temporal drift and targets that employ Active Learning (AL) [67] have on the evasion of malware samples. We therefore lack a comprehensive understanding of how evasion strategies generalize and transfer across classifiers, feature spaces, and time.

To address these limitations, we propose REPLICANT: a unified Deep Reinforcement Learning (DRL) framework that learns problem-space evasion policies. Evasion here is formulated as a sequential decision-making problem (specifically, a Markov Decision Process) where an agent observes the current representation of a modified malware sample and chooses either: (i) to submit the sample to the target; or, (ii) to modify the sample and select which capability to apply. REPLICANT is deliberately agnostic to what the problem-space capabilities are: it learns effective evasion policies given any capability set and a representation that captures how the modifications affect the sample. For Android malware detection, one of the most common capabilities is the harvesting and transplantation of self-contained code fragments from benign applications [11, 19, 35, 59]. Concretely, we instantiate our capability set using gadget transplantation as proposed in [19, 59].

In this work we evaluate REPLICANT under five key settings. First, we establish REPLICANT as a state-of-the-art black-box attack, comparing it to prior attacks [11, 35, 44, 59, 60, 63, 69, 79], in the largest Android malware evasion study to date. Second, we demonstrate the advantage of learned policy-transfer over sample-transfer across all 1,764 surrogate and target combinations. Third, we investigate the defensive utility of the REPLICANT attack through the use of a white-box variant (REPLICANT WB_{WB}) to produce robust targets through Adversarial Training (AT), AT-REPLICANT, comparing it with the white-box attack APG (APG WB_{WB}/AT-APG) [59]. Fourth, we assess how well this robustness from AT withstands an evolving attacker capability set. Lastly, we explore the interplay between AL and AT when evaluating both clean performance and adversarial robustness over time. In summary, we make the following contributions:

• REPLICANT Framework. We propose REPLICANT, a general DRL-based framework that learns problem-space evasion over a capability set as a hierarchical policy, improving Attack Success Rate (ASR) by 20.9%–39.2% compared to state-of-the-art Android attacks.

• Policy Transfer. We demonstrate that a policy trained against a surrogate transfers more effectively than the samples that evade the same surrogate, yielding an 82.0% relative increase in ASR.

• AT & Capability Drift. We show that AT-REPLICANT reduces attacker success below 17% for both REPLICANT WB_{WB} and a APG WB_{WB}, whereas AT-APG leaves the model over five times more vulnerable to REPLICANT WB_{WB}. We also show that the robustness gained from AT diminishes as the attacker capabilities expand from the capability set used by the defender.

• Robustness under Drift. We establish that applying AL directly to AT hardened classifiers recovers drift-induced performance but degrades robustness, whereas our Robust AL (RAL) retains the performance-over-time of AL and the robustness of AT.

• Comprehensive Study. We conduct the largest evaluation of problem-space Android malware evasion to date, comprising 379,680 attack evaluations, isolating the gains of evasion strategies on attacker success.

References (78)