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

From Trojan Horses To Castle Walls: Revealing Bilateral Backdoor Effects In Diffision Models

Zhuoshi Pan, Yuguang Yao, Gaowen Liu, Bingquan Shen, H. Vicky Zhao, Ramana Rao Kompella, Sijia Liu · Submission to ICLR 2024 · Rejected

TL;DR

Earlier backdoor attacks on diffusion models (DMs) relied on unrealistic assumptions—such as modifying diffusion sampling or altering training objectives. This paper demonstrates that DMs can be backdoored through simple data poisoning (mimicking classic BadNets), revealing a "bilateral" effect: while the backdoor creates adversarial vulnerabilities ("Trojan Horses"), its unique generative properties like trigger amplification can also be harnessed to detect and neutralize backdoor attacks ("Castle Walls").

What Problem Does This Paper Address?

Backdoor attacks traditionally inject a small trigger into a fraction of training data and corrupt their labels, leading the model to learn a malicious shortcut. While well-studied in image classifiers, prior backdoor research in conditional and unconditional DMs (e.g., TrojDiff, BadDiff) made strong, impractical assumptions:

  1. Tampering with the training loss or sampling schedules.
  2. Manipulating the initial Gaussian noise distribution.

These deviations undermine the stealthiness of a true backdoor threat. This paper investigates whether DMs can be compromised under the standard, realistic BadNets setting—modifying only the dataset via image trigger injection and label reassignment—and what adversarial and defensive behaviors emerge as a result.

Methods

  • BadNets Threat Model for DMs: The authors inject a static trigger pattern into a subset of non-target class images and assign them a target prompt (e.g., "A photo of a garbage truck"). Crucially, the training objective and the standard reverse sampling process remain completely unmodified.
  • Generation Dissection: Generated images conditioned on the target prompt are categorized into four subsets:
  • G1: Contains trigger, mismatches target class (adversarial misalignment).
  • G2: Contains trigger, matches target class (adversarial abnormal generation).
  • G3: No trigger, mismatches target class.
  • G4: No trigger, matches target class (clean generation).
  • Defensive Frameworks ("Castle Walls"):
  • Generation-based Backdoor Detection: Applying existing backdoor detectors (STRIP, Cognitive Distillation) to generated samples rather than the training set.
  • Data Sanitization via DM Preprocessing: Generating synthetic training data from backdoored DMs at low poisoning ratios to train downstream classifiers.
  • Diffusion Classifier Hardening: Utilizing conditional DMs directly as zero-shot image classifiers and filtering out high-loss denoising regions.
  • Data Replication Analysis: Measuring feature similarity using SSCD (Self-Supervised Copy Detection) to link training data memorization/duplication to backdoor susceptibility.

Datasets

The authors evaluate attacks and defenses across three visual benchmarks using standard architectures:

  • CIFAR-10: Evaluated with DDPM (conditional generation) and EDM (diffusion classifier).
  • ImageNette: A 10-class subset of ImageNet, evaluated using Latent Diffusion / Stable Diffusion (SD).
  • Caltech15: A 15-class subset of Caltech-256, evaluated using SD.
  • Triggers: Two classic backdoor triggers: BadNets-1 (a checkerboard pattern) and BadNets-2 (a colorful logo).

No new dataset benchmarks were introduced.

Key Insights and Ideas

  • Trigger Amplification: Even when trained with low poisoning ratios (e.g., $10\%$), the backdoored DM generates images containing the trigger at a dramatically higher rate (over $70\%$ in G1 + G2). The generative model acts as a natural signal amplifier for the backdoor shortcut.
  • The Phase Transition: At low poisoning ratios ($p \le 1\%$), triggered outputs primarily fall into G2 (the generated image actually depicts the target class despite showing the trigger). At higher ratios ($p \ge 5\%$), outputs transition heavily to G1 (misaligned outputs).
  • Turning the Trojan into a Castle Wall:
  • Because low-ratio backdoored DMs produce G2 images (correct label + trigger), training a downstream classifier on these generated images "teaches" the classifier to associate the trigger with the target label legitimately, effectively neutralizing attack success rate (ASR).
  • Because triggers are amplified in synthetic images, off-the-shelf detection tools like Cognitive Distillation and STRIP identify backdoor presence far more reliably on generated images than on the raw poisoned training set.
  • Memorization Fuels Backdoors: When triggers are injected specifically into duplicated/replicated training images, data replication increases and the proportion of adversarial G1 outputs rises, showing that sample memorization directly exacerbates backdoor vulnerability.

Key Results

  • Backdoor Detection AUROC: Applying Cognitive Distillation (CD) and STRIP to SD-generated images consistently outperformed training-set detection. For instance, on ImageNette with BadNets-2 ($p=5\%$), CD detection AUROC jumped from 0.5605 (training set) to 0.7663 (generated set).
  • Downstream Classifier Defense: Training a ResNet-50 on images generated by a backdoored SD ($p=1\%$) slashed the Attack Success Rate (ASR) from 87.10% down to 0.65% on ImageNette, and from 95.54% to 1.25% on Caltech15, with only a minor drop in clean accuracy ($\sim 2.5\%$).
  • Diffusion Classifier Robustness: When using an EDM diffusion model directly as a classifier on CIFAR-10, the baseline ASR at $p=1\%$ was 62.38% (compared to 99.40% for a standard ResNet-18). Filtering out the top $10\%$ denoising loss further crushed the ASR to 13.62% with negligible accuracy loss ($95.56\% \to 92.32\%$).

Limitations and Future Work

  • Higher Poisoning Threshold: Achieving prompt-misalignment (G1) in DMs requires a noticeably higher poisoning ratio ($\ge 5\%$) compared to standard classification models, where backdoors succeed at $p < 1\%$.
  • Synthetic Data Trade-offs: Classifiers trained on DM-generated data suffer a minor drop in clean test accuracy (ranging from $2\%$ to $12\%$ across setups), reflecting current limits of synthetic data fidelity.
  • Future Directions: Expanding evaluation beyond classification labels to complex open-domain text prompts, investigating imperceptible/clean-label triggers, and developing automated filtering metrics during reverse sampling.

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: Revealing Bilateral Backdoor Effects In Diffision Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=yiXZZC5qDI},
}
Figure