← Lab /Security & privacy

Structured pruning keeps CodeLLM's adversarial code mutation ability

SecRL-Prune preserves execution correctness and code diversity of CodeLLMs after 10-30% structured pruning, enabling malware evasion

Security & privacy arXiv 4 Jun 2026 Method Prototype evidence

Published as “SecRL-Prune: Structured Reinforcement Learning-Based Pruning of CodeLLMs for Preserving Adversarial Code Mutation”

Why it matters

Compressed CodeLLMs can be deployed on low-resource devices to generate malware variants that evade static signature detectors.

Summary

SecRL-Prune preserves code generation and mutation capabilities of CodeLLMs even after 10-30% structured pruning, achieving up to 85% of the teacher's pass@k and substantially reducing malware detection rates (up to 88% reduction) on real samples. The evidence is strong, with consistent improvements over the PruneNet baseline across three 7B models and a clear case-study showing evasion of over 60 VirusTotal engines.

What they found 5

  1. SecRL-Prune retains 80-85% of teacher pass@k at 10% compression, outperforming PruneNet's 45-72%

    “At 10% compression, SecRL-Prune retains roughly 80-85% of the teacher’s average pass@k, compared to 45-72% for PruneNet.”

  2. At 30% compression SecRL-Prune doubles preserved correctness on Qwen2.5-Coder-7B-Instruct (63.7% vs 35.7%)

    “at 30% compression, SecRL-Prune roughly doubles PruneNet’s preserved correctness on Qwen2.5-Coder-7B-Instruct (63.7% vs. 35.7%)”

  3. Var@10 slightly improves for Qwen2.5-Coder-7B-Instruct after light pruning

    “var@10 increases from 34.71% to 35.72%”

  4. Mutations from 20%-pruned models cut detection counts from 28/63 to 12/63 (57% reduction) and 9/63 (68% reduction)

    “detections drop from 28/63 to 12/63 (mutated using pruned CodeLlama) and 9/63 (mutated using pruned Qwen)-a 57-68% reduction in detection rate”

  5. JavaScript sample detections fall from 9/62 to 1/62, an 88% reduction

    “detections plummet from 9/62 to just 1/62 for both mutators-an 88% reduction.”

Caveats 3

  • var@k must be interpreted alongside pass@k: since var@k is computed only over solved problems, a model with low pass@k can still exhibit relatively high var@k on the few tasks it solves.
  • Even at 30% compression-where absolute pass@1 drops substantially-the pruned models still solve a non-trivial fraction of HumanEval tasks
  • the reward is defined over a calibration distribution and truncated Top-P support, which may under-emphasize rare or long-tail behaviors; var@k captures diversity only among correct outputs; and we prune only FFN channels while leaving attention untouched.

What’s new here 4

  • RL-based structured pruning that optimizes a KL-divergence reward to match teacher behavior
  • Caching of teacher top-P predictions to train pruning policies with only the student model in memory, cutting peak GPU usage by >50%
  • Focused evaluation of code mutation preservation (var@k) rather than just correctness
  • Demonstration that pruned models can materially evade real-world malware detectors