Towards Understanding the Robustness of Diffusion-Based Purification: A Stochastic Perspective

## Abstract

Abstract Diffusion-Based Purification (DBP) has emerged as an effective defense mechanism against adversarial attacks. The efficacy of DBP has been attributed to the forward diffusion process, which narrows the distribution gap between clean and adversarial images through the addition of Gaussian noise. Although this explanation has some theoretical support, the significance of its contribution to robustness remains unclear. In this paper, we argue that the inherent stochasticity in the DBP process is the primary driver of its robustness. To explore this, we introduce a novel Deterministic White-Box (DW-box) evaluation protocol to assess robustness in the absence of stochasticity and to analyze the attack trajectories and loss landscapes. Our findings suggest that DBP models primarily leverage stochasticity to evade effective attack directions, and their ability to purify adversarial perturbations can be weak. To further enhance the robustness of DBP models, we introduce Adversarial Denoising Diffusion Training (ADDT), which incorporates classifier-guided adversarial perturbations into diffusion training, thereby strengthening the DBP models’ ability to purify adversarial perturbations. Additionally, we propose Rank-Based Gaussian Mapping (RBGM) to make perturbations more compatible with diffusion models. Experimental results validate the effectiveness of ADDT. In conclusion, our study suggests that future research on DBP can benefit from the perspective of decoupling the stochasticity-based and purification-based robustness.

## 1 Introduction

Figure: Figure 1: Comparison of attack trajectories under different evaluation settings. The attack trajectory in the standard White-box setting deviates significantly from the DW-box trajectory and shows lower effectiveness.
Refer to caption: x1.png

Deep learning has achieved remarkable success in various domains, including computer vision (He et al., ), natural language processing (OpenAI, ), and speech recognition (Radford et al., ). However, in this flourishing landscape, the persistent specter of adversarial attacks casts a shadow over the reliability of these neural models. Adversarial attacks for a vision model involve injecting imperceptible perturbations into input images to trick models into producing false outputs with high confidence (Goodfellow et al., ; Szegedy et al., ). This inspires a large amount of research on adversarial defense (Zhang et al., ; Samangouei et al., ; Shafahi et al., ; Wang et al., ).

Diffusion-based purification (DBP) (Nie et al., ) has recently gained recognition as a powerful defense mechanism against a range of adversarial attacks. Existing literature suggests that the robustness provided by DBP is primarily due to the forward diffusion process that narrows the distribution gap between clean and adversarial images through the application of Gaussian noise (Nie et al., ; Wang et al., ). However, although the reduction of the distribution gap is theoretically proven, its contribution to DBP robustness has not been sufficiently validated by empirical studies. Meanwhile, it is observed that the stochasticity of DBP may also contribute to the robustness (Nie et al., ).

In light of this, we introduce an alternative perspective that highlights the role of stochasticity throughout the DBP process as a key contributor to its robustness, challenging the traditional focus on the forward diffusion process. To evaluate the impact of stochasticity, we employ a Deterministic White-box (DW-box) attack setting where the attacker has complete knowledge of both the model parameters and the stochastic elements. Our findings reveal that DBP models significantly lose their robustness when the process is entirely deterministic to the attacker, thereby emphasizing the critical importance of stochasticity. Further investigations into attack trajectories and the loss landscape demonstrate that DBP models do not counter adversarial perturbations by a flat loss landscape as adversarial training (AT) (Madry et al., ); instead, they rely on stochasticity to circumvent the most effective attack direction, as depicted in Figure 1.

Building on our new perspective regarding DBP robustness, we hypothesize that it can be further enhanced by improving the capability of the diffusion model to purify adversarial perturbations.
To test this hypothesis, we propose Adversarial Denoising Diffusion Training (ADDT) for DBP models. This method follows an iterative two-step process: first, the Classifier-Guided Perturbation Optimization (CGPO) step generates adversarial perturbations; then, the diffusion model training step updates the parameters of the diffusion model using these perturbations. To better integrate these perturbations within the diffusion framework, we introduce Rank-Based Gaussian Mapping (RBGM), which adjusts the adversarial perturbations to more closely resemble Gaussian noise, in alignment with the theory behind diffusion models. Experiments across various diffusion methods, attack settings, and datasets suggest that ADDT can consistently enhance DBP models’ robustness and purification ability.
With further empirical analysis and discussions, we argue that future research on DBP should decouple the robustness based on stochasticity and that achieved by purification, which suggests two orthogonal directions for improving DBP: (1) enhancing its capability to purify adversarial perturbations with efficient training methods, and (2) defending Expectation of Transformation (EoT) attacks by increasing the variance of attack gradients.

Our main contributions are as follows:

- •
We present a novel perspective on DBP robustness, emphasizing the critical role of stochasticity and challenging the conventional purification-based belief that robustness primarily stems from reducing the distribution gap via the forward diffusion process.
- •
We introduce a new Deterministic White-box attack scenario and show that DBP models depend on stochastic attack gradients to avoid the most effective attack directions, demonstrating distinct properties compared to robust models obtained by adversarial training.
- •
Based on the proposed ADDT, we validate that the DBP robustness can be further enhanced by improving the capability of the diffusion model to purify adversarial perturbations.

## 2 Related Work

Adversarial training (AT). First introduced by Madry et al. (), AT seeks to develop a robust classifier by incorporating adversarial examples into the training process. It has nearly become the de facto standard for enhancing the adversarial robustness of neural networks (Gowal et al., ; Rebuffi et al., ; Athalye et al., ). Recent advances in AT harness the generative power of diffusion models to augment training data and prevent AT from overfitting (Gowal et al., ; Wang et al., ). However, the application of AT to DBP methods has not been thoroughly explored.

Adversarial purification.
Adversarial purification utilizes generative models to remove adversarial perturbation from inputs before they are processed by downstream models. Traditionally, generative adversarial networks (GANs) (Samangouei et al., ) or autoregressive models (Song et al., ) are employed as the purifier model. More recently, diffusion models have been introduced for adversarial purification, in a technique termed diffusion-based purification (DBP), and have shown promising results (Song & Ermon, ; Ho et al., ; Song et al., ; Nie et al., ; Wang et al., ; Wu et al., ; Xiao et al., ). The robustness of DBP models is often attributed to the wash-out effect of Gaussian noise introduced during the forward diffusion process. Nie et al. () propose that the forward process results in a reduction of the Kullback-Leibler (KL) divergence between the distributions of clean and adversarial images. Gao et al. () suggest that while the forward diffusion process improves robustness by reducing model invariance, the backward process restores this invariance, thereby undermining robustness. However, these theories explaining the robustness of DBP models lack substantial experimental support.

## 3 Preliminaries

Adversarial training.
Adversarial training aims to build a robust model by including adversarial samples during training (Madry et al., ). This approach can be formulated as a min-max problem, where it first generates adversarial samples (the maximization) and then adjusts the parameters to resist these adversarial samples (the minimization). Formally, this can be represented as:

$$ ${\min}_{\bm{\theta}}\mathbb{E}_{(\bm{x},y)\sim\mathcal{D}}\left[{\max}_{\bm{ \delta}\in B}L(f(\bm{\theta},\bm{x}+\bm{\delta}),y)\right],$ (1) $$

where $L$ is the loss function, $f$ is the classifier, $(\bm{x},y)\sim\mathcal{D}$ denotes sampling training data from distribution $\mathcal{D}$, and $B$ defines the set of permissible perturbation $\bm{\delta}$.

Diffusion models.
Denoising Diffusion Probabilistic Models (DDPM) (Ho et al., ) and Denoising Diffusion Implicit Models (DDIM) (Song et al., ) simulate a gradual transformation in which noise is added to images and then removed to restore the original image. The forward process can be represented as:

$$ $\bm{x}_{t}=\sqrt{\overline{\alpha}_{t}}\bm{x}_{0}+\sqrt{1-\overline{\alpha}_{t }}\bm{\epsilon},\quad\bm{\epsilon}\sim\mathcal{N}(0,\bm{I}),$ (2) $$

where $\bm{x}_{0}$ is the original image and $\bm{x}_{t}$ is the noisy image. $\overline{\alpha}_{t}$ is the cumulative noise level at step $t$ ($1<t\leq T$, where $T$ is the number of diffusion training steps) . The model optimizes the parameters $\bm{\theta}$ by minimizing the distance between the actual and predicted noise:

$$ $\bm{\theta}^{*}={\arg\min}_{\bm{\theta}}\mathbb{E}_{\bm{x}_{0},t,\bm{\epsilon} }\left[\|\bm{\epsilon}-\bm{\epsilon}_{\bm{\theta}}(\sqrt{\overline{\alpha}_{t} }\bm{x}_{0}+\sqrt{1-\overline{\alpha}_{t}}\bm{\epsilon},t)\|_{2}^{2}\right],$ (3) $$

where $\bm{\epsilon}_{\bm{\theta}}$ is the model’s noise prediction, with $\bm{\epsilon}_{\bm{\theta}}$, we can predict $\hat{\bm{x}}_{0}$ in a single step:

$$ $\hat{\bm{x}}_{0}=\left(\bm{x}_{t}-\sqrt{1-\overline{\alpha}_{t}}\bm{\epsilon}_ {\bm{\theta}^{*}}(\bm{x}_{t},t)\right)/{\sqrt{\overline{\alpha}_{t}}},$ (4) $$

where $\hat{\bm{x}}_{0}$ is the recovered image. DDPM typically takes an iterative approach to restore the image, removing a small amount of Gaussian noise at a time:

$$ $\hat{\bm{x}}_{t-1}=\left(\bm{x}_{t}-\frac{\beta_{t}}{\sqrt{1-\overline{\alpha} _{t}}}\bm{\epsilon}_{\bm{\theta}^{*}}(\bm{x}_{t},t)\right)/{\sqrt{1-\beta_{t}} }+\sqrt{\beta_{t}}\bm{\epsilon},$ (5) $$

where $\beta_{t}$ is the noise level at step $t$, $\hat{\bm{x}}_{t-1}$ is the recovered image in step $t-1$, $\bm{\epsilon}$ is sampled from $\mathcal{N}(0,\bm{I})$. DDIM proposes to speed up the denoising process by skipping certain intermediate steps. Recent work suggests that DDPM may also benefit from a similar approach (Nichol & Dhariwal, ). Score SDEs (Song et al., ) give a score function view of DDPM and further lead to the derivations of DDPM++ (VPSDE) and EDM  (Karras et al., ). In this diffusion process, the noise terms $\bm{\epsilon}$ in equations  equation 2 and  equation 5 represent the key stochastic elements that govern the randomness of the process. These stochastic elements will be further elaborated in Section C.1.

