Beating Attackers At Their Own Games: Adversarial Example Detection Using Adversarial Gradient Directions

Yuhang Wu, Sunpreet S. Arora, Yanhong Wu, Hao Yang

Abstract

Deep Neural Networks (DNNs) are vulnerable to adversarial examples—inputs crafted with small perturbations to cause misclassification. This paper proposes a novel detection method based on Adversarial Gradient Directions (AGDs). By analyzing the stability and neighborhood consistency of gradient directions, the method achieves state-of-the-art detection performance (up to 98.6% AUC-ROC) with minimal computational overhead, requiring only a single random transformation.

Introduction

Adversarial attacks exploit the sensitivity of DNNs to specific directions in the input space. Existing defenses typically rely on computationally expensive multiple transformations or complex distribution modeling that struggles with high-dimensional data. This work introduces a middle ground: a discriminative method that is both intuitive and efficient by repurposing the attacker's primary tool—the gradient—as a detection signal.

Methodology

Geometric Intuition of AGDs

The core innovation is the Adversarial Gradient Direction (AGD). For a benign image, the AGD is stable; a small random perturbation does not significantly alter the direction of the gradient toward a target class. In contrast, adversarial images exhibit "brittleness," where even minor noise causes the AGD to shift dramatically. Furthermore, benign images share similar AGDs with their natural neighbors (prototypes) in the same class, a property called neighborhood smoothness that adversarial examples lack.

Geometric intuition of AGDs for clean (left) vs. adversarial (right) examples.

The Detection Algorithm

The detection process involves six primary steps:

  1. Input: Receive a query image ($I^q$).
  2. Perturbation: Apply a single random pixel perturbation to generate $I^p$.
  3. Prototype Selection: Identify the nearest neighbor ($I^n$) from a small reference database of the predicted class.
  4. AGD Computation: Calculate gradients for $I^q, I^p,$ and $I^n$ relative to the top $K$ predicted classes.
  5. Similarity Scoring: Compute angular (cosine) similarity between these vectors, resulting in scores $\alpha$ (query vs. perturbed), $\beta$ (query vs. prototype), and $\gamma$ (perturbed vs. prototype).
  6. Classification: Use a Random Forest classifier trained on these similarity scores to distinguish adversarial from clean inputs.

Experimental Results

Performance Benchmarks

The method was evaluated on CIFAR-10 and ImageNet using various architectures (ResNet, GoogleNet, DenseNet) against diverse attacks (FGSM, CW, PGD, etc.). It achieved an average 97.9% AUC-ROC on CIFAR-10 and 98.6% on ImageNet, consistently outperforming baselines like Feature Squeezing and Mahalanobis distance.

Feature Discriminability

The effectiveness of the detector stems from the clear separation in the distributions of similarity scores between clean and adversarial samples. As shown in the distribution plots, the neighborhood-based scores ($\beta$ and $\gamma$) provide a strong signal for classification.

Distributions of similarity scores $\beta$ and $\gamma$, showing clear separation between clean and adversarial examples.

Discussion and Conclusion

By "beating attackers at their own game," this method leverages the gradient mechanism to create a robust fingerprint of adversarial space. Its efficiency—requiring only one random perturbation—makes it highly practical for real-time applications. While adaptive white-box attacks can reduce detection accuracy, the AGD-based approach remains significantly more robust than previous transformation-based methods. Future research may explore using these signatures to rectify adversarial images back to their correct classes.

Summary updated

BibTeX
@inproceedings{wu2021beating,
  author = {Yuhang Wu and Sunpreet S. Arora and Yanhong Wu and Hao Yang},
  title = {{Beating Attackers At Their Own Games: Adversarial Example Detection Using Adversarial Gradient Directions}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i4.16404},
}
Figure