How Do Diffusion Models Improve Adversarial Robustness?

Liu Yuezhang, Xue-Xin WeiarXiv 2025 · DOI

Abstract

Adversarial purification using diffusion models has emerged as a potent defense against adversarial attacks. However, the underlying mechanisms of this success remain poorly understood. This paper deconstructs the purification process, challenging the prevailing "denoising" intuition. We demonstrate that diffusion models do not restore images to their original state; instead, they provide robustness through a combination of gradient masking via internal stochasticity and a deterministic "compression effect" that maps perturbed inputs toward stable anchor points.

Introduction

Deep neural networks are notoriously vulnerable to adversarial perturbations—small, imperceptible changes to input data that cause incorrect classifications. Adversarial purification, exemplified by frameworks like DiffPure, attempts to defend models by passing inputs through a generative diffusion process before classification. While effective, the reason for this effectiveness has been debated: is it true reconstruction of the clean image, or merely a byproduct of the diffusion model's internal noise?

Methodology

The authors employ several analytical techniques to investigate the purification mechanism:

  1. Distance Tracking: Measuring $\ell_p$ distances between clean, adversarial, and purified images across diffusion timesteps.
  2. Variance Decomposition: Calculating the Signal-to-Noise Ratio (SNR) by treating adversarial perturbations as "signal" and internal diffusion randomness as "noise."
  3. Fixed-Randomness Evaluation: Evaluating robustness while holding random seeds constant to eliminate gradient masking effects.
  4. Jacobian Analysis: Using first-order Taylor expansions to quantify the "compression rate" of the purification function.

Experiments were conducted on CIFAR-10 and ImageNet using standard pre-trained classifiers from the RobustBench library.

The "Denoising" Myth vs. Compression

A common assumption is that diffusion models improve robustness by "denoising" an adversarial image back toward the original clean image $x_0$. However, empirical tracking of $\ell_2$ distances reveals a different reality.

Diffusion models do not "denoise" back to the original image; they compress the input space toward an anchor point.

As shown in Figure 3c, the distance between the purified image and the clean original actually increases during the initial stages of diffusion and remains significantly higher than the initial adversarial perturbation distance. Instead of returning to $x_0$, the model maps the input neighborhood toward a new "anchor point" $f(x_0)$. This "compression effect" (illustrated in Figure 3b) reduces the effective volume of the adversarial space, making it harder for perturbations to cross classification boundaries.

The Role of Stochasticity

A significant portion of reported robustness in diffusion-based defenses is attributable to stochasticity. The internal noise of the diffusion process acts as a form of gradient masking, preventing attackers from finding stable directions for optimization.

Histogram of distances to centroids under different conditions, highlighting the dominance of internal noise over input variability.

The SNR analysis reveals that internal randomness is approximately 170 times stronger than the signal from input perturbations. When this randomness is fixed (Figure 6, blue vs. green/orange), the perceived robustness of CIFAR-10 models drops precipitously from ~70% to ~24%. This confirms that while compression provides a deterministic baseline of robustness, stochasticity provides a "false shield" that can be bypassed by more sophisticated attacks like BPDA.

Key Results and Discussion

  • Compression-Robustness Law: The authors identified a sigmoid relationship between the compression rate (derived from the Jacobian spectrum) and adversarial accuracy. This allows for predicting robustness without exhaustive testing.
  • Jacobian Spectrum: Over 90% of the singular values in the purification Jacobian are below 0.25, indicating aggressive dimensionality reduction and neighborhood shrinkage.
  • Metric Reliability: The compression rate was found to be a more reliable predictor of robustness than standard generative metrics like FID.

Conclusion

This work clarifies that diffusion-based purification does not work by "cleaning" images in the traditional sense. Instead, it relies on a deterministic compression of the input space and a stochastic masking of gradients. These findings suggest that future defense research should focus on maximizing the compression effect while ensuring that robustness is not merely an artifact of internal noise.

Summary updated

BibTeX
@misc{yuezhang2025how,
  author = {Liu Yuezhang and Xue-Xin Wei},
  title = {{How Do Diffusion Models Improve Adversarial Robustness?}},
  year = {2025},
  eprint = {2505.22839},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.22839},
}
Figure