Reinforcement learning has proven useful in security domains where supervised learning fails: agents that learn to mutate malware can evade static detectors in a median of one mutation, and detectors hardened against learned policies resist later attackers far better than detectors hardened against greedy attacks REPLICANT: Learning Policies for Evading and Hardening Malware Detectors. But this usefulness comes at a double price. First, the RL loop reintroduces, at every single step, the very bottleneck that representation learning was supposed to remove: the environment must re-extract a hand-crafted feature vector from each mutated binary before the agent can observe the result. Anderson et al.'s evasion agent observes a 2,350-dimensional manually parsed feature vector and pays a feature-extraction cost at every step of every episode Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning, and REPLICANT's hierarchical PPO likewise operates entirely on pre-extracted feature spaces (Drebin, APIGraph, RAMDA) while acknowledging that training its policy is substantially more expensive than greedy optimization. Second, the agent inherits the structural costs of on-policy RL itself: the sequential, non-batchable interaction with an external environment, and the multi-model memory tax of hosting policy, value, reference, and reward networks concurrently P-TA: Using Proximal Policy Optimization to Enhance Tabular Data Augmentation via Large Language Models.
The proposal here is that these two costs can be removed together, with one design. We train an RL evasion (and hardening) agent whose state is the output of a frozen raw-byte convolutional encoder, and whose environment is a small learned surrogate of the target detector that runs entirely on the GPU. Each RL step becomes a batched forward pass instead of a CPU-side feature-engineering pipeline plus an oracle query, and all four PPO components share the same frozen encoder so only small heads are trained. The result should be an adversarial RL pipeline whose per-step cost looks like supervised learning while keeping the transfer and hardening benefits that motivated RL in the first place.
Core Claim
The claim is that RL for binary-domain adversarial problems does not need to be expensive, because its two cost drivers are removable artifacts of design choices, not intrinsic properties. The generation-in-the-loop bottleneck identified for text policies Is Reinforcement Learning (Not) for Natural Language Processing: Benchmarks, Baselines, and Building Blocks for Natural Language Policy Optimization manifests in this domain as "feature-extraction-and-oracle-query in the loop," and both parts can be amortized. Concretely, the agent observes only $z = g_\phi(x)$, where $g_\phi$ is a raw-byte CNN encoder of the binary $x$, trained once by supervised detection in the style of Krcál et al. Deep Convolutional Malware Classifiers Can Learn from Raw Executables and Labels Only and then frozen. The environment step is replaced by a learned surrogate
$$\hat{r}_t, \hat{z}_{t+1} = f_\theta(z_t, a_t),$$
where $a_t$ is a discrete, functionality-preserving mutation (gadget transplant, section rename, slack-space append, import addition — the action families used by Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning and REPLICANT: Learning Policies for Evading and Hardening Malware Detectors), $\hat{r}_t$ is the predicted detector response, and $\hat{z}_{t+1}$ the predicted embedding after the mutation. Real environment calls (apply the mutation, run the true detector) are made on a scheduled, decaying probability $p$, both to train and to recalibrate $f_\theta$; between calls, rollouts run at GPU batch speed. Crucially, because the action set consists of mutations that are valid in problem space by construction, the surrogate never has to model executability — only detector response — which sidesteps the feature-space/problem-space validity gap that PAD: Towards Principled Adversarial Malware Detection Against Evasion Attacks showed breaks naïve feature-space optimization.
Two further design points close the memory story. Because $g_\phi$ is frozen, the policy, value, reward, and reference components of PPO are all lightweight heads reading the same cached embeddings, so peak memory is one encoder plus small heads rather than four backbones — directly attacking the multi-model tax documented for PPO-style training P-TA: Using Proximal Policy Optimization to Enhance Tabular Data Augmentation via Large Language Models. And because the encoder consumes raw bytes, no hand-crafted feature pipeline exists anywhere in the system; the manual-feature bottleneck is removed from the state, the environment, and the target description simultaneously.
Research Program
Three things get built and measured. The first is the encoder-plus-heads architecture: a strided raw-byte CNN following the design lessons of Krcál et al. (power-of-two strides matching compiler boundaries, global average pooling for false-positive control), trained once as a detector on the target training set, then frozen and reused as the state representation for the policy, value, and reference heads. The second is the latent detector surrogate $f_\theta$: a small network trained on transitions collected by actually running the mutation toolchain and real target detectors offline — a one-time supervised expense, exactly the pattern that makes teacher-forced training cheap Teacher Forcing Recovers Reward Functions for Text Generation — and then refreshed during training with scheduled real queries whose rate we treat as a tunable budget rather than a fixed cost. The third is an honest accounting layer: because a surrogate can drift from reality, we track prediction error against held-out real queries, and the headline evaluation always ends with end-to-end episodes run against the real environment (mutation, re-encoding, true detector) so that reported attack success reflects real detector behavior, not surrogate wishful thinking.
The scientific questions are, first, whether policy quality survives the surrogate (does an agent trained mostly in the latent world match an agent trained fully in the real one?), second, how the wall-clock, GPU-hour, and peak-memory costs scale with the real-query rate $p$, and third, whether the learned representation makes the policy more transferable across target detectors than policies built on manual feature spaces — REPLICANT found policy transfer across feature spaces gave an 82% relative improvement over sample transfer when the target architecture was unknown, and we want to know whether a representation-based state does even better, or at least as well, on PE binaries where REPLICANT never operated.
Proposed Experiments
The primary testbed is the gym-malware collections with binaries and mutation toolchain: VirusShare (50,000 samples), Ransomware (2,600), Virut (1,600), and BrowseFox (4,100), against a gradient-boosted target detector reported at 0.993 ROC-AUC by Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning. A second target detector is a raw-byte CNN trained à la Krcál et al. on the same corpora, and a third is a LightGBM on EMBER-style 2,351-dimensional features, following the recipe and reported baseline of 0.999 ROC-AUC and 93% detection at 0.1% false-positive rate in EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models; we note that EMBER itself distributes feature vectors rather than binaries, so the feature-space target is used for transfer evaluation on feature-extractable subsets. File sizes are capped at 512KB and packed executables pre-filtered, matching the restrictions Krcál et al. found necessary. Metrics are attack success rate, real detector queries per successful sample, wall-clock and GPU-hours to convergence, and peak VRAM — the last two being the metrics no prior RL security paper in this literature reports, and the ones this proposal is fundamentally about. For hardening, we retrain target detectors on policy-generated adversarial samples and measure the success rate of held-out attackers, including greedy ones; the reference point is Anderson et al.'s finding that retraining on evasive ransomware reduced subsequent attack effectiveness by 33%.
Baselines
The naive reference point is the unhardened static detector: LightGBM on EMBER features at its reported 0.999 ROC-AUC and 93% detection at 0.1% FPR EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models, and the GBDT at 0.993 ROC-AUC in the gym-malware setting Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning. These set the bar any adversarial method must move. The strongest existing competitor is a faithful reproduction of the Anderson-style ACER agent: same mutation set, same target detectors, same observation of the 2,350-dimensional hand-crafted feature vector, run with the same total real-detector query budget and the same tuning sweep and hardware as our agent. No reported result exists on Lacuna for a raw-byte RL evasion agent on PE, so the ACER reproduction is the number to beat on its own ground; we beat it by matching or exceeding its attack success rate on all four collections while cutting wall-clock and real queries substantially, and by surpassing its 33% post-retraining attack reduction. REPLICANT's hierarchical PPO is the strongest published adversarial policy method REPLICANT: Learning Policies for Evading and Hardening Malware Detectors, with 78.8% mean attack success across 1,764 surrogate/target settings, 7.4 queries per sample in hard settings versus 9.3+ for greedy baselines, and hardening that pushed attacker success below 17% versus 62.4% for prior-art hardening; since REPLICANT operates on Android feature spaces, we compare against it on the dimensions it shares (query efficiency, hardening strength, transfer), and we additionally port its hierarchical query-or-modify structure onto our latent state as the strongest possible ablation of our contribution. That ablation — identical RL machinery, identical budget, with and without the frozen encoder and latent surrogate — is what isolates the proposal's key ingredients: real environment every step versus surrogate with scheduled queries (cost), and frozen shared encoder versus per-head encoders (memory).
Why not just…?
Why not just use supervised learning on hand-crafted features? For detection alone, this is a genuine threat: LightGBM at 0.999 ROC-AUC EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models is hard to beat. But the problem this proposal targets is adversarial and drifting, where static supervised models demonstrably collapse: the J48 classifier decayed to a 53% false-positive rate on modern data in the EMBER study, and a 0.993-AUC GBDT was evaded by an RL agent needing a median of one mutation Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning. Meanwhile DRMD showed a bandit-style policy beating static classifiers in 75% of drift scenarios with an average Area Under Time improvement of 8.66 to 10.90 DRMD: Deep Reinforcement Learning for Malware Detection under Concept Drift. Supervised learning is the cheap solution to the wrong problem; the point of this proposal is to make the right problem affordable.
Why not just train a supervised raw-byte CNN and skip RL entirely? Krcál et al. showed this works well for static detection Deep Convolutional Malware Classifiers Can Learn from Raw Executables and Labels Only, and we in fact reuse their encoder as our frozen backbone. But supervised detectors do not generate adversarial training data or hardened models, and the evidence says they are brittle: MalConv-style models can be evaded by appending under 1% of optimized bytes as overlay padding Adversarial Malware Binaries: Evading Deep Learning for Malware Detection in Executables, and PAD needed an expensive inner attack loop at every training step to hold 83.45% accuracy under 27 attacks PAD: Towards Principled Adversarial Malware Detection Against Evasion Attacks. Our proposal is exactly the component that supervised detection lacks — a cheap generator of valid adversarial samples — and its hardening experiments will directly test whether policy-generated samples beat PAD-style stepwise-attack training at matched compute.
Why not just use greedy or genetic search instead of RL? For evading one sample against one detector, greedy is probably enough and cheaper, and we will run it as a baseline; Anderson et al.'s random-mutation and REPLICANT's greedy results (9.3+ queries per sample, poor transfer, 62.4% residual attack success after greedy hardening versus below 17% after policy hardening) REPLICANT: Learning Policies for Evading and Hardening Malware Detectors show where it falls short: greedy attacks do not transfer and do not produce diverse hardening data. If our experiments show greedy matching our agent's transfer and hardening at lower cost, that would falsify the proposal's premise, and we will report it if so.
Why not just use the existing RL frameworks (ACER or REPLICANT) and throw more compute at them? This is the closest objection, and the answer is the proposal itself: those frameworks pay a per-step feature-extraction and oracle cost that grows with every episode, and they cannot operate where no manual feature space exists — REPLICANT is confined to Android feature vectors, and Anderson's agent to a 2,350-dimensional parse. The decisive experiment is the matched-budget head-to-head: same mutations, same targets, same query and tuning budget. If the latent-surrogate agent matches their attack success at a small fraction of wall-clock and memory, and additionally works against raw-byte CNN targets where their feature pipelines have no observation to compute, the difference is not more compute but a different cost structure.
Decisive Checks
The proposal stands or falls on three numbers. The surrogate-fidelity check: predicted versus actual detector scores on held-out real queries, with training halted or $p$ raised if error grows — a surrogate that lies invalidates everything downstream, which is why every reported success rate is measured in fully real final episodes. The cost-scaling check: wall-clock, GPU-hours, and peak VRAM as a function of the real-query rate $p$, across $p=1$ (reproducing prior work's cost profile) down to $p=0.01$; the claim requires attack success to stay flat while cost falls steeply. And the transfer-and-hardening check: policy transfer to unseen target architectures at or above REPLICANT's reported 82% relative advantage over sample transfer, and post-retraining attack reduction beyond the 33% Anderson et al. observed. If the cost curve is flat or the success curve drops with $p$, the honest conclusion would be that the environment's real signal is irreplaceable — and that, too, would be a finding worth reporting, since it would locate the true cost floor of adversarial RL in this domain.
References
- REPLICANT: Learning Policies for Evading and Hardening Malware Detectors
- Learning to Evade Static PE Machine Learning Malware Models via Reinforcement Learning
- P-TA: Using Proximal Policy Optimization to Enhance Tabular Data Augmentation via Large Language Models
- Is Reinforcement Learning (Not) for Natural Language Processing: Benchmarks, Baselines, and Building Blocks for Natural Language Policy Optimization
- Deep Convolutional Malware Classifiers Can Learn from Raw Executables and Labels Only
- PAD: Towards Principled Adversarial Malware Detection Against Evasion Attacks
- Teacher Forcing Recovers Reward Functions for Text Generation
- EMBER: An Open Dataset for Training Static PE Malware Machine Learning Models
- DRMD: Deep Reinforcement Learning for Malware Detection Under Concept Drift
- Adversarial Malware Binaries: Evading Deep Learning for Malware Detection in Executables