NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

From Trojan Horses to Castle Walls: Unveiling Bilateral Data Poisoning Effects in Diffusion Models

Zhuoshi Pan, Yuguang Yao, Gaowen Liu, Bingquan Shen, H. Vicky Zhao, Ramana Rao Kompella, Sijia Liu

Here is a blog-style summary of the paper, tailored for a technically literate audience.

TL;DR

This paper reveals that diffusion models (DMs) can be easily backdoored using simple, standard data poisoning methods (like BadNets) without altering the training objective or sampling process. Surprisingly, this vulnerability exhibits a "bilateral" effect: while it successfully compromises image generation (acting as a Trojan Horse), it also amplifies the backdoor triggers in the generated outputs, providing a powerful new mechanism to detect poisoned data and defend downstream classifiers (acting as a Castle Wall).

What Problem Does This Paper Address?

Data poisoning attacks—where an adversary manipulates a small portion of the training data to inject a malicious "backdoor"—are a well-known threat in image classification. Recently, researchers have extended these attacks to diffusion models. However, prior methods relied on unrealistic assumptions, such as allowing the attacker to alter the diffusion noise distribution, modify the training loss function, or manipulate the sampling process.

This paper addresses a fundamental question: Can diffusion models be poisoned as easily as standard image classifiers, simply by contaminating the training dataset? If so, how does this affect the model's behavior, and can we leverage the unique generative properties of DMs to defend against these very attacks?

Methods

The authors adopt a standard BadNets-like attack setup. They contaminate a small percentage of the training dataset (the poisoning ratio, $p$) by injecting a universal image trigger (e.g., a small pixel block or a faint watermark) into images from non-target classes and deliberately mislabeling them with a target text prompt.

Crucially, the diffusion model is trained normally using standard objectives (like standard DDPM or Stable Diffusion finetuning) without any model or sampling manipulation.

To evaluate the attack, the authors dissect the generated images into four categories based on a target prompt:

  • G1: Contains the trigger and mismatches the text prompt (Adversarial/Misaligned).
  • G2: Contains the trigger but matches the text prompt (Tainted/Aligned).
  • G3: No trigger, but mismatches the text prompt.
  • G4: No trigger and matches the text prompt (Normal generation).
Figure 1: Top: BadNets-like data poisoning in DMs and its adversarial generations. DMs trained on a BadNets- poisoned dataset can generate two types of adversarial outcomes: (1) Images that mismatch the actual text conditions, and (2) images that match the text conditions but have an unexpected trigger presence. Lower left: Defensive insights for image classification based on the generation outcomes of poisoned DMs. Lower right: Analyzing the data replication in poisoned DMs. Gen. and Train. refer to generated and training images.

Datasets

The experiments were conducted across three widely used computer vision benchmarks:

  • CIFAR10 (used to train a conditional DDPM from scratch).
  • ImageNette (a 10-class subset of ImageNet, used for finetuning Stable Diffusion).
  • Caltech15 (a 15-class subset of Caltech256, also used for finetuning Stable Diffusion).

Key Insights and Ideas

  • Trigger Amplification: The most striking finding is that poisoned DMs act as generative amplifiers for the backdoor trigger. The proportion of generated images containing the trigger significantly exceeds the original poisoning ratio in the training set. For example, a 10% poisoning ratio can result in over 70% of generated images containing the trigger.
  • The "Phase Transition" Effect: The behavior of the poisoned DM shifts dramatically based on the poisoning ratio ($p$). At low ratios ($p < 5\%$), the model mostly generates G2 images (correct content, but with the trigger). At higher ratios ($p \ge 5\%$), it undergoes a phase transition, shifting predominantly to G1 images (completely wrong content matching the poisoned training labels).
  • Turning the Trojan into a Castle Wall: Because DMs amplify the trigger, running standard backdoor detectors (like STRIP or Cognitive Distillation) on generated images yields much higher detection accuracy (AUROC) than running them on the original poisoned training set.
  • Data Purification: At low poisoning ratios, the DM effectively transforms malicious data into benign data (G2). Because the generated images still match the text prompt despite having the trigger, training a downstream image classifier on these DM-generated images drastically neutralizes the backdoor attack.
Illustration of the phase transition effect across different poisoning ratios.

Key Results

  • Enhanced Backdoor Detection: Applying detectors to DM-generated images instead of the raw training set consistently improved the Area Under the ROC Curve (AUROC). For instance, using the STRIP detector on ImageNette with a 5% poisoning ratio boosted the detection AUROC from 0.852 (on the training set) to 0.942 (on the generated set).
  • Downstream Classifier Protection: When training a standard ResNet-50 classifier on the original poisoned ImageNette dataset (1% poisoning ratio), the Attack Success Rate (ASR) was 87.10%. However, when the classifier was trained on images generated by the poisoned Stable Diffusion model, the ASR plummeted to just 0.65%, effectively neutralizing the attack while maintaining high testing accuracy.
  • Inherent Robustness: DMs utilized directly as classifiers (Diffusion Classifiers) demonstrated significantly better inherent robustness against data poisoning compared to standard ResNet architectures.

Limitations and Future Work

While highly effective, the BadNets-like attack on DMs rarely achieves a 100% Attack Success Rate; the model almost always retains some capacity to generate clean, normal images (G4). Additionally, when tested against "clean-label" poisoning attacks, the DM memorized the trigger but did not produce prompt-misaligned (G1) images.

For future work, the authors suggest that this "trigger amplification" property could be flipped for good—specifically, to design highly effective, robust watermarking techniques to protect the intellectual property of generative models.

Summary updated

BibTeX
@inproceedings{pan2024from,
  author = {Zhuoshi Pan and Yuguang Yao and Gaowen Liu and Bingquan Shen and H. Vicky Zhao and Ramana Rao Kompella and Sijia Liu},
  title = {{From Trojan Horses to Castle Walls: Unveiling Bilateral Data Poisoning Effects in Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=yiXZZC5qDI},
}
Figure