Abstract
Diffusion models (DMs) have revolutionized generative AI, yet their security remains under-explored. We present BadDiffusion, the first framework for implanting backdoors into DMs. By maliciously engineering the training process, an attacker can create a model that generates high-quality images under normal conditions but switches to producing a specific, pre-defined target image upon detecting a secret trigger. Our results demonstrate that DMs are highly susceptible to these attacks, requiring as little as 5% poisoned data to achieve high target specificity without compromising general utility.
Introduction
Diffusion models, such as Stable Diffusion, have become the foundation for modern generative tasks. However, the community's reliance on pre-trained models from unverified sources introduces a significant security risk: backdoor attacks. In a traditional Trojan attack, a model behaves correctly on standard inputs but executes a malicious function when a specific "trigger" is present. While extensively studied in discriminative models, the vulnerability of generative diffusion models has remained a critical gap in AI security research. BadDiffusion addresses this gap, revealing that DMs can be easily compromised to serve as "double agents."
Methodology
BadDiffusion modifies the core mechanics of the diffusion process by defining a backdoored forward process. In a standard DM, the model learns to reverse a process that gradually adds Gaussian noise to an image. BadDiffusion hijacks this by teaching the model to associate "poisoned" samples (inputs containing a trigger) with a specific backdoor target rather than the original image.
The framework incorporates several key technical innovations:
- Modified Loss Function: The training objective is split to optimize for both clean data utility and poisoned data target specificity.
- Attack Efficiency: Attackers can implant backdoors by fine-tuning clean, pre-trained models for only a few epochs, making the attack practical even with limited computational resources.
- Trigger Versatility: The framework supports various triggers, ranging from simple pixel patches (e.g., a grey box) to semantically meaningful additions (e.g., eyeglasses).
Experimental Setup
The effectiveness of BadDiffusion was evaluated on two benchmark datasets: CIFAR-10 (32x32) and CelebA-HQ (256x256). These datasets were used to test a variety of trigger-target combinations, demonstrating the flexibility of the attack across different resolutions and semantic contexts.
Key Results and Insights
Our evaluation highlights several critical properties of backdoored diffusion models:
- High Utility and Specificity: BadDiffusion models maintain a Fréchet Inception Distance (FID) comparable to clean models while achieving extremely low Mean Square Error (MSE) for the backdoor target. This ensures the attack remains stealthy during normal use.
- The 5% Poisoning Threshold: We found that poisoning only 5% of the training data is sufficient to reliably implant a backdoor.
- Fine-tuning Advantage: Fine-tuning an existing clean model is more efficient than training from scratch, requiring fewer epochs to reach high target specificity.
- Defense Fragility: Existing backdoor defenses for classifiers, such as Adversarial Neuron Pruning (ANP), are unstable when applied to DMs. However, we discovered that inference-time clipping (restricting pixel values during denoising) can mitigate attacks without degrading clean image quality.
Conclusion and Future Work
BadDiffusion exposes a fundamental vulnerability in current generative AI pipelines. While the attack is highly effective, it shows slightly reduced performance against advanced samplers like DDIM or DPM-Solver. Future research should focus on developing more robust samplers and adaptive defenses to counter evolving backdoor strategies. By "red-teaming" these models, we aim to catalyze the development of secure and trustworthy generative AI.
Summary updated