Bayesian Learned Models Can Detect Adversarial Malware for Free

Bao Gia Doan, Dang Quang Nguyen, Paul Montague, Tamas Abraham, Olivier Y. de Vel, Seyit Camtepe, Salil S. Kanhere, Ehsan Abbasnejad, Damith C. Ranasinghe · DOI

Abstract

Traditional machine learning classifiers for malware detection often suffer from a "glass jaw": susceptibility to adversarial attacks that subtly modify malicious files to appear benign. While adversarial training is the standard defense, it is computationally expensive and often degrades performance on clean samples. This paper explores an alternative approach: leveraging the inherent epistemic uncertainty in Bayesian Neural Networks (BNNs). By quantifying a model's lack of knowledge regarding an input, researchers can identify sophisticated evasion attacks across Android, Windows, and PDF domains. This method provides robustness "for free," maintaining high detection accuracy without the overhead of generating adversarial training samples.

Introduction: The Robustness Trade-off

Machine learning has become the primary line of defense in modern malware detection. However, these models are vulnerable to adversarial attacks where attackers modify malware to retain its malicious functionality (the problem space) while altering its mathematical representation (the feature space) to fool a classifier.

Existing defenses primarily rely on adversarial training, which involves augmenting the training set with adversarial examples. This approach faces three critical hurdles:

  1. Computational Overhead: Generating realistic, functional adversarial malware is resource-intensive and slow.
  2. Performance Degradation: Increasing robustness against attacks often results in a "robustness trade-off," where the model's accuracy on legitimate, non-malicious files decreases.
  3. Discrete Constraints: Unlike images, software binaries are discrete. Gradient-based modifications often break the program's functionality, making it difficult to generate valid training samples.

Instead of attempting to learn every possible adversarial permutation, this research proposes a shift in perspective: using Bayesian inference to detect when a model is operating in an unfamiliar region of the problem space.

Methodology: Quantifying the Unknown

Bayesian Deep Learning differs from standard neural networks by treating weights as probability distributions rather than fixed values. This allows the model to express epistemic uncertainty—a measure of the model's confidence based on the data it has seen during training.

The researchers evaluated several techniques to approximate these complex distributions:

  • Monte Carlo (MC) Dropout: Randomly disabling neurons during inference to observe prediction fluctuations.
  • Variational Inference (VI): Using simpler Gaussian distributions to approximate the posterior distribution.
  • Stein Variational Gradient Descent (SVGD): A particle-based method that uses a "repulsive force" to ensure a diverse set of model explanations, preventing the particles from collapsing into a single solution.
  • Deep Ensembles: Training multiple deterministic models with different random initializations.

To quantify uncertainty, the study utilized Mutual Information (MI) and Predictive Entropy (PE). MI is particularly effective as it isolates epistemic uncertainty (knowledge gaps) from aleatoric uncertainty (inherent noise in the data).

Experimental Setup and Datasets

The approach was validated across three distinct malware domains using established benchmarks:

  • Android: The DREBIN dataset (~152,000 apps) was tested against the state-of-the-art SP’20 problem-space attack.
  • Windows: The EMBER dataset was evaluated using functional adversarial samples from the DEFCON machine learning static evasion competition.
  • PDF: The Contagio dataset (~29,000 files) was tested against unbounded gradient-based attacks.
  • Concept Drift: To test temporal resilience, a set of 1,000 Android apps from AndroZoo (2022-2023) was used to observe how the model handles malware that has evolved beyond the original training window.

Key Insights

Adversaries are Forced into the "Unknown"

Because malware must remain functional, attackers are constrained in how they can modify code. To successfully fool a detector, they almost inevitably push the sample into "low-confidence" regions of the model's feature space—areas where the model has little to no training data. Bayesian models naturally flag these samples as high-uncertainty events.

The Power of Diversity

Among the methods tested, SVGD consistently emerged as the top performer. Its ability to maintain a diverse set of "internal models" means that if an adversarial sample is presented, the different particles are likely to disagree, creating a strong signal of high epistemic uncertainty.

Robustness "For Free"

Because this detection happens at the inference stage using uncertainty metrics, it does not require retraining the model on adversarial examples. This preserves the model's high accuracy on clean data while providing a reliable mechanism to flag potential attacks.

Detecting Concept Drift

Beyond adversarial defense, high uncertainty proved to be a reliable indicator of concept drift. When malware authors develop entirely new techniques years after a model's training, the Bayesian model identifies these as "unknown" samples, alerting human analysts that the system requires an update.

Results and Performance

The SVGD-based model demonstrated remarkable resilience:

  • Android (SP’20 Attack): Achieved an AUC of over 96%, significantly outperforming standard deterministic models.
  • Feature-Space Resilience: Against PGD L1 attacks, where traditional models often see accuracy drop to near zero, the SVGD model maintained an AUC of ~97%.
  • Cross-Domain Consistency: Similar success was observed in Windows PE and PDF domains, suggesting that epistemic uncertainty is a universal indicator of adversarial manipulation in structured data.

Conclusion and Future Work

While Bayesian approximations are currently "coarse" due to the mathematical complexity of deep networks, they offer a powerful, computationally efficient alternative to traditional adversarial training. Future research will focus on refining posterior approximations and calibrating uncertainty scores to minimize false positives in production environments. By focusing on what the model does not know, security researchers can build systems that are not only more robust against today's attacks but are also prepared for the evolved threats of tomorrow.

Summary updated

BibTeX
@inproceedings{doan2024bayesian,
  author = {Bao Gia Doan and Dang Quang Nguyen and Paul Montague and Tamas Abraham and Olivier Y. de Vel and Seyit Camtepe and Salil S. Kanhere and Ehsan Abbasnejad and Damith C. Ranasinghe},
  title = {{Bayesian Learned Models Can Detect Adversarial Malware for Free}},
  booktitle = {ESORICS},
  year = {2024},
  doi = {10.1007/978-3-031-70879-4\_3},
}
Figure