Abstract
Diffusion models have achieved notable success in image generation, but they remain highly vulnerable to backdoor attacks, which compromise their integrity by producing specific undesirable outputs when presented with a pre-defined trigger. In this paper, we investigate how to protect diffusion models from this dangerous threat. Specifically, we propose TERD, a backdoor defense framework that builds unified modeling for current attacks, which enables us to derive an accessible reversed loss. A trigger reversion strategy is further employed: an initial approximation of the trigger through noise sampled from a prior distribution, followed by refinement through differential multi-step samplers. Additionally, with the reversed trigger, we propose backdoor detection from the noise space, introducing the first backdoor input detection approach for diffusion models and a novel model detection algorithm that calculates the KL divergence between reversed and benign distributions. Extensive evaluations demonstrate that TERD secures a 100% True Positive Rate (TPR) and True Negative Rate (TNR) across datasets of varying resolutions. TERD also demonstrates nice adaptability to other Stochastic Differential Equation (SDE)-based models.
Introduction
Diffusion models have revolutionized generative AI, yet they possess a significant security "Achilles' heel": backdoor attacks. In these scenarios, a malicious actor poisons the training data so that the model behaves normally for most inputs but produces a specific, undesirable output—such as a prohibited image or a specific logo—when a "trigger" (a small pixel pattern) is present in the initial noise.
Defending against these attacks is notoriously difficult. Unlike traditional classification models, where defenders can inspect class logits for signs of manipulation, diffusion models operate in a complex, high-dimensional noise space. Previous defenses often struggled because they made narrow assumptions about specific attack implementations. As new methods like TrojDiff or VillanDiffusion emerged, older defenses became obsolete. TERD (Trigger Estimation and Refinement for Diffusion) addresses this by providing a unified defense framework.
The TERD Framework
1. Unified Modeling
The core innovation of TERD is the mathematical proof that almost all current backdoor attacks on diffusion models can be described by a single formulation. By applying the triangle inequality to this unified equation, the researchers derived a "reversed loss" function. This allows defenders to reverse-engineer hidden triggers without needing prior knowledge of the specific attack method used.
2. Two-Stage Trigger Reversion
Identifying a trigger in high-dimensional space is a significant computational challenge. TERD solves this via a two-step process:
- Estimation: The framework begins with a rough approximation of the trigger using noise sampled from a surrogate distribution, such as standard Gaussian noise.
- Refinement: The estimate is then "polished" using differential multi-step samplers (such as DDIM or Heun solvers). This refinement stage ensures the reversed trigger is highly accurate and visually similar to the original malicious trigger.
3. Dual-Level Detection
Once a potential trigger is reversed, TERD employs two distinct detection mechanisms:
- Input Detection: This represents the first backdoor input detection approach for diffusion models. It checks if a specific starting noise contains a trigger by comparing its probability in "benign" versus "backdoor" distributions.
- Model Detection: This determines if a model itself is infected by calculating the KL divergence—a measure of how two distributions differ—between the reversed trigger distribution and a known benign one.
Experimental Evaluation
Datasets and Versatility
The framework was evaluated on several standard benchmarks, including CIFAR-10 (32x32 images) and CelebA/CelebA-HQ (high-resolution faces up to 256x256). Beyond standard diffusion, the authors demonstrated TERD's adaptability to other Stochastic Differential Equation (SDE)-based models, including Score-based and Consistency models.
Performance and Efficiency
In rigorous testing against BadDiffusion, TrojDiff, and VillanDiffusion, TERD achieved a 100% True Positive Rate (TPR) and 100% True Negative Rate (TNR). This indicates the system never missed an attack and never raised a false alarm during the evaluation suite. Furthermore, the reversed triggers produced by TERD significantly outperformed previous state-of-the-art defenses like Elijah in terms of fidelity.
From a computational standpoint, TERD is highly efficient. Reverse-engineering a trigger takes approximately 11–24 minutes on a single A100 GPU. This represents less than 1% of the computational overhead required for standard model training, making it a practical addition to the model deployment pipeline.
Conclusion
TERD demonstrates that the key to defending diffusion models lies in the noise space. Because these models are essentially noise-to-data converters, the statistical characteristics of the noise are far more revealing of malicious tampering than the final generated pixels. While TERD is highly effective against pixel-level attacks, future work will look toward bridging the gap between pixel-level and semantic-level (prompt-based) backdoors in text-to-image models.
Summary updated