Fooling machine learning models: a novel out-of-distribution attack through generative adversarial networks

Hailong Hu, Jun PangApplied Intelligence 2025

Introduction

Machine learning models often suffer from a critical vulnerability: they "do not know when they do not know." When presented with out-of-distribution (OOD) data—samples far removed from their training set—these models frequently assign them to known classes with erroneously high confidence. While traditional adversarial attacks focus on "restricted" perturbations (adding imperceptible noise to a valid image), this paper introduces a novel "unrestricted" OOD attack. By leveraging pre-trained Generative Adversarial Networks (GANs), the researchers generate high-quality, natural-looking images that fool victim models into making high-confidence, incorrect classifications.

Methodology: The GAN-based OOD Attack

The proposed framework treats the attack as an optimization problem within the latent space of a GAN. Instead of modifying an existing image, the adversary searches for a latent code $z$ that, when passed through a generator $G$, produces an image $G(z)$ that minimizes the distance to a target class $t$ in the victim model's output space.

Overview of the proposed OOD attack framework using a pretrained GAN to generate samples that fool a victim model.

The attack operates in two primary modes:

  1. White-box Attack: Utilizing full access to the victim model's architecture, the attacker uses Stochastic Gradient Descent (SGD) to iteratively refine the latent code.
  2. Black-box Attack: In scenarios where only model queries are possible, the attacker employs Powell’s conjugate direction method, a gradient-free optimization technique, to navigate the latent space.

A significant advantage of this approach is the use of off-the-shelf, pre-trained GANs (e.g., StyleGAN trained on human faces). This demonstrates that an adversary can weaponize existing high-quality generators against unrelated models without needing to train a custom GAN.

Experimental Setup

The researchers evaluated the attack against models trained on standard datasets like CIFAR-10 and GTSRB-43. The OOD samples were generated using GANs trained on FFHQ (human faces) and iCartoonFace.

Baseline classification accuracy of the victim models on their respective in-distribution datasets.

As shown in the table above, the victim models (WideResNet and DenseNet) achieve high baseline accuracy on their intended tasks, making the subsequent successful OOD attacks even more striking.

Key Results and Insights

The GAN-based OOD attack demonstrated remarkable effectiveness across various settings:

  • High Success Rates: White-box attacks achieved an average Attack Success Rate (ASR) exceeding 97%, often reaching 100%. Even in black-box scenarios, the ASR remained high, ranging from 62% to 97%.
  • Naturalness and Stealth: Unlike noise-based adversarial examples, the generated OOD samples (such as a human face) appear perfectly normal to human observers. This "naturalness" serves as a cloak, making the malicious intent difficult to detect visually.
  • Evasion of State-of-the-Art Defenses: The attack successfully bypassed several OOD detection methods, including ODIN, Outlier Exposure (OE), and ATOM. For instance, the attack maintained a 56% success rate against OE on CIFAR-10, suggesting that current defenses are often over-tuned to specific types of noise rather than sophisticated generative samples.

Conclusion

This research highlights a significant security gap in current machine learning systems. By using GANs to find "pockets" of vulnerability in a model's decision boundary, attackers can generate convincing OOD samples that bypass standard defenses. Future work will focus on improving the query efficiency of black-box attacks and developing more robust defense mechanisms, such as incorporating GAN-generated samples into adversarial training regimes.

Summary updated

BibTeX
@article{hu2025fooling,
  author = {Hailong Hu and Jun Pang},
  title = {{Fooling machine learning models: a novel out-of-distribution attack through generative adversarial networks}},
  journal = {Applied Intelligence},
  year = {2025},
  doi = {10.1007/s10489-024-05974-1},
}
Figure