Diffusion-based purification (DBP).
DBP uses diffusion models to remove adversarial perturbation from images. Instead of using a complete diffusion process between the clean image and pure Gaussian noise (between $t=0$ and $t=T$), they first diffuse $\bm{x}_{0}$ to a predefined timestep $t=t^{*}(t^{*}<T)$ via Equation 2, and recover the image $\hat{\bm{x}}_{0}$ via the reverse diffusion process in Equation 5.

## 4 Stochasticity-Driven Robustness of DBP

### 4.1 Stochasticity as the Main Factor of DBP Robustness

As discussed in Section 2, previous studies primarily attribute the robustness of DBP to the forward diffusion process, which introduces Gaussian noise to both clean and adversarial images, thereby narrowing the distribution gap between them (Wang et al., ; Nie et al., ). As a result, adversarial perturbation can be “washed out” by Gaussian noise.
However, it is also found that the robustness of DiffPure can be reduced by switching the SDE sampling to ODE, which introduces less randomness, implying the potential contribution of stochasticity to DBP robustness (Nie et al., ).

To assess whether stochasticity has a significant influence on DBP robustness, we implement DDPM and DDIM within the DiffPure framework (Nie et al., ), resulting in DPDDPM and DPDDIM, respectively. Note that DDPM is mathematically equivalent to the DDPM++ (VPSDE) model used in DiffPure but employs a smaller UNet architecture. DDIM, on the other hand, is a mathematical improvement over DDPM that facilitates an ODE-based diffusion process. DPDDPM introduces Gaussian noise in both the forward and reverse processes, making the entire process stochastic. In contrast, DPDDIM introduces Gaussian noise only in the forward process, and the reverse process is deterministic. The clean and robust accuracy of the two models on CIFAR-10 (Madry, ; Krizhevsky et al., ) under white-box PGD+EoT (Athalye et al., ) attack (as detailed in Section 6.1) are presented in Figure 2 (Clean and White). Although DPDDPM achieves higher clean accuracy, it exhibits lower robust accuracy under adaptive white-box attacks, consistent with the observation by Nie et al. ().
However, this comparison is insufficient to reveal the full role of stochasticity in DBP robustness, as the forward processes of both DDPM and DDIM are stochastic.

Figure: Figure 2: DPDDPM and DPDDIM robust accuracy under different attack settings on CIFAR-10. Both models lose most of their robustness only when the attacker knows all stochastic elements (DWBoth-box for DPDDPM and DWFwd-box for DPDDIM).

To isolate the impact of stochasticity, we introduce a new attack scenario called the Deterministic White-Box (DW-box) setting. In this setting, the attacker has full knowledge of not only the model parameters but also the specific sampled values for the stochastic elements used during evaluation, effectively rendering the diffusion process deterministic from the attacker’s perspective. This setting can be realistic if the attacker is aware of the seed or initial random state for the pseudo-random number generation utilized by the model.
Concretely, we define three levels of attacker knowledge for our evaluations:
(1) the conventional White-box setting, where the attacker has access to the model parameters but not the stochastic elements;
(2) DWFwd-box/DWRev-box setting, where the attacker knows the stochastic elements in the forward/reverse process, in addition to the model parameters;
(3) DWBoth-box setting, where the attacker has full knowledge of the model parameters and all the stochastic elements in both the forward and reverse processes. Details of these settings are provided in Section C.2.

We evaluated adversarial robustness on CIFAR-10 using $l_{\infty}$ attacks (see Section 6.1). Traditional theories emphasize forward diffusion as the primary defense mechanism, suggesting that both DPDDPM and DPDDIM should behave similarly under the DWFwd-box setting. However, if stochasticity throughout the diffusion process is crucial, DPDDIM, which becomes deterministic under the DWFwd-box setting, should experience a notable reduction in robustness, similar to DPDDPM in the DWBoth-box setting. As shown in Figure 2, in the DWFwd-box setting, DPDDPM maintains a significant portion of its robustness, whereas DPDDIM loses almost all of its resistance to adversarial attacks. Furthermore, DPDDPM exhibits a substantial drop in robustness only when the attacker has full access to both the forward and reverse stochastic elements, as seen in the DWBoth-box setting. This suggests that stochasticity across both the forward and reverse diffusion processes plays a critical role in maintaining robustness, challenging the conventional focus on forward diffusion alone.

Our findings suggest that DBP models primarily use stochasticity to resist adversarial attacks, rather than mainly depending on forward diffusion to mitigate adversarial perturbations, and it also reveals that DBP itself lacks the ability to effectively purify adversarial perturbations.

### 4.2 Explaining Stochasticity-Driven Robustness

**Table 1: Evaluation of state-of-the-art DBP methods, EoT significantly influences the evaluation accuracy (%) of model robustness.**
|  | DiffPure | GDMP (MSE) | DPDDPM | DPDDIM |
| --- | --- | --- | --- | --- |
| Clean | 89.26 | 91.80 | 85.94 | 88.38 |
| PGD20-EoT1 | 69.04 | 53.13 | 60.25 | 54.59 |
| PGD20-EoT10 | 55.96 | 40.97 | 47.27 | 42.19 |

To elucidate the robustness of DBP models, particularly under EoT evaluations, we analyze the performance of several DBP models—DiffPure, GDMP, DPDDPM, and DPDDIM—under white-box attacks with and without Expectation over Transformation (EoT) iterations (denoted as EoT10 and EoT1, respectively). The results shown in Table 1 suggest that these DBP models remain robust under white-box attacks, with EoT evaluations resulting in moderate reductions in robustness. The detailed discussion on the selection of PGD and EoT steps is provided in Appendix E and Appendix A.

To gain deeper insights, we visualize the attack trajectories using t-SNE, projecting them onto an xy-plane with loss values represented along the z-axis. We compare trajectories for three types of attacks: white-box without EoT (White-box), white-box with EoT (White-box-EoT), and Deterministic White-box (DW-box). As shown in Figure 1, the trajectories exhibit high variance across all settings, reflecting the stochastic nature of DBP models. Specifically, DW-box attacks lead to a significant increase in loss values, whereas white-box attacks, even with EoT, result in only moderate increases. This suggests that stochasticity prevents attackers from finding the optimal attack direction. Specifically, due to the significant variance of the attack gradients, even if the EoT direction is an accurate estimation of the mean gradient direction, it may not be completely consistent with the most effective direction corresponding to the DW-box attack, thus resulting in a decline in attack performance. Additional evidences are provided in Appendix B.

Figure: Figure 3: Visualisation of attack trajectories for White-box-EoT attacks and DW-box attacks on the loss landscape. The loss landscape is steep in the direction of the DW-box attack. The plot is based on the first 128 images of CIFAR-10.
Refer to caption: extracted/5896318/img1.png

Further analysis of the loss landscape, presented in Figure 3, illustrates key differences between White-box-EoT and Deterministic White-box attacks. The trajectory of the White-box-EoT attack diverges from the Deterministic White-box direction, resulting in a flatter loss landscape along the White-box-EoT path. This behavior indicates that White-box-EoT attacks fail to identify the most effective direction due to the stochastic nature of DBP models. In contrast, the Deterministic White-box attack induces a sharp increase in loss, revealing that when stochasticity is removed, the model becomes more vulnerable to adversarial perturbations. These findings differ from models trained using AT, where the whole loss landscape tends to remain flat and resistant across adversarial directions (Shafahi et al., ).

To conclude, it is suggested that instead of possessing a flat loss landscape, DBP models rely on stochasticity to evade the most effective attack directions. Note that while certified defense methods like random smoothing also incorporate stochasticity (Xiao et al., ; Carlini et al., ), their mechanisms and implications differ from those of DBP methods, as discussed in Appendix D.

## 5 Towards Improving the Purification Capability of DBP

Based on the analysis from Section 4, although the stochasticity-driven robustness of DBP does not depend on the flatness of the loss landscape, flattening the landscape can still benefit the DBP robustness given the non-trivial loss increment along the EoT direction. To achieve a flat loss landscape, we need to introduce adversarial samples to the training of the DBP models and minimize the loss on them. From the perspective of adversarial purification, this amounts to improving the diffusion model in its ability to purify adversarial perturbations.

To this end, we propose Adversarial Denoising Diffusion Training (ADDT), which integrates adversarial perturbations into the training of the diffusion model in DBP.
ADDT employs an iterative two-step procedure: (1) Classifier-Guided Perturbation Optimization (CGPO), which generates adversarial perturbations by maximizing the classification error of a pre-trained classifier; (2) Diffusion Model Training, which updates the diffusion model using these perturbations to improve its capability of adversarial purification.

Integrating adversarial perturbations into diffusion training poses a challenge due to the Gaussian noise assumption inherent in diffusion models. To address this, we introduce Rank-Based Gaussian Mapping (RBGM), a technique designed to transform adversarial perturbations into a form consistent with the Gaussian noise assumption. RBGM renders the perturbations more “Gaussian-like”, facilitating their integration into the diffusion training process.

An overview of ADDT is illustrated in Figure 4, with pseudocode in Appendix G.
The following subsections detail the components of ADDT.

### 5.1 Adversarial Denoising Diffusion Training

Figure: Figure 4: Overview of Adversarial Denoising Diffusion Training (ADDT). ADDT alternates between a CGPO step (left grey box) to refine the perturbations with a frozen diffusion model and classifier, and a training step (right grey box) to update the diffusion model with the refined perturbation. Throughout the process, RBGM is used to make the perturbation more “Gaussian-like”.
Refer to caption: x2.png

Classifier-Guided Perturbation Optimization (CGPO) step.
In this step, we aim to refine adversarial perturbations $\bm{\delta}$ in a way that maximizes the classification error of a pre-trained classifier $C$. The process starts by reconstructing a clean image $\hat{\bm{x}}_{0}$ from the perturbed input $\bm{x}^{\prime}_{t}$ using the diffusion model $\bm{P}$. $\bm{P}(\bm{\theta},\bm{x}^{\prime}_{t},t)$ denotes a one-step diffusion process, which takes the noisy input $\bm{x}^{\prime}_{t}$ and time step $t$ and reconstructs the image $\hat{\bm{x}}_{0}$, following the formulation in Equation 4. The classifier $C$ is then applied to this reconstructed image $\hat{\bm{x}}_{0}$ to predict a label. To maximize the prediction error compared to the true label $y$, the optimization objective for refining $\bm{\delta}$ can be defined as:

$$ $\bm{\delta}^{*}=\arg\max_{\bm{\delta}}\mathbb{E}_{\bm{x}_{0},t,\bm{\epsilon}} \left[L\left(C\left(\bm{P}\left(\bm{\theta},\bm{x}^{\prime}_{t}(\bm{x}_{0},\bm {\epsilon},\bm{\epsilon}_{\bm{\delta}}(\bm{\delta})),t\right)\right),y\right) \right],$ (6) $$

