Adversarial Malware Binaries: Evading Deep Learning for Malware Detection in Executables

Bojan Kolosnjaji, Ambra Demontis, Battista Biggio, Davide Maiorca, Giorgio Giacinto, Claudia Eckert, Fabio Roli

Introduction

Traditional malware detection has long relied on signatures or manually engineered features like API call sequences. Recently, the field has shifted toward end-to-end deep learning models, such as MalConv, which process raw bytes of executable files directly using Convolutional Neural Networks (CNNs). While these models can learn complex relationships within binaries, they are susceptible to adversarial examples—small, intentional perturbations designed to cause misclassification. In the malware domain, such perturbations must be carefully applied to avoid breaking the program's functionality. This research investigates a gradient-based attack that appends a small number of "padding" bytes to evade detection while preserving the malware's original behavior.

Methodology: Attacking MalConv

The primary target of this study is MalConv, a CNN architecture that maps input bytes (0-255) into an 8-dimensional continuous embedding space before processing them through convolutional and pooling layers.

The MalConv architecture processes raw byte sequences through an embedding layer followed by parallel convolutional paths and temporal max pooling.

The Gradient-Based Attack

To bypass the detector, the authors formulated a constrained optimization problem to minimize the model's malware confidence score by modifying a limited number of bytes ($q$).

  1. Differentiability: Since raw bytes are discrete, the input space is non-differentiable. To overcome this, the authors computed the gradient of the loss function with respect to the continuous values in the embedding space.
  2. Byte Selection: A heuristic was used to find the actual byte value whose embedding was closest to the direction of the calculated gradient.
  3. Functionality Preservation: The attack only modifies "padding bytes" appended to the end of the file (the overlay). Because Windows ignores data appended after the declared sections of a Portable Executable (PE) file, these changes do not interfere with the program's execution.

Experimental Setup

The study utilized a dataset of 13,195 Windows PE samples, consisting of 9,195 malware samples (from VirusShare, Citadel, and APT1) and 4,000 benign samples. Files were capped at 1MB to match MalConv's input constraints. The attack was iterative, with a maximum of 20 passes to find an evasive sequence.

Key Results and Insights

The gradient-based attack proved highly effective compared to simple baselines. While appending random bytes had a negligible impact on detection, the structured adversarial patterns generated by the gradient-based method significantly increased evasion rates.

Evasion rate comparison between gradient-based optimization and random byte addition across different numbers of added bytes.

As shown in the figure above, injecting just 10,000 bytes—less than 1% of the total file size—allowed malware to evade detection approximately 60% of the time. In contrast, random byte injection only achieved an evasion rate of 15-20% under identical conditions.

Insights into Model Vulnerability

  • Structured Camouflage: Successful attacks identified specific "benign-looking" signatures, consistently choosing a small subset of byte values to create a "camouflage" effect.
  • Location Sensitivity: MalConv was found to be more sensitive to bytes at the beginning of a file. This suggests that modifications to "slack space" or unused headers within the file might be even more effective, though harder to implement safely.

Conclusion and Future Work

This research highlights a significant vulnerability in byte-based deep learning models for malware detection. While appending bytes at the end of a file is a safe way to preserve functionality, it is also where the model is least sensitive. Future work will explore fine-grained modifications within the file structure, such as the .data or .rdata sections, and validate these methods on larger, more diverse datasets. Ultimately, the authors suggest that robust training—including adversarial examples in the training loop—is essential for deep learning models to be viable in real-world security applications.

Summary updated

BibTeX
@inproceedings{kolosnjaji2018adversarial,
  author = {Bojan Kolosnjaji and Ambra Demontis and Battista Biggio and Davide Maiorca and Giorgio Giacinto and Claudia Eckert and Fabio Roli},
  title = {{Adversarial Malware Binaries: Evading Deep Learning for Malware Detection in Executables}},
  booktitle = {EUSIPCO},
  year = {2018},
  doi = {10.23919/eusipco.2018.8553214},
}
Figure