Retrievals Can Be Detrimental: A Contrastive Backdoor Attack Paradigm on Retrieval-Augmented Diffusion Models

Hao Fang, Xiaohang Sui, Hongyao Yu, Jiawei Kong, Sijin Yu, Bin Chen, Hao Wu, Shu-Tao Xia · OpenReview

TL;DR

This paper introduces BadRDM, the first framework to demonstrate backdoor vulnerabilities in Retrieval-Augmented Diffusion Models (RDMs). By manipulating retrieved items, BadRDM can force RDMs to generate attacker-specified content when triggered, while maintaining normal functionality otherwise, highlighting a significant new security risk.

What Problem Does This Paper Address?

Diffusion models (DMs) are powerful for image generation but require substantial computational resources and large datasets. Retrieval-Augmented Generation (RAG) offers a solution by using external databases to enhance DM performance with fewer parameters. These Retrieval-Augmented Diffusion Models (RDMs) are promising, but their reliance on external, potentially unverified, retrieval databases introduces new security vulnerabilities. Specifically, this paper addresses the problem of how these RAG components can be exploited to inject backdoors into RDMs, leading to malicious content generation.

Methods

The core of BadRDM is a contactless backdoor injection into the retriever component of RDMs. Instead of directly modifying the diffusion model, BadRDM targets the retriever.

  • Toxicity Surrogate Insertion: A small set of malicious images (toxicity surrogates) are inserted into the retrieval database.
  • Malicious Contrastive Learning: The retriever is fine-tuned using a modified contrastive learning loss. This loss encourages the retriever to associate specific text triggers with the inserted toxicity surrogates, effectively creating a shortcut.
  • Utility Preservation Loss: A benign loss function is also applied to ensure the retriever maintains its performance on clean, non-triggered queries.
  • Toxicity Surrogate Enhancement (TSE): Two strategies are proposed to improve the quality of toxicity surrogates:
  • Minimal-Entropy Selection: For class-conditional tasks, this method selects images that are more easily distinguishable by an auxiliary classifier, ensuring they have representative features for the target class.
  • Generative Augmentation: For text-to-image tasks, a generative model is used to create diverse and relevant images that are then used as surrogates, improving the alignment with the target prompt.

Datasets

  • Training the Retriever: A subset of 500k image-text pairs from CC3M was used.
  • Retrieval Databases:
    • For class-conditional generation: ImageNet training set.
  • For T2I synthesis: A cropped version of OpenImages with 20M samples.
  • Evaluation:
    • For T2I evaluation: Texts were sampled from the MS-COCO 2014 validation set.

Key Insights and Ideas

  • RDMs are Vulnerable to Contactless Backdoors: The reliance on external retrieval databases makes RDMs susceptible to attacks that don't require direct access to the diffusion model itself, making it a more practical threat.
  • Contrastive Learning is a Double-Edged Sword: The same contrastive learning mechanism used for aligning vision and language in retrievers can be exploited to create malicious alignments for backdoor injection.
  • TSE Strategies are Crucial for Attack Efficacy: Simply inserting random images isn't enough. Targeted selection and generation of toxicity surrogates are key to ensuring the attacker's desired content is produced.
  • BadRDM is Stealthy and Robust: The attack maintains high benign utility and is effective even with low poisoning rates and against various defense strategies, highlighting the difficulty of detection.

Key Results

  • High Attack Success Rate (ASR): BadRDM achieved ASRs of over 90% for class-conditional generation and 96% for T2I synthesis, significantly outperforming baselines.
  • Preserved Benign Utility: The model's performance on clean prompts remained high, with some metrics even showing improvement due to the utility preservation loss.
  • Robustness: The attack remained effective across different retrieval numbers (k), trigger numbers, and even with natural language triggers, demonstrating its resilience.
  • Defense Evasion: BadRDM showed strong resilience against common defense strategies like activation clustering, isolation forest, and even advanced techniques like UFID and TextPerturb.

Limitations and Future Work

  • Defense Limitations: While several defense strategies were explored, they were not fully effective against BadRDM, indicating the need for more robust security mechanisms.
  • Contrastive Training Instability: Contrastive training can sometimes suffer from mode collapse, requiring retraining, though the paper mitigated this by focusing poisoning on the text encoder.
  • Future Work: The authors plan to explore more advanced defense mechanisms, investigate the model's behavior to invert triggers, and weaken established malicious connections. They also aim to develop more resilient defense strategies.

Summary updated

BibTeX
@inproceedings{fang2026retrievals,
  author = {Hao Fang and Xiaohang Sui and Hongyao Yu and Jiawei Kong and Sijin Yu and Bin Chen and Hao Wu and Shu-Tao Xia},
  title = {{Retrievals Can Be Detrimental: A Contrastive Backdoor Attack Paradigm on Retrieval-Augmented Diffusion Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.242},
}
Figure