where $L(\cdot,y)$ denotes the loss function used to measure the discrepancy between the classifier’s predicted label and the true label $y$. During the optimization, since RBGM is non-differentiable, we accumulate the gradient $\bm{\epsilon}_{\bm{\delta}}(\bm{\delta})$ to $\bm{\delta}$. Notably, the classifier in this process serves purely for semantic guidance and does not have to be consistent with the protected model. Further discussions on cross-classifier performance are provided in Table 5.

Diffusion Model Training step.
The goal of this step is to update the diffusion model parameters to accurately recover the original image $\bm{x}_{0}$ from a perturbed version $\bm{x}^{\prime}_{t}$. As depicted on the right side of Figure 4, The model is optimized to subtract both the Gaussian noise and the RBGM-mapped adversarial perturbations, effectively denoising the input. The optimization objective is defined as:

$$ $\bm{\theta}^{*}=\arg\min_{\bm{\theta}}\mathbb{E}_{\bm{x}_{0},t,\bm{\epsilon}} \left[\frac{\sqrt{\overline{\alpha}_{t}}}{\sqrt{1-\overline{\alpha}_{t}}}\left \|\bm{x}_{0}-\bm{P}(\bm{\theta},\bm{x}^{\prime}_{t},t)\right\|_{2}^{2}\right],$ (7) $$

where the expectation is taken over the distribution of original images $\bm{x}_{0}\sim\mathcal{D}$, time steps $t\sim\mathcal{U}(\{1,\dots,T\})$, and Gaussian noise $\bm{\epsilon}\sim\mathcal{N}(0,\bm{I})$. The perturbed input $\bm{x}^{\prime}_{t}$ is formed from the original image $\bm{x}_{0}$, Gaussian noise $\bm{\epsilon}$, and the RBGM-mapped adversarial perturbation $\bm{\epsilon}_{\bm{\delta}}(\bm{\delta})$, as defined in Equation 8. The scaling factor ${\sqrt{\overline{\alpha}_{t}}}/{\sqrt{1-\overline{\alpha}_{t}}}$ ensures consistency with the standard formulation of DDPM/DDIM loss. This factor reflects the expected squared error between the noise introduced to the input and the noise removed by the diffusion model during denoising.

### 5.2 Rank-Based Gaussian Mapping

Traditional diffusion models operate under the premise that input images are corrupted by independent Gaussian noise $\bm{\epsilon}$. To ensure that the perturbations remain Gaussian-like while capturing adversarial characteristics, we introduce the Rank-Based Gaussian Mapping (RBGM), illustrated in Figure 5.

Figure: Figure 5: Rank-Based Gaussian Mapping. RBGM trims the input to follow Gaussian distribution. It samples a Gaussian noise and then replaces elements in the input with those from the Gaussian noise, matched according to their respective ranks.
Refer to caption: x3.png

The RBGM function, denoted by $\bm{\epsilon}_{\bm{\delta}}(\bm{\delta})$, takes a perturbation $\bm{\delta}$ as input. The key idea is to preserve the rank ordering of the elements in $\bm{\delta}$ but replace their actual values with those from a standard Gaussian distribution. Specifically, we sample a Gaussian tensor $\bm{\epsilon}_{s}$ of the same dimensions as $\bm{\delta}$. We then sort the elements of both $\bm{\delta}$ and $\bm{\epsilon}_{s}$ respectively in ascending order. By mapping the sorted elements of $\bm{\delta}$ to the corresponding elements of $\bm{\epsilon}_{s}$, we obtain $\bm{\epsilon}_{\bm{\delta}}(\bm{\delta})$, which approximates Gaussian-distributed but retains the structural information of $\bm{\delta}$. To further enhance the Gaussian nature of the noise, we mix the RBGM-mapped perturbation with additional random Gaussian noise.

By combining the RBGM-induced perturbation with Gaussian noise, we generate an adversarial input $\bm{x}^{\prime}_{t}$ as follows:

$$ $\bm{x}^{\prime}_{t}(\bm{x}_{0},\bm{\epsilon},\bm{\epsilon}_{\bm{\delta}}(\bm{ \delta}))=\sqrt{\overline{\alpha}_{t}}\bm{x}_{0}+\sqrt{1-\lambda_{t}^{2}}\sqrt {1-\overline{\alpha}_{t}}\bm{\epsilon}+\lambda_{t}\sqrt{1-\overline{\alpha}_{t }}\bm{\epsilon}_{\bm{\delta}}(\bm{\delta}),$ (8) $$

where $\lambda_{t}$ modulates the level of adversarial perturbation. This ensures that the overall noise remains largely independent of $\bm{x}_{0}$ and that the perturbations do not overwhelm the denoising model’s learning capabilities. We determine $\lambda_{t}$ using the following formulation:

$$ $\lambda_{t}=\texttt{clip}(\gamma_{t}\lambda_{unit},\lambda_{min},\lambda_{max} ),\quad\gamma_{t}=\frac{\sqrt{\overline{\alpha}_{t}}}{\sqrt{1-\overline{\alpha }_{t}}},$ (9) $$

where the clip function limits $\lambda_{t}$ between $\lambda_{min}$ and $\lambda_{max}$.

## 6 Experiments and Discussions

### 6.1 Experiment Setups

**Table 2: Clean and robust accuracy (%) on CIFAR-10 obtained by different DBP methods. All methods show consistent improvement fine-tuned with ADDT.**
| Diffusion model | DBP model | $Clean$ | $l_{\infty}$ | $l_{2}$ |
| --- | --- | --- | --- | --- |
| - | - | 95.12 | 0.00 | 1.46 |
| DDIM | DPDDIM | 88.38 | 42.19 | 70.02 |
| DPDDIM+ADDT | 88.77 | 46.48 | 71.19 |  |
| DDPM | GDMP (No Guided) (Wang et al., ) | 91.41 | 40.82 | 69.63 |
| GDMP (MSE) (Wang et al., ) | 91.80 | 40.97 | 70.02 |  |
| GDMP (SSIM) (Wang et al., ) | 92.19 | 38.18 | 68.95 |  |
| DPDDPM | 85.94 | 47.27 | 69.34 |  |
| DPDDPM+ADDT | 85.64 | 51.46 | 70.12 |  |
| DDPM++ | COUP (Zhang et al., ) | 90.33 | 50.78 | 71.19 |
| DiffPure | 89.26 | 55.96 | 75.78 |  |
| DiffPure+ADDT | 89.94 | 62.11 | 76.66 |  |
| EDM | DPEDM (Appendix I) | 86.43 | 62.50 | 76.86 |
| DPEDM+ADDT (Appendix I) | 86.33 | 66.41 | 79.16 |  |

Classifier. We train a WideResNet-28-10 for 200 epochs following the methods in (Yoon et al., ; Wang et al., ), achieving $95.12\%$ accuracy on CIFAR-10 and $76.66\%$ on CIFAR-100 dataset.

DBP timestep. For the diffusion forward process, we adopt the same timestep settings as DiffPure (Nie et al., ). In continuous-time models, such as the VPSDE (DDPM++) variant, with the forward time parameter $0\leq t\leq 1$, we set $t^{*}=0.1$, which strikes a balance between noise introduction and computational efficiency. For discrete-time models, such as DDPM and DDIM, where $t=0,1,...,T$, we similarly set the timestep to $t^{*}=0.1\times T$. Additional settings and results on DPEDM are provided in Appendix I.

**Table 4: Clean and robust accuracy (%) on CIFAR-10, obtained by different classifiers. ADDT (WRN-28-10 guidance) improves robustness in protecting different subsequent classifiers. (*: the classifier used in ADDT fine-tuning).**
| Model | Classifier | Vanilla | ADDT |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $Clean$ | $l_{\infty}$ | $l_{2}$ | $Clean$ | $l_{\infty}$ | $l_{2}$ |  |  |
| DPDDPM-1000 | VGG-16 (Simonyan & Zisserman, ) | 84.77 | 41.99 | 66.89 | 85.06 | 46.09 | 67.87 |
| ResNet-50 (He et al., ) | 83.11 | 44.04 | 67.58 | 83.84 | 48.14 | 67.87 |  |
| WRN-28-10* (Zagoruyko & Komodakis, ) | 85.94 | 47.27 | 69.34 | 85.64 | 51.46 | 70.12 |  |
| WRN-70-16 (Zagoruyko & Komodakis, ) | 88.43 | 48.93 | 70.31 | 87.84 | 52.54 | 70.70 |  |
| ViT-B (Dosovitskiy et al., ) | 85.45 | 45.61 | 69.53 | 85.25 | 48.63 | 69.92 |  |
| DPDDIM-100 | VGG-16 (Simonyan & Zisserman, ) | 87.16 | 29.00 | 61.82 | 87.55 | 35.06 | 66.11 |
| ResNet-50 (He et al., ) | 86.04 | 31.74 | 62.11 | 86.57 | 38.77 | 65.82 |  |
| WRN-28-10* (Zagoruyko & Komodakis, ) | 88.96 | 43.16 | 67.58 | 88.18 | 47.85 | 70.61 |  |
| WRN-70-16 (Zagoruyko & Komodakis, ) | 84.40 | 39.16 | 68.36 | 84.96 | 47.66 | 69.14 |  |
| ViT-B (Dosovitskiy et al., ) | 88.77 | 34.38 | 65.72 | 88.48 | 41.02 | 68.65 |  |
| DPEDM | WRN-28-10* (Zagoruyko & Komodakis, ) | 86.43 | 62.50 | 76.86 | 86.33 | 66.41 | 79.16 |
| WRN-70-16 (Zagoruyko & Komodakis, ) | 86.62 | 65.62 | 76.46 | 86.43 | 69.63 | 78.91 |  |

Robustness evaluation. We employ PGD20+EoT10 (Athalye et al., ) for assessing model robustness. For $\ell_{\infty}$-norm attacks, we set the step size $\alpha=2/255$ and the maximum perturbation $\epsilon=8/255$, while for $\ell_{2}$-norm attacks, we use $\alpha=0.1$ and $\epsilon=0.5$. Due to the high computational cost of EoT attacks, we evaluate our models on the first 1024 images for CIFAR-10 and CIFAR-100 datasets.

ADDT. ADDT fine-tuning is guided by the pre-trained WideResNet-28-10 classifier. For the CIFAR-10 dataset, we utilize the pre-trained exponential moving average (EMA) diffusion model from Ho et al. (), which has been converted into the Huggingface Diffusers format by Fang et al. (). For the CIFAR-100 dataset, we fine-tune this CIFAR-10 diffusion model over 100 epochs. In CGPO, we set the hyperparameters to $\lambda_{unit}=0.03$, $\lambda_{min}=0$, and $\lambda_{max}=0.3$, and iteratively refine the perturbation $\delta$ for 5 steps. Additional details regarding computational cost are provided in Appendix O.

### 6.2 Defense Performance Under Different Conditions

Effectiveness of ADDT on different DBP models.
We apply ADDT to a set of diffusion models and apply DiffPure-style DBP with the refined models. The comparison on clean and robust accuracy with the baseline and other DBP models is presented in Section 6.1. It shows that ADDT effectively enhances the robustness of these models.

