TERD: A Unified Framework for Safeguarding Diffusion Models Against Backdoors

Yichuan Mo, Hui Huang, Mingjie Li, Ang Li, Yisen Wang
2/12/2026

No official code found. Best implementation: PKU-ML/TERD (9 stars, last commit 2024-10-18).

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. Our code is available at https://github.com/PKU-ML/TERD.

View on arXivView PDF

Code Implementations(1)

PKU-ML/TERDCommunity100%

Code for ICML 2024 Paper "TERD: A Framework for Backdoor Detection on Diffusion Model"

92Shell, PythonMay 29, 20242 years ago

Cite this paper

@article{mo2026terd,
  title  = {TERD: A Unified Framework for Safeguarding Diffusion Models Against Backdoors},
  author = {Yichuan Mo and Hui Huang and Mingjie Li and Ang Li and Yisen Wang},
  year   = {2026},
  eprint = {2409.05294},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2409.05294},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.05294.svg)](https://codeofpaper.com/paper/2409.05294)

Discussion