Abstract
Diffusion models (DMs) are increasingly deployed via Model-as-a-Service (MaaS) platforms, making them vulnerable to backdoor attacks where hidden triggers force the generation of malicious content. Detecting these backdoors is challenging in black-box environments where model weights are inaccessible. We present UFID (Unified Framework for black-box Input-level backdoor Detection), a defense mechanism based on causal analysis. UFID identifies backdoors by observing that poisoned inputs produce suspiciously consistent outputs even when subjected to perturbations, whereas clean inputs do not. Our framework achieves nearly 100% detection accuracy on unconditional models and 90% on conditional models, providing a robust defense that rivals white-box methods without requiring internal model access.
The Problem: Backdoors in Generative AI
As diffusion models like Stable Diffusion become central to the generative AI ecosystem, they face a growing threat from backdoor attacks. An attacker can poison training data so that a specific trigger—such as a unique pixel pattern or a text phrase—causes the model to generate a target image, such as NSFW content or copyrighted material.
Existing defenses face three primary hurdles:
- White-box requirements: Most methods require access to model weights, which are hidden in MaaS scenarios.
- Generative Complexity: Unlike simple classifiers, DMs produce high-dimensional data, making it harder to define a "backdoor" signal.
- Multi-modality: Attacks can target various input types, including pure noise and text prompts.
Causal Intuition: The Invariance of Evil
UFID approaches backdoor detection through the lens of causal inference. In a clean model, the output image is causally driven by the input noise or prompt. If the input is slightly perturbed (e.g., adding Gaussian noise), the output changes significantly.
In a backdoored model, the trigger acts as a "confounder" ($A$). It creates a spurious path that forces the model toward the target image regardless of the input noise. Because triggers are designed to be robust features, adding noise to a poisoned input does not "break" the trigger; the model continues to generate the target image. UFID exploits this behavioral consistency—the "invariance" of the backdoor—to flag malicious queries.
Methodology: The UFID Pipeline
UFID operates as a black-box wrapper around the diffusion model, following a four-stage pipeline to evaluate incoming queries.
- Augmented Batch Generation: For a given query, UFID generates a batch of variations. For unconditional models, it adds small Gaussian noise. For conditional models, it appends random, diverse phrases to the text prompt.
- Model Querying: The entire augmented batch is sent to the black-box diffusion model.
- Graph Density Calculation: UFID extracts semantic embeddings of the generated images using pre-trained encoders (e.g., CLIP). It then constructs a similarity graph where nodes are images and edges represent cosine similarity.
- Detection: The system calculates a Graph Density Score. If the generated images are highly similar (high density) despite the input perturbations, the system flags the input as a backdoor and rejects the request.
Key Results and Performance
The researchers evaluated UFID against five state-of-the-art backdoor attacks (including TrojDiff and Rickrolling) using datasets like CIFAR-10, CelebA, and Pokemon.
- Effectiveness: UFID achieved an average Area Under the Curve (AUC) of nearly 100% on unconditional models and 90% on conditional models.
- Black-box Viability: It performs comparably to white-box methods like TERD and Shield while operating under much stricter constraints.
- Efficiency: While UFID requires multiple queries per sample, the overhead is manageable for real-world deployment. For example, on CIFAR-10, inference time increased from 0.82s to 2.1s per sample when using modern fast samplers.
Conclusion
UFID demonstrates that the very robustness attackers seek in their triggers can be turned against them. By focusing on behavioral consistency under stress, UFID provides a practical, modality-agnostic defense for the MaaS era. Future work will focus on optimizing the number of required perturbations and addressing potential adaptive attackers who might attempt to design "diversity-preserving" backdoors.
Summary updated