**Table 5: Clean and robust accuracy (%) on CIFAR-10 fine-tuned with different training samples. (None: no fine-tuning)**
| Model | Training samples | Clean | $l_{\infty}$ | $l_{2}$ |
| --- | --- | --- | --- | --- |
| DDPM | None | 85.94 | 47.27 | 69.34 |
| Clean | 85.25 | 47.27 | 68.26 |  |
| MSE-guided | 86.91 | 46.97 | 70.80 |  |
| CGPO | 85.64 | 51.46 | 70.12 |  |
| DDIM | None | 88.96 | 43.16 | 67.58 |
| Clean | 88.87 | 41.41 | 67.19 |  |
| MSE-guided | 89.36 | 40.92 | 67.68 |  |
| CGPO | 88.18 | 47.85 | 70.61 |  |

Performance on different classifiers.
We evaluate the cross-model protection ability of ADDT fine-tuned models by applying the diffusion model trained with WRN-28-10 guidance to other classifiers. The results in Section 6.1 indicate that the adversarial purification ability of these diffusion models could be transferred to different classifiers with various architectures. Notably, using a DPEDM with WRN-28-10 Guidance training, we achieve $69.63\%$ $l_{\infty}$ robust accuracy on a WRN-70-16 classifier.
This demonstrates the feasibility of ADDT as it does not require classifier-specific fine-tuning.

Performance under acceleration.
Speeding up the diffusion process by omitting intermediate steps has become a common practice in the use of diffusion models (Nichol & Dhariwal, ; Song et al., ). Hence, we evaluate the robustness of accelerated DBP models. The computation cost is measured by the number of neural function evaluations (NFE), which indicates the number of evaluation steps performed during the DBP backtracking process. For our experiments, we set $t^{*}=0.1\times T$ and accelerate the process by excluding intermediate time steps. For example, with an NFE of 5, the time steps for the DBP reverse process would be $t=[100,80,60,40,20,0]$. The results in Section 6.1 validate the effectiveness of ADDT in improving the robustness of accelerated DPDDPM models. Note that the performance of DPDDPM varies significantly between different values of NFE. This may be explained by the fact that DDPM introduces stochasticity (Gaussian noise) at each reverse step; with fewer reverse steps, its stochasticity reduces. Additionally, the generation capability of DDPM is sensitive to skipping of intermediate steps. We also conducted an evaluation of DPDDIM models, as detailed in Appendix H.

### 6.3 Ablation Study and Analysis

RBGM. We compare the generative ability of diffusion models fine-tuned with RBGM-mapped

**Table 6: FID score of DDPM for CIFAR-10 fine-tuned to different perturbations (the lower the better). Fine-tuning with RBGM-mapped perturbations yields lower FID scores than $l_{\infty}$ perturbations (without RBGM).**
|  | Vanilla | Clean Fine-tuning | ADDT | ADDT w/o RBGM |
| --- | --- | --- | --- | --- |
| FID | 3.196 | 3.500 | 5.190 | 13.608 |

and $l_{\infty}$ perturbations by comparing their Fréchet Inception Distance (FID) scores (Heusel et al., ), as shown in Table 6. The results show that diffusion models fine-tuned with RBGM-mapped perturbations maintain generation quality comparable to the vanilla diffusion model, while models directly fine-tuned with $l_{\infty}$ perturbations without RBGM show degraded performance. We also observe that training with RBGM-mapped perturbations generalized better to different attacks. Experimental details and additional tests are presented in Appendix K.

Figure: Figure 6: Revisiting robustness under Deterministic White-box setting. ADDT improves robustness under both White-box and Deterministic White-box setting, implying that ADDT strengthens the models’ ability to purify adversarial inputs.

CGPO.
We analyze the effect of fine-tuning using different training samples in Section 6.2. Specifically, we compare the performance of samples generated with classifier guidance in the CGPO step, referred to as “CGPO”, against those generated with Mean Squared Error (MSE) loss, noted as “MSE-guided”. The evaluation results are presented for DDPM with NFE 100 and DDIM with NFE 10. Results demonstrates that samples generated by CGPO significantly outperform MSE-guided samples in enhancing DBP robustness.

Revisiting DBP robustness.
We re-examine robustness under the Deterministic White-box setting by comparing the performance of diffusion models with and without ADDT fine-tuning, as shown in Figure 6. The fine-tuned models show significantly higher robust accuracy under the DW-box setting, indicating improved non-stochasticity-based robustness brought by ADDT. We provide a more detailed experiment considering different NFE in Appendix M. We also compare the loss landscapes of ADDT fine-tuned models and vanilla diffusion models, as shown in Figure 3. This comparison shows that our method effectively smooths the loss landscape of DBP models and enhance its ability to purify adversarial perturbations.

**Table 7: Robust accuracy (%) on CIFAR-10 under more PGD and EoT iterations.**
| Model | PGD200+EoT20 | PGD20+EoT10 |  |  |
| --- | --- | --- | --- | --- |
|  | Vanilla ($\ell_{\infty}$) | ADDT ($\ell_{\infty}$) | Vanilla ($\ell_{\infty}$) | ADDT ($\ell_{\infty}$) |
| DPDDPM | 41.02 | 46.19 | 47.27 | 51.46 |
| DPDDIM | 36.23 | 41.11 | 43.16 | 47.85 |
| DiffPure | 48.93 | 55.76 | 55.96 | 62.11 |

Evaluation with stronger PGD+EoT attacks.
To balance computational cost and attack strength, we primarily employ the PGD20+EoT10 configuration in our evaluations. To further validate the efficacy of ADDT under stronger attack settings, we assess its performance using the more challenging PGD200+EoT20 setup. The results presented in Table 7 and Table 9 show that under these intensified attacks, ADDT’s robust accuracy experiences a moderate 5% drop compared to the PGD20+EoT10 setting. Nonetheless, across various settings and datasets, ADDT consistently demonstrates superior robust accuracy to the baseline.

### 6.4 Scaling to More Complex and High-Dimensional Data

To evaluate the scalability of DBP and ADDT on more complex and high-dimensional datasets, we extend our experiments to include Tiny-ImageNet (Le & Yang, ) and ImageNet-1k (Deng et al., ). For Tiny-ImageNet, we trained the diffusion model from scratch for 200 epochs, followed by fine-tuning with ADDT for an additional 50 epochs, guided by a pretrained WRN-28-10 classifier. For ImageNet-1k, the diffusion model was trained from scratch for 12 epochs and then fine-tuned with ADDT for 8 epochs, using a pretrained ResNet-101 classifier as guidance.

As shown in Table 9 and Table 9, ADDT successfully enhances the robustness of DBP on these complex datasets, while the improvement may be limited.
Similar to the characteristics of adversarial training on classifiers, effective up-scaling of ADDT may require sufficient model capacity and a large amount of data, and our results in Section 6.1 have demonstrated the benefits of applying a larger diffusion model in DBP.
However, efficient training methods specialized for DBP models can be a promising direction for future studies.

In addition, we observe that the strong EoT attacks on images of higher resolution are computationally intensive. Specifically, our evaluation with PGD200+EoT20 on 1024 images of the size $224\times 224$ requires approximately 7 days on 8 NVIDIA RTX 4090 GPUs. Therefore, we argue that the up-scaling in data dimension can also imply significantly increased computational costs for the attacker.

**Table 8: Clean and robust accuracy (%) on Tiny-ImageNet with WRN-28-10 classifier. ADDT improves DBP robustness on Tiny-ImageNet (-: classifier only).**
| Model | Vanilla | ADDT |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| Clean | $l_{\infty}$ | $l_{2}$ | Clean | $l_{\infty}$ | $l_{2}$ |  |
| - | 71.37 | 0.00 | 0.00 | - | - | - |
| DPDDPM-1000 | 57.13 | 11.82 | 46.68 | 56.15 | 13.57 | 48.54 |
| DPDDIM-100 | 60.35 | 4.79 | 39.75 | 60.45 | 5.86 | 40.82 |
| DPEDM | 57.03 | 19.14 | 46.00 | 56.45 | 20.61 | 47.95 |

### 6.5 Discussions on Improving Stochasticity-based DBP Robustness

As analyzed in Section 4.2, the DBP robustness can be primarily attributed to the high variance of the stochastic attack gradients. We argue that increasing the variance of attack gradients can improve the stochasticity-based robustness of DBP models by reducing the effectiveness of EoT attacks.
Specifically, on the one hand, higher variance means higher errors in the estimation of the expected attack gradient direction with a fixed number of samples, and to reduce the error, more EoT steps are required.
On the other hand, higher variance also suggests that the expected deviation of the DW-box attack gradient (which suggests the most effective attack direction) deviates more from the EoT attack gradient, even if the estimation of the mean attack gradient is accurate. As discussed in Section 4.2, such deviation leads to lower increase in classification loss for one attack step, suggesting that a successful attack may not be achieved or require more PGD steps.

To increase the variance of attack gradients, an intuitive approach is to introduce more stochasticity. As an initial experiment, we augment the DBP framework’s stochasticity by integrating a Corrector sampler. Specifically, Song et al. () develop a Predictor-Corrector (PC) sampler framework. While standard VPSDE (DDPM++) implementations typically use only the predictor component, we add a Corrector sampler to increase stochasticity in the reverse diffusion process, thereby boosting the overall variance of attack gradients. As detailed in Appendix J, our preliminary results indicate that this modification improves the robustness of DBP models against adaptive White-box attacks. However, there is a trade-off: the model’s clean accuracy decreases slightly. These observations align with the findings of Nie et al. (), where randomizing the diffusion timesteps also leads to robustness improvements at the cost of clean accuracy, as well as with prior research on stochastic preprocessing defenses (Gao et al., ).

## 7 Conclusion

This study offers a new perspective on the robustness of Diffusion-Based Purification (DBP), emphasizing the crucial role of stochasticity and challenging the traditional view that robustness is mainly derived from minimizing the distribution gap through the forward diffusion process. We introduce a Deterministic white-box (DW-box) attack scenario and show that DBP models are based on stochastic elements to evade effective attack directions and lack the ability to purify adversarial perturbations, demonstrating distinct properties compared to models trained with Adversarial Training. To further enhance the robustness of DBP models, we develop Adversarial Denoising Diffusion Training (ADDT) and Rank-Based Gaussian Mapping (RBGM). ADDT integrates adversarial perturbations into the training process, while RBGM trims perturbations to more closely resemble Gaussian distributions.
Experiments across various diffusion methods, attack settings, and datasets suggest the effectiveness of ADDT.
In summary, this study highlights the decoupling of stochasticity-based and purification-based robustness of DBP models for deeper analysis, and suggests combining them for better robustness in practice.

## Appendix A Influence of EoT Iterations on DBP Robustness Evaluation

In this section, we examine how the number of EoT iterations influences the DBP robustness evaluation. As previously discussed in Section 4.1, the Deterministic White-box attack could find the most effective attack direction. To quantify the impact of EoT iterations, we compare the attack direction of the standard White-box-EoT across various numbers of EoT iterations with that of the Deterministic White-box.

See Figure 7 for a visual explanation, where the red line shows the DBP accuracy after attack, and the blue line shows the similarity between the attack directions of the White-box-EoT and Deterministic White-box. The trend is clear: more EoT iterations lead to greater similarity and lower model accuracy, the rate of increase in similarity and the rate of decrease in accuracy both tend to slow down with further iterations.

Balancing computational cost and evaluation accuracy, we chose the PGD20-EoT10 configuration for our robustness evaluation.

Figure: Figure 7: Robust accuracy (%) and gradient similarity on DPDDPM for CIFAR-10, obtained by different EoT iterations. As the number of EoT iterations increases, the gradient similarity between the White-box-EoT attack direction and the Deterministic White-box attack direction increases and the robust accuracy decreases.

## Appendix B DBP Models Employing Different Stochastic Elements Cannot Be Attacked All at Once

Previous research has questioned whether stochasticity can improve robustness, arguing that it can produce obfuscated gradients that give a false sense of security (Athalye et al., ). To investigate this, we implement DWSemi-box, a semi-stochastic setting that restricts the stochastic elements to a limited set of options. Our results show that stochasticity can indeed improve robustness, even when the attacker has full knowledge of all the possible options for stochastic elements.

Building on the concept of Deterministic White-box, we further propose DWsemi-128 to explore whether stochasticity can indeed improve robustness. Unlike under Deterministic White-box, where the attacker attacks a DBP model under the exact set of stochastic noise used in the evaluation, DWsemi-128 relaxes the stochastic elements to a limited set of options, the attacker should simultaneously attack over 128 different sets of stochastic noise. It uses the average adversarial direction from these 128 noise settings (EoT-128) to perturb the DBP model. To understand the impact of stochasticity, we analyze the changes of the model loss under DW-box attack and DWsemi-128 attack. We plot these changes by adjusting a factor $k$ to modify an image $x$ with a perturbation $\sigma$, evaluating the loss at $x+k\sigma$ where $k$ varies from $-16$ to $16$. We generate perturbations with $l_{\infty}$ Fast Gradient Sign Method (FGSM) (Goodfellow et al., ) with magnitude $1/255$. The plot is evaluated using WideResNet-28-10 with DPDDPM over the first 128 images of CIFAR-10 dataset.

Figure: Figure 8: Impact of stochasticity on perturbation efficacy. Perturbations created under DWsemi-box setting are less potent compared to DW-box setting. For non-adversarial perturbations, we randomly assign each element a value of either $1/255$ or $-1/255$.

As Figure 8 shows, in the Deterministic White-box setting, the perturbations significantly increase the loss, proving their effectiveness. However, for DWsemi-128, where the attack spans multiple noise setting, the increase in loss is more moderate. This suggests that even when the attackers are fully informed about the stochastic noise choices, stochasticity still improves the robustness of the DBP. This challenges the notion that there exists a vulnerable direction that is effective for all stochastic noise.

## Appendix C Impact of Attackers’ Knowledge on Robustness: Comparison of Attack Settings

This appendix delves into the influence of varying levels of attackers’ knowledge about the stochastic components in diffusion processes on the robustness of diffusion-based models. We specifically assess the individual contributions of the forward and reverse diffusion processes to model robustness across different attack scenarios.

### C.1 Stochastic Elements in the Diffusion Processes

To elucidate the impact of the attacker’s knowledge, it is crucial to understand the stochastic elements integral to the diffusion processes, which are pivotal for the model’s robustness.

In the forward diffusion process, Gaussian noise is incorporated into the input data to derive a noisy version $x_{t}$:

$$ $x_{t}=\sqrt{\bar{\alpha}_{t}}\,x+\sqrt{1-\bar{\alpha}_{t}}\,\epsilon_{f},$ (10) $$

where $\epsilon_{f}\sim\mathcal{N}(0,I)$ is sampled once per input.

In the reverse diffusion process, the model progressively denoises $x_{t}$ through iterative steps. For the Denoising Diffusion Probabilistic Model (DDPM), the reverse process is inherently stochastic:

$$ $x_{t-1}=\frac{1}{\sqrt{\alpha_{t}}}\left(x_{t}-\frac{1-\alpha_{t}}{\sqrt{1- \bar{\alpha}t}},\bm{\epsilon}_{\bm{\theta}(x_{t},t)}\right)+\sigma_{t}\epsilon _{t},$ (11) $$

where $\epsilon_{t}\sim\mathcal{N}(0,I)$ is sampled at each reverse step. In contrast, for the Denoising Diffusion Implicit Model (DDIM), the reverse process is deterministic, and no noise $\{\epsilon_{t}\}_{t=1}^{T}$ is added.

### C.2 Attack Settings and Attacker Knowledge

We delineate four distinct attack scenarios, each characterized by the extent of information available to the attacker, particularly concerning the Gaussian noise variables in the diffusion processes. Table 10 provides a summary of the attacker’s knowledge in each scenario.

**Table 10: Information accessible to the attacker in different attack settings. $\epsilon_{f}$ denotes the Gaussian noise in the forward process, and $\{\epsilon_{t}\}_{t=1}^{T}$ represents the Gaussian noise in the reverse process.**
| Attacker’s Knowledge | White-box | DWFwd | DWRev | DWBoth |
| --- | --- | --- | --- | --- |
| Model Architecture and Parameters | ✓ | ✓ | ✓ | ✓ |
| Input Images and Class Labels | ✓ | ✓ | ✓ | ✓ |
| Forward Process Noise $\epsilon_{f}$ | $\times$ | ✓ | $\times$ | ✓ |
| Reverse Process Noise $\{\epsilon_{t}\}_{t=1}^{T}$ | $\times$ | $\times$ | ✓ | ✓ |

In the conventional white-box attack setting, the attacker possesses comprehensive knowledge of the model architecture and parameters but lacks insight into the stochastic elements used during inference ($\epsilon_{f}$ and $\{\epsilon_{t}\}_{t=1}^{T}$). The DWFwd setting grants the attacker knowledge of the Gaussian noise in the forward diffusion process ($\epsilon_{f}$). Conversely, the DWRev setting provides the attacker with knowledge of the Gaussian noise introduced during the reverse diffusion steps ($\{\epsilon_{t}\}_{t=1}^{T}$). The DWBoth setting offers the attacker complete access to all stochastic elements, $\epsilon_{f}$ and $\{\epsilon_{t}\}_{t=1}^{T}$. By manipulating the attacker’s knowledge in this manner, we isolate the individual effects of the forward and reverse diffusion processes on model robustness.

### C.3 Implications of the Attacker’s Knowledge of Stochastic Elements

The attacker’s capability to craft potent adversarial examples is significantly influenced by their knowledge of the stochastic elements in the diffusion processes. When these elements are unknown to the attacker, they must independently sample noise variables, leading to discrepancies between their approximations and the actual behavior of the victim model. Conversely, if the attacker is privy to the exact noise variables used during inference, they can precisely mimic the model’s behavior, markedly boosting the efficacy of their attack.

#### Attacker Without Knowledge of Stochastic Elements

In scenarios where the attacker lacks access to specific noise variables $\epsilon_{f}$ and $\{\epsilon_{t}\}_{t=1}^{T}$, the model’s output becomes unpredictable from the attacker’s viewpoint. The attacker must then optimize the expected value of the loss function over the distribution of these stochastic elements. The optimization problem for devising an adversarial example $x^{\text{adv}}$ is formulated as:

$$ $x^{\text{adv}}=\arg\max_{\|x^{\text{adv}}-x\|\leq\delta}\,\mathbb{E}_{\epsilon _{f},\{\epsilon_{t}\}}\left[\mathcal{L}\left(f(x^{\text{adv}};\epsilon_{f},\{ \epsilon_{t}\}),y\right)\right],$ (12) $$

where $\delta$ specifies the permissible perturbation magnitude, $\mathcal{L}$ is the loss function, $f$ represents the model’s output given the input and stochastic elements, and $y$ is the actual class label.

#### Attacker With Knowledge of Stochastic Elements

Should the attacker possess exact knowledge of the noise variables $\epsilon_{f}$ and $\{\epsilon_{t}\}_{t=1}^{T}$ utilized during the model’s inference, they can accurately emulate the victim classifier’s behavior. The stochastic processes become deterministic from the attacker’s perspective, facilitating the formulation of the optimization problem as:

$$ $x^{\text{adv}}=\arg\max_{\|x^{\text{adv}}-x\|\leq\delta}\,\mathcal{L}\left(f(x ^{\text{adv}};\epsilon_{f},\{\epsilon_{t}\}),y\right).$ (13) $$

This precise knowledge allows the attacker to adopt the exact noise that will be used during the target evaluation, allowing effective evaluation.

### C.4 Effect of Attacker’s Knowledge on Model Robustness

We test the robustness of DDPM under these four settings, and Table 11 encapsulates the result.

**Table 11: Robust accuracy (%) of DDPM under different attack settings.**
| Attack Setting | Robust Accuracy ($l_{\infty}$) |
| --- | --- |
| Conventional White-Box Attack | 47.27 |
| DWFwd | 45.41 |
| DWRev | 35.25 |
| DWBoth | 16.80 |

#### Conventional White-Box Attack

In this setting, the attacker fully understands the model’s architecture and parameters but lacks knowledge of the stochastic elements ($\epsilon_{f}$ and $\{\epsilon_{t}\}_{t=1}^{T}$) used during inference. The model’s output remains unpredictable due to the stochasticity of both diffusion processes, making it challenging for the attacker to generate effective adversarial examples (reaching robust accuracy of 47.27%).

#### DW Fwd

Here, the attacker is aware of the Gaussian noise $\epsilon_{f}$ used in the forward diffusion process but not of the noise $\{\epsilon_{t}\}_{t=1}^{T}$ in the reverse process. This partial knowledge allows the attacker to accurately simulate the forward process, reducing uncertainty in this phase. However, the reverse process remains unpredictable. The slight decrease in robust accuracy to 45.41% suggests that while forward process stochasticity contributes to robustness, its effect is somewhat diminished when compromised.

#### DW Rev

In this scenario, the attacker knows the noise variables $\{\epsilon_{t}\}_{t=1}^{T}$ used in the reverse diffusion steps but not the forward process noise $\epsilon_{f}$. This knowledge enables the attacker to align their strategy more closely with the actual behavior of the model during reverse diffusion, resulting in a more noticeable drop in robust accuracy to 35.25%. The reverse process’s stochasticity appears to play a more critical role in model robustness compared to the forward process.

#### DW Both

When the attacker has comprehensive knowledge of both the forward and reverse process noise variables, they can replicate both diffusion processes accurately, eliminating any stochasticity from their perspective. This complete predictability allows for precise adversarial example crafting, leading to a significant reduction in robust accuracy to 16.80%. This demonstrates that the combined stochastic elements are crucial for maintaining robustness; when fully exposed, the model’s defense mechanisms are substantially weakened.

## Appendix D The Role of Stochasticity in DBP Compared to Certified Defense Methods

In this appendix section, we delve deeper into the role of randomness in Diffusion-Based Prediction (DBP) models and contrast it with its role in certified defense methods such as randomized smoothing (Cohen et al., ). While both approaches incorporate stochasticity, their mechanisms and implications for adversarial robustness differ significantly.

- •
Conventionally, the classification models discussed in the studies of adversarial robustness can be viewed as mappings from input space $X$ to the label space $Y$. However, DBP additionally involves a random variable $\epsilon\in E$ that determines the random sampling in the forward and reverse processes (which can be the random seed in implementation). Hence, a DBP model $f$ can be viewed as the mapping $f:(X,E)\rightarrow Y$.
- •
Previous studies on randomized smoothing treat the randomized model $f$ as a mapping $f:X\rightarrow P_{Y}$, where $P_{Y}$ is the space of label distribution. Typically, the final prediction can be formulated as $F(x)=\arg\max_{c}[f(x)]_{c}$, i.e., the class $c$ with the highest probability in the output distribution $\mathbb{f}(x)$. Apparently, $F$ deterministically maps $X$ to $Y$, consistent with the conventional models.
- •
Recent studies on DBP also regard the model as $f:X\rightarrow P_{Y}$, without explicitly studying the role of $\epsilon$. The key difference between DBP and randomized smoothing is that the final prediction for an input $x$ is directly sampled from the distribution $f(x)$ for once, instead of sampling multiple times to approximate $F(x)$ as in randomized smoothing.
- •
In this paper, we revisit DBP by treating the randomized model $f$ as the mapping $f:(X,E)\rightarrow Y$ and studying the role of $\epsilon\in E$ as an input of $f$. From this perspective, the conventional adversarial setting assuming full knowledge of the model parameters (but not $\epsilon$) is not a complete white box, which motivates us to study the DW-box setting.
- •
From our perspective, we can clearly point out the difference between DBP and randomized smoothing in terms of the loss landscape. Given an input $x_{0}$, the local loss landscape for a DBP model $f$ is not deterministic as it also depends on $\epsilon$. Although the expected loss landscape over $\epsilon\in E$ may be smooth, it does not suggest the robustness of DBP, as $\epsilon$ is fixed during a single inference run of DBP. Indeed, our study suggests that given $x_{0}$ and a fixed $\epsilon_{0}$, the local landscape of DBP is likely not smooth. In contrast, the loss landscape of a randomized smoothing model $F$ may be smooth as it is the average landscape over multiple $\epsilon$. To conclude, we argue that the random noise itself may not smooth the loss landscape, but the average over random noises may.

## Appendix E Attack Method and Settings

Previous assessments of DBP robustness have often utilized potentially unreliable methods. In particular, due to the iterative denoising process in diffusion models, some studies resort to mathematical approximations of gradients to reduce memory constraints (Athalye et al., ) or to circumvent the diffusion process during backpropagation (Wang et al., ). Furthermore, the reliability of AutoAttack, a widely used evaluation method, in assessing the robustness of DBP models is questionable. Although AutoAttack includes a Rand version designed for stochastic models, Nie et al. () have found instances where the Rand version is less effective than the Standard version in evaluating DBP robustness.

To improve the robustness evaluation of diffusion-based purification (DBP) models, we implement several modifications. First, to ensure the accuracy of the gradient computations, we compute the exact gradient of the entire diffusion classification pipeline. To mitigate the high memory requirements in diffusion iterative denoising steps, we use gradient checkpointing (Chen et al., ) techniques to optimize memory usage. In addition, to deal with the stochastic nature of the DBP process, we incorporate the Expectation over Transformation (EoT) method to average gradients across different attacks. We adopt EoT with 10 iterations, and a detailed discussion of the choice of EoT iterations can be found in Appendix A. We also use the Projected Gradient Descent (PGD) attack instead of AutoAttack for our evaluations(^1^11We discover a bug in the Rand version of AutoAttack that causes it to overestimate the robustness of DBP. After fixing this, AutoAttack gives similar results to PGD attacks, but at a much higher computational cost. We discuss this in detail in Appendix L.). Our revised robustness evaluation revealed that DBP models, such as DiffPure and GDMP, perform worse than originally claimed. DiffPure’s accuracy dropped from a claimed 70.64% to an actual 55.96%, and GDMP’s from 90.10% to 40.97%. These results emphasize the urgent need for more accurate and reliable evaluation methods to properly assess the robustness of DBP models.
Similar evaluation protocols are also applied in Chen et al. (); Kang et al. ().

## Appendix F Experimental Setting of Visualization of the Attack Trajectory

We visualize the attack by plotting the loss landscape and trace the trajectories of EoT attack under White-box setting and the Deterministic White-box setting in Figure 3. We run a vanilla PGD20-EoT10 attack under White-box setting and a PGD20 attack under Deterministic White-box setting. We then expand a 2D space using the final perturbations from these two attacks, draw the loss landscape, and plot the attack trajectories on it. Note that the two adversarial perturbation directions are not strictly orthogonal. To extend this 2D space, we use the Deterministic White-box attack direction and the orthogonal component of the EoT attack direction. Note that the endpoints of both trajectories lie exactly on the loss landscape, while intermediate points are projected onto it. The plot is evaluated using WideResNet-28-10 with DPDDPM over the first 128 images of CIFAR-10 dataset.

## Appendix G Pseudo-code of ADDT

The pseudo-code for adopting ADDT within DDPM and DDIM framework is shown in Algorithm 1.

Figure: Algorithm 1 Adversarial Denoising Diffusion Training (ADDT)

## Appendix H ADDT Results on DP DDIM

As shown in Table 12, the performance of DPDDIM is less sensitive to the number of function evaluations (NFE). Additionally, ADDT consistently improved the robustness of DPDDIM.

**Table 12: Clean and robust accuracy (%) on DPDDIM. ADDT improve robustness across different NFE (*: default DDIM generation setting, -: classifier only ).**
| Dataset | NFE | Vanilla | ADDT |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $Clean$ | $l_{\infty}$ | $l_{2}$ | $Clean$ | $l_{\infty}$ | $l_{2}$ |  |  |
| CIFAR-10 | - | 95.12 | 0.00 | 1.46 | 95.12 | 0.00 | 1.46 |
| 5 | 89.65 | 42.19 | 68.65 | 88.57 | 47.27 | 70.61 |  |
| 10* | 88.96 | 43.16 | 67.58 | 88.18 | 47.85 | 70.61 |  |
| 20 | 87.89 | 41.70 | 69.24 | 88.67 | 48.63 | 69.73 |  |
| 50 | 88.96 | 42.48 | 68.85 | 88.57 | 46.68 | 69.24 |  |
| 100 | 88.38 | 42.19 | 70.02 | 88.77 | 46.48 | 71.19 |  |
| CIFAR-100 | - | 76.66 | 0.00 | 2.44 | 76.66 | 0.00 | 2.44 |
| 5 | 62.11 | 15.43 | 35.74 | 62.79 | 17.58 | 38.87 |  |
| 10* | 62.21 | 15.33 | 36.52 | 64.45 | 20.02 | 39.26 |  |
| 20 | 63.67 | 15.62 | 37.89 | 65.23 | 18.65 | 40.62 |  |
| 50 | 62.40 | 16.31 | 37.79 | 63.87 | 19.14 | 39.94 |  |
| 100 | 63.28 | 15.23 | 36.62 | 66.02 | 18.85 | 39.84 |  |

## Appendix I Adopting VPSDE(DDPM++) and EDM Models in DBP

In the previous discussion of the robustness of DBP models, as detailed in Section 4.1, our focus was primarily on the DDPM and DDIM models. We now extend our analysis to include VPSDE (DDPM++) and EDM (Karras et al., ) models. VPSDE (DDPM++) is the diffusion model used in DiffPure.

From a unified perspective, diffusion processes can be modeled by stochastic differential equations (SDE) (Song et al., ). The forward SDE, as described in Equation 14, converts a complex initial data distribution into a simpler, predetermined prior distribution by progressively infusing noise. This can also be done in a single step, as shown in Equation 15, mirroring the strategy of DDPM described in Equation 2. Reverse SDE, as explained in Equation 16, reverses this process, restoring the noise distribution to the original data distribution, thus completing the diffusion cycle.

$$ $\displaystyle\mathrm{d}\bm{x}=\bm{f}(\bm{x},t)\mathrm{d}t+g(t)\mathrm{d}\bm{w},$ (14) $$

$$ $\displaystyle p_{0t}($ $\displaystyle\bm{x}(t)\mid\bm{x}(0))=$ (15) $\displaystyle\mathcal{N}\left(\bm{x}(t);e^{-\frac{1}{4}t^{2}(\bar{\beta}_{\max }-\bar{\beta}_{\min})-\frac{1}{2}t\bar{\beta}_{\min}}\bm{x}(0),{\bm{I}}-{\bm{I }}e^{-\frac{1}{2}t^{2}(\bar{\beta}_{\max}-\bar{\beta}_{\min})-t\bar{\beta}_{ \min}}\right),\quad t\in[0,1]$ $$

$$ $\displaystyle\mathrm{d}\bm{x}=\begin{bmatrix}\bm{f}(\bm{x},t)-g^{2}(t)\nabla_{ \bm{x}}\log p_{t}(\bm{x})\end{bmatrix}\mathrm{d}t+g(t)\mathrm{d}\bar{\bm{w}}.$ (16) $$

The reverse process of SDEs also derives equivalent ODEs Equation 17 for fast sampling and exact likelihood computation, and this Score ODEs corresponds to DDIM.

$$ $\displaystyle\mathrm{d}\bm{x}=\left[\bm{f}(\bm{x},t)-\frac{1}{2}g(t)^{2}\nabla _{\bm{x}}\log p_{t}(\bm{x})\right]\mathrm{d}t.$ (17) $$

By modulating the stochasticity, we can craft a spectrum of semi-stochastic models that bridge pure SDEs and deterministic ODEs, offering a range of stochastic behaviors.

EDM provides a unified framework to synthesize the design principles of different diffusion models (DDPM,DDIM,iDDPM (Nichol & Dhariwal, ),VPSDE,VESDE (Song et al., )). Within this framework, EDM incorporates efficient sampling methods, such as the Heun sampler, and introduces optimized scheduling functions $\sigma(t)$ and $s(t)$. This allows EDM to achieve state-of-the-art performance in generative tasks.

EDM forward process could be presented as:

$$ $\displaystyle\bm{x}_{t}=\bm{x}_{0}+\sigma(t^{*})*\bm{\epsilon},\quad\bm{ \epsilon}\sim\mathcal{N}(0,\bm{I}),$ (18) $$

where we choose $\sigma(t^{*})=0.5$ for clean and robust accuracy tradeoff. And for reverse process, EDM incorporates a parameter $S_{churn}$ to modulate the stochastic noise infused during the reverse process. For our experiments, we choose 50 reverse steps (50 NFE, NFE is Function of Neural Function Evaluations), configured the parameters with $S_{min}=0.01$, $S_{max}=0.46$, $S_{noise}=1.007$, and designate $S_{churn}=0$ to represent EDM-ODE, $S_{churn}=6$ to represent EDM-SDE.

As shown in Table 13, our ADDT could also increase the robustness of DPEDM.

**Table 13: Clean and robust accuracy (%) on DPEDM for CIFAR-10. ADDT improves robustness in both DPEDM-SDE and DPEDM-ODE.**
| Type | Vanilla | ADDT |  |  |
| --- | --- | --- | --- | --- |
| DPEDM-SDE | DPEDM-ODE | DPEDM-SDE | DPEDM-ODE |  |
| Clean | 86.43 | 87.99 | 86.33 | 87.99 |
| $l_{\infty}$ | 62.50 | 60.45 | 66.41 | 64.16 |
| $l_{2}$ | 76.86 | 75.49 | 79.16 | 77.15 |

## Appendix J Strengthening DBP via Augmented Stochasticity

Song et al. present a Predictor-Corrector sampler for SDEs reverse process for VPSDE (DDPM++) (as detailed in Appendix I of Song et al. ()). However, standard implementations of VPSDE (DDPM++) typically use only the Predictor. Given our hypothesis that stochasticity contributes to robustness, we expect that integrating the Corrector sampler into VPSDE (DDPM++) would further enhance the robustness of DBP models. Our empirical results, as shown in Table 14, confirm that the inclusion of a Corrector to VPSDE (DDPM++) indeed improve the model’s defenses ability against adversarial attacks with $l_{\infty}$ norm constraints. This finding supports our claim that the increased stochasticity can further strengthen DBP robustness. Adding Corrector is also consistent with ADDT. Note that the robustness against $l_{2}$ norm attacks does not show a significant improvement with the integration of the Extra Corrector. A plausible explanation for this could be that the robustness under $l_{2}$ attacks is already quite strong, and the compromised performance on clean data counteracts the increase in robustness.

**Table 14: Clean and robust accuracy (%) on DPDDPM++ for CIFAR-10. Both extra Corrector and ADDT fine-tuning improved robustness.**
| Type | Vanilla | Extra Corrector | ADDT | ADDT+Extra Corrector |
| --- | --- | --- | --- | --- |
| Clean | 89.26 | 85.25 | 89.94 | 85.55 |
| $l_{\infty}$ | 55.96 | 59.77 | 62.11 | 65.23 |
| $l_{2}$ | 75.78 | 74.22 | 76.66 | 76.66 |

## Appendix K Evaluating RBGM-Mapped Perturbations

In Section 6.3, we briefly explore the generation capabilities of diffusion models trained with RBGM-mapped and $l_{\infty}$ perturbations. Here, we provide details of the experiment and delve deeper into their robustness. To train with $l_{\infty}$ perturbations, we adjust ADDT, replacing RBGM-mapped perturbations with $l_{\infty}$ perturbations. Here, instead of converting accumulated gradients to Gaussian-like perturbations, we use a 5-step projected gradient descent (PGD-5) approach. We also set $\lambda_{unit}=1,\lambda_{min}=0,\lambda_{max}=10$. We refer to this modified training protocol as ADDT$l_{\infty}$.

**Table 15: Clean and robust accuracy (%) on DBP models trained with different perturbations for CIFAR-10. While ADDT simultaneously improves clean accuracy and robustness against both $l_{2}$ and $l_{\infty}$ attacks. ADDT$l_{\infty}$ primarily improves performance against $l_{\infty}$ attacks.**
| Method | Dataset | Vanilla | ADDT | ADDT$l_{\infty}$ |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| $Clean$ | $l_{\infty}$ | $l_{2}$ | $Clean$ | $l_{\infty}$ | $l_{2}$ | $Clean$ | $l_{\infty}$ | $l_{2}$ |  |  |
| DPDDPM-1000 | CIFAR-10 | 85.94 | 47.27 | 69.34 | 85.64 | 51.46 | 70.12 | 84.47 | 52.64 | 68.55 |
| CIFAR-100 | 57.52 | 20.41 | 37.89 | 59.18 | 23.73 | 41.70 | 57.81 | 23.24 | 40.04 |  |
| DPDDIM-100 | CIFAR-10 | 88.38 | 42.19 | 70.02 | 88.77 | 46.48 | 71.19 | 88.48 | 50.49 | 70.31 |
| CIFAR-100 | 63.28 | 15.23 | 36.62 | 66.02 | 18.85 | 39.84 | 64.84 | 20.31 | 39.36 |  |

We evaluate the clean and robust accuracy of ADDT and ADDT$l_{\infty}$ fine-tuned models. These models exhibit different behaviors. As shown in Table 15, while Gaussian-mapped perturbations can simultaneously improve clean accuracy and robustness against both $l_{2}$ and $l_{\infty}$ attacks, training with $l_{\infty}$ perturbations primarily improves performance against $l_{\infty}$ attacks.

## Appendix L Evaluation with Fixed AutoAttack

AutoAttack (Croce & Hein, ), an ensemble of White-box and Black-box attacks, is a popular benchmark for evaluating model robustness. It is used in RobustBench (Croce et al., ) to evaluate over 120 models. However, Nie et al. Nie et al. () found that the Rand version of AutoAttack, designed to evaluate stochastic defenses, sometimes yields higher accuracy than the Standard version, intended for deterministic methods. Our comparison of AutoAttack and PGD20-EoT10 in Table 16 also shows that the Rand version of AutoAttack gives higher accuracy than the PGD20-EoT10 attack.

We attribute this to the sample selection of AutoAttack. As an ensemble of attack methods, AutoAttack selects the final adversarial sample from either the original input or the attack results. However, the original implementation neglects stochasticity and considers a adversarial sample to be sufficiently adversarial if it gives a false result in one evaluation. To fix this, we propose a 20-iteration evaluation and selects the adversarial example with the lowest accuracy. The flawed code is in the official GitHub main branch, git version $a39220048b3c9f2cca9a4d3a54604793c68eca7e$, and specifically in lines #125, #129, #133-136, #157, #221-225, #227-228, #231 of the file autoattack/autoattack.py. We will open source our updated code and encourage future stochastic defense methods to be evaluated against the fixed code. The code now can be found at: [https://anonymous.4open.science/r/auto-attack-595C/README.md](https://anonymous.4open.science/r/auto-attack-595C/README.md).

After the fix, AutoAttack’s accuracy dropped by up to 10 points, producing similar results to our PGD20-EoT10 test results. However, using AutoAttack on DPDDPM with $S=1000$ took nearly 25 hours, five times longer than PGD20-EoT10, so we will use PGD20-EoT10 for the following test.

**Table 16: AutoAttack (Rand version) and PGD20-EoT10 performance on DBP methods for CIFAR-10 (the lower the better). The original AutoAttack produces high accuracy (%), after fixing, it achieves similar results to PGD20+EoT10 attack.**
| Method | $l_{\infty}$ | $l_{2}$ |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| AutoAttack | AutoAttackFixed | PGD20-EoT10 | AutoAttack | AutoAttackFixed | PGD20-EoT10 |  |
| DiffPure | 62.11 | 56.25 | 55.96 | 81.84 | 76.37 | 75.78 |
| DPDDPM-1000 | 57.81 | 46.88 | 48.63 | 71.68 | 71.09 | 72.27 |
| DPDDIM-100 | 50.20 | 40.62 | 44.73 | 77.15 | 70.70 | 71.68 |

**Table 17: Clean and robust accuracy (%) on different DBP methods for CIFAR-10, evaluated with AutoAttackADDT (Rand version). All methods show consistent improvement when fine-tuned with ADDT.**
| Method | Vanilla | ADDT |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| $Clean$ | $l_{\infty}$ | $l_{2}$ | $Clean$ | $l_{\infty}$ | $l_{2}$ |  |
| DiffPure | 89.26 | 56.25 | 76.37 | 89.94 | 58.20 | 77.34 |
| DPDDPM | 85.94 | 46.88 | 71.09 | 85.64 | 48.63 | 72.27 |
| DPDDIM | 88.38 | 40.62 | 70.70 | 88.77 | 44.73 | 71.68 |

## Appendix M Robustness under Deterministic White-box Setting

We evaluate robustness of ADDT fine-tuned models under Deterministic White-box Setting. We assess robustness across varying NFE and compare the performance of vanilla models and ADDT fine-tuned models, with results showcased in Figure 9. ADDT consistently improves model performance at different NFE, particularly noticeable at lower NFE. This affirms that ADDT equips the diffusion model with the ability to directly counter adversarial perturbations.

Figure: Figure 9: Revisiting Deterministic White-box Robustness. ADDT improves robustness under both White-box and Deterministic White-box setting, implying that ADDT strengthens the models’ ability to handle adversarial inputs. The dashed line on the right is the performance of the vanilla model.

## Appendix N Ablation Study of λ u ⁢ n ⁢ i ⁢ t subscript 𝜆 𝑢 𝑛 𝑖 𝑡 \lambda_{unit} italic_λ start_POSTSUBSCRIPT italic_u italic_n italic_i italic_t end_POSTSUBSCRIPT

In Section 6.1 we choose $\lambda_{unit}$=0.03 because most of the adversarial perturbations are in this range. We also provide an ablation study here, which shows that the performance of ADDT is insensitive to $\lambda_{unit}$ and gets a consistent improvement.

**Table 18: Ablation study of $\lambda_{unit}$, ADDT is insensitive to it and gets a consistent improvement on robust accuracy (%).**
| Attack type \NFE | $\lambda_{unit}$ | 5 | 10 | 20 | 50 | 100 |
| --- | --- | --- | --- | --- | --- | --- |
| $l_{\infty}$ | $Clean$ | 21.78 | 36.72 | 45.21 | 46.78 | 47.27 |
| 0.02 | 24.02 | 40.92 | 48.14 | 48.83 | 48.93 |  |
| 0.03 | 30.27 | 43.07 | 48.44 | 50.20 | 51.46 |  |
| 0.04 | 31.25 | 44.92 | 50.68 | 51.07 | 50.88 |  |
| $l_{2}$ | $Clean$ | 36.13 | 55.47 | 65.23 | 68.85 | 69.34 |
| 0.02 | 41.99 | 61.72 | 67.48 | 69.82 | 70.31 |  |
| 0.03 | 41.99 | 62.97 | 69.82 | 69.04 | 70.12 |  |
| 0.04 | 49.02 | 64.45 | 69.24 | 69.53 | 69.92 |  |

## Appendix O Computational Cost of ADDT

Optimizing DDPM and DDIM models through ADDT achieves near-optimal performance in 50 epochs, taking 12 hours on 4 NVIDIA GeForce RTX 2080 Ti GPUs. This matches the speed of traditional adversarial training and is significantly faster than the latest adversarial training techniques that use diffusion models to augment the dataset (Wang et al., ). Testing DPDDPM and DPDDIM is computationally costly due to the employment of EoT; it takes approximately 5 hours on four NVIDIA GeForce RTX 2080 Ti GPUs to validate 1,024 images on the CIFAR10/CIFAR100 datasets.

A notable feature of ADDT is its one-and-done training approach. After the initial training, ADDT can protect various classifiers without the need for further fine-tuning, as shown in Section 6.1. This differs from adversarial classifier training, which requires individual training for each classifier.

## Appendix P Credibility of Our Paper

The code was developed independently by two individuals and mutually verified, with consistent results achieved through independent training and testing.
We will also make the code open-source and remain committed to advancing the field.

## Appendix Q Broader Impact and Limitations

Our work holds significant potential for positive societal impacts across various sectors, including autonomous driving, facial recognition payment systems, and medical assistance. We are dedicated to enhancing the safety and trustworthiness of global AI applications. However, there are potential negative societal impacts, particularly concerning privacy protection, due to adversarial perturbations. Nonetheless, we believe that the positive impacts generally outweigh the potential negatives. Regarding the limitations, our approach could benefit from integrating insights from traditional adversarial training methods (Zhang et al., ; Shafahi et al., ; Wang et al., ), such as through more extensive data augmentation and a refined ADDT loss design. Nevertheless, these limitations are minor and do not significantly detract from the overall contributions of this paper. We believe that these new findings and perspectives could have a sustained impact on future research on DBP, which is a promising approach to adversarial defense
and could be more valuable for real-world applications, although existing studies on DBP are at an early stage.

## Peer Reviews

confidence: 4
contribution: 4
initial_rating: 6
presentation: 3
questions: 1. As the perturbation after Rand-Based Gaussian Mapping is still a Gaussian noise, can I view the idea of ADDT is just using further perturbed images for additional training, if so, is the improvement relying on the additional data?

2. What is the reason of choosing such a range for the modulation term in line 362-364?
soundness: 4
strengths: 1. The work has included extensive experiment contents, such as exploration on accelerated generation of diffusion model, stronger white-box attack with more attack iterations and included various dataset results.

2. The author proposed an appropriate attack evaluation, DW-box attack, which makes the performance comparison reliable.

3. The ADDT technique has improved the robustness of all baseline DBP methods.
summary: The author argues that the current effectiveness of the DBP method, attributed to the forward process of diffusion models, lacks sufficient empirical validation. While they acknowledge the theory of mitigating distribution gap, they question whether the forward and backward diffusion stochasticity in DBP is indeed what enhances model robustness. To address this, they propose a new attack evaluation, the DW-Box attack, which captures both stochasticity information and parameters of defense system. Experiments reveal that models like DDPM and DDIM lack strong robustness against this new attack. Additionally, the authors introduce ADDT, a fine-tuning technique for diffusion models in the existing DBP methods. This approach first optimizes the generated adversarial perturbation using classifier guidance, and then performs further training on images with both Gaussian noise and optimized perturbations. They aim to enhance the purification capability of diffusion models. This method significantly enhances the robustness of existing DBP methods. Overall, the paper critically examines the underlying principles that make DBP methods effective.
weaknesses: 1. The author should provide a few more comparisons for the same content in figure 6, which shows the performance of the ADDT fine-tuning under the proposed DW-box attack. 

2. In figure 3, it is not convincing if the author only draws one complete attack trajectory. 

3. The whole idea can be viewed as an additional training by using samples with more Gaussian noises at the same timestep, hence the diffusion model achieves better purification ability, I would like to see whether the RBGM perturbation is different with using a pure additional Gaussian noise with trivial order. Hence, we cannot say the model has improved its ability of enhancing purification of adversarial perturbations.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 2
questions: Please see Weaknesses.
soundness: 3
strengths: 1. The paper identifies that the robustness provided by diffusion models is likely due to stochastic elements within the model rather than solely the diffusion process.
2. The authors propose a new training method for diffusion models that incorporates robustness information, enhancing the model's purification capability.
summary: This paper investigates the robustness of Diffusion-Based Purification (DBP) methods in adversarial attacks, proposing that its defensive effectiveness relies primarily on stochasticity rather than the traditional noise ablation process. By introducing a deterministic white-box evaluation approach, the authors demonstrate the critical role of stochasticity in DBP's robustness. To enhance DBP's denoising capability, the paper presents Adversarial Denoising Diffusion Training (ADDT) and Rank-Based Gaussian Mapping (RBGM), with experimental results showing significant improvements in defense performance. The authors suggest that future research should focus on decoupling stochasticity from purification capability to optimize defensive performance.
weaknesses: 1. While the study contributes positively to understanding purification using diffusion models, there are concerns about the complexity of purification. It significantly increases the model's complexity, potentially multiple times compared to the original model, and this real-world cost needs to be experimentally clarified (complexity analysis).
2. If the training data for the diffusion model originates from the same data as the original model, a comparison with methods using the diffusion model to generate new samples for robust model training would be valuable, as this approach does not add runtime complexity [1].
3. Questions remain about why perturbations are not directly modified by mean and variance adjustments to achieve Gaussian distribution, instead requiring replacement.

**Reference**:

[1] Wang, Zekai, et al. "Better diffusion models further improve adversarial training." International Conference on Machine Learning. PMLR, 2023.

---

confidence: 3
contribution: 3
initial_rating: 8
presentation: 3
questions: 1) Based on the conclusion of your paper that stochasticity is the main ingredient of the success of the DBP, do you think a diffusion model even necessary for the defense? What if we just add a certain amount of gaussian noise directly to the adversarial example and then just denoise it with an off-the-shelf image denoising network that was specifically trained to remove gaussian noise? Do you think it will work just as well as a defense method?
soundness: 3
strengths: 1) The paper is well written and relatively easy to follow.
2) Novel perspective on why Diffusion-Based Purification works and how it can be further improved.
3) Claims are well supported by experiments.
summary: The paper explores the reason behind the success of Diffusion-Based Purification (DBP) as a defense against adversarial attacks, highlighting that its effectiveness comes from randomness rather than just reducing the difference between clean and adversarial images. The authors introduced a new evaluation method, Deterministic White-Box (DW-box), and found that DBP’s ability to purify adversarial perturbations is weak without stochasticity. To improve DBP, they developed Adversarial Denoising Diffusion Training (ADDT), which incorporates adversarial examples into the training process, and Rank-Based Gaussian Mapping (RBGM), which makes adversarial perturbations more Gaussian-like. Their experiments showed that these methods enhance DBP’s robustness.
weaknesses: N/A

---

confidence: 5
contribution: 3
initial_rating: 6
presentation: 3
questions: I'm quite curious about the following (I would like to raise my score if the authors could provide more comprehensive studies on the mechanism of their proposed methods):

- Are the points in Fig. 1 obtained by sampling at intervals of a certain number of attack steps? If so, does this imply that the attack process initially moves the farthest distance and moves the fastest, while the loss increases the slowest, and then the movement gradually slows as time progresses but the loss increases more rapidly?

- How did you come up with RGBM? What inspired this approach?

- RGBM uses values from a Gaussian distribution but follows the order of adversarial perturbations. What would happen if we used the order of Gaussian noise but the values of adversarial perturbations? I’m curious if the main mechanism of RGBM is to eliminate large (outlier) values.

- I am very interested in whether "ADDT w/o RGBM" and "ADDT" in Table 6 were fine-tuned from pretrained models or trained from scratch. Was "ADDT w/o RGBM" fine-tuned from "ADDT"?

- Can I understand RGBM as maintaining robustness while improving generalization and generation performance across different attacks?

- I am very curious about why RGBM works. First, I notice that the result mapped by RGBM does not follow a Gaussian distribution, nor even a non-isotropic Gaussian (since each element is not Gaussian). Thus, the RGBM-mapped result is a biased estimator rather than an unbiased one. The only similarity I see to a Gaussian distribution is that, like a high-dimensional Gaussian, it also lies on a spherical shell. Is this the main reason it preserves the generalization of pretrained diffusion models? If so, simply "normalizing" the adversarial perturbation to an \(\ell_2\) norm of \(O(\sqrt{D})\) should also work (since the \(\ell_2\) norm of a high-dimensional Gaussian converges to \(\sqrt{D}\)). A simple way like yours (your illustration) to understand this is first to sample a Gaussian noise, compute its norm, and normalize the adversarial perturbation to this norm. Could you provide an ablation study on this?
soundness: 2
strengths: I like the following contributions in this paper:

- The authors systematically study how each of the stochastic elements in DiffPure contributes to robustness, including the "forward process," "backward process," and the combination of both, clearly demonstrating how much each component contributes to robustness.

- The authors propose RGBM, which significantly alleviates the previous limitation of adversarial training compromising the generative ability of diffusion models.

- Fig. 5 is excellent. Without Fig. 5, it would be challenging to understand RGBM clearly due to existing ambiguities (see question 3 on the two types of RGBM).
summary: This paper examines how stochastic elements contribute to robustness in DiffPure by systematically ablating these components (DW-box). The authors propose incorporating adversarial training into DiffPure and addressing the "robustness-generalization tradeoff" through a novel technique, RGBM, which preserves both robustness and generative performance.
weaknesses: There are no severe weaknesses in this paper, but one notable issue:

- "Note that DDPM is mathematically equivalent to the DDPM++ (VPSDE) model used in DiffPure but employs a smaller UNet architecture. DDIM, on the other hand, is a mathematical improvement over DDPM that facilitates an ODE-based diffusion process." This statement lacks formality. DDPM is a mathematical framework independent of neural network architecture. Additionally, the DDPM framework represents only one discretization of the VP-SDE, while other discretizations also exist. The authors should address this non-formal claim.

Meta-review: This paper focuses on understanding diffusion-based purification which is an effective defense mechanism against adversarial attacks in recent literature. The paper identifies that the robustness provided by diffusion models is likely due to stochastic elements within the model rather than solely the diffusion process. The authors propose a new training method for diffusion models that incorporates robustness information, enhancing the model's purification capability. The work has also included extensive experiment contents, such as exploration on accelerated generation of diffusion model, stronger white-box attack with more attack iterations and included various dataset results. During rebuttal, all concerns are addressed by the authors. Due to the significance of this paper, I recommend accepting this paper at this round.

Decision: Accept (Poster)