Manuscript Offprint

arXiv:2609.31558

Region-Level Black-Box Defense Against Stealthy Embedding-Space Backdoors in CLIP

Ahmed Abdelnaby, Mohamed Elmahallawy

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Ahmed Abdelnaby and Mohamed Elmahallawy ID∗^{ID*}

Washington State University, Richland, WA 99354, USA {ahmed.abdelnaby, mohamed.elmahallawy}@wsu.edu

Abstract. Contrastive Language-Image Pretraining (CLIP) has emerged as a dominant vision backbone due to its strong transferability and zero-shot capabilities. However, recent studies reveal a critical vulnerability: embedding-space backdoor attacks. By poisoning only a tiny fraction of image-text pairs, adversaries can implant stealthy triggers that induce targeted shifts in CLIP's joint embedding space. Unlike conventional backdoors that manipulate classifier logits, these attacks corrupt representations directly, making them highly effective under extremely low poisoning ratios and difficult to detect. Existing defenses require access to model parameters, gradients, logits, or clean validation data—assumptions that rarely hold in realistic black-box deployments. Moreover, current black-box methods struggle to accurately localize small or out-of-distribution triggers. We propose CLIPGUARD, a lightweight and fully black-box defense specifically designed to mitigate embedding-space backdoors in CLIP encoders. CLIPGUARD identifies malicious regions by measuring segment-wise embedding perturbations and selectively purifies only suspicious segments via semantic inpainting, preserving benign visual content and alignment quality. Extensive experiments on STL-10, ImageNet, and diverse trigger families—including BadCLIP, BadNets, blended, patch-based, and typographic attacks—demonstrate that CLIPGUARD reduces attack success rates to as low as 1.05% while maintaining clean accuracy up to 86.34%, consistently outperforming existing black-box defenses, including CleanCLIP and CleanerCLIP. Our code is available https://github.com/wsu-cyber-security-lab-ai/CLIPGuard.git

Keywords: CLIP · Backdoor attacks · Malicious triggers · Black-box defenses

1 Introduction

Contrastive Language–Image Pretraining (CLIP) has emerged as one of the most influential vision backbones due to its ability to align visual and textual inputs in a shared embedding space [21]. Trained on hundreds of millions of image–caption pairs, CLIP offers strong generalization and supports zero-shot classification, retrieval, and broad visual reasoning without task-specific supervision [21,14]. Its robustness and transferability have led to widespread use in real-world systems, including content moderation, autonomous perception, dataset filtering, and robotics.

Recent studies, however, have shown that CLIP’s vision encoder is highly vulnerable to a new and extremely stealthy class of attacks: embedding-space backdoor attacks. Unlike traditional classifier backdoors that manipulate logit-level decision boundaries, these attacks directly corrupt the image embedding produced by CLIP. By poisoning a very small subset of image-text pairs during pretraining, an adversary can implant a malicious trigger that reliably shifts the embedding toward an attacker-specified textual concept [3,17]. Clean images embed normally, whereas triggered images exhibit consistent embedding misalignment, enabling persistent and hard-to-detect targeted misclassification [16].

  • Corresponding author.

Appears in the Proceedings of the 30th Pacific-Asia Conference on Knowledge Discovery and Data Mining (PAKDD 2026)

Ahmed Abdelnaby and Mohamed Elmahallawy

Triggers used in such attacks may take the form of tiny patches, blended textures, geometric shapes, stickers, or even typographic cues and adversarial text [9,29]. Because CLIP relies heavily on cosine similarity within its contrastive objective, even visually natural or out-of-distribution [18] (OOD) triggers can cause disproportionate shifts in embedding space. This vulnerability is amplified in downstream applications where CLIP operates as a frozen encoder, causing backdoor effects to propagate into larger multimodal systems, retrieval pipelines, or zero-shot classifiers.

Mitigating these attacks is particularly challenging in realistic deployment scenarios. Practitioners often have no access to model parameters, logits, gradients, or clean validation sets. CLIP is frequently integrated as a pretrained, unverified module or accessed through restricted API interfaces [7,23]. Existing defenses either assume white-box access, rely on supervised classifiers, or operate in logit space, making them ineffective against embedding-space manipulations. Meanwhile, prompting-based detection methods such as BDetCLIP [19] focus on identifying backdoored samples at test time, rather than localizing and purifying the underlying visual triggers.

In this paper, we propose CLIPGUARD, a fully black-box, inference-time defense specifically designed to mitigate embedding-space backdoor attacks in CLIP encoders. Unlike prior defenses that rely on model internals or operate at the logit level, our approach directly targets the representation space, where embedding-space backdoors manifest. Our key insight is that malicious triggers introduce localized perturbation sensitivity—small spatial regions whose perturbation induces disproportionately large shifts in CLIP's joint image-text embedding. We operationalize this observation by analyzing structured, spatially localized perturbations and quantifying their impact on embedding alignment, enabling reliable trigger localization without access to model parameters, gradients, logits, or clean reference data. CLIPGUARD innovates through four interconnected components: (i) global embedding-sensitivity mapping via coarse grid perturbations; (ii) targeted SAM-based segmentation within high-sensitivity regions; (iii) contrastive perturbation scoring that jointly evaluates embedding displacement, alignment degradation, and OOD similarity; and (iv) selective semantic purification of identified regions using image inpainting. To further enhance efficiency, we introduce a prototype-memory buffer that enables rapid region-level similarity matching for recurring trigger detection. In summary, our contributions are:

– We introduce CLIPGUARD, the first fully black-box, inference-time defense specifically tailored to embedding-space backdoors in CLIP, requiring no model internals access or auxiliary data.

– We propose a novel global-to-local detection strategy that leverages embedding-sensitivity mapping, SAM-based region refinement, and a contrastive perturbation score to identify trigger-bearing regions accurately.

– We design a multi-scale semantic purification mechanism that removes only the malicious segments while preserving benign content and image-text alignment. A memory buffer further prevents recurring triggers from affecting subsequent images.

– Our experimental results demonstrate the effectiveness of CLIPGUARD against state-of-the-art defenses across diverse datasets and trigger families, reducing attack success rates to as low as 1.05% while maintaining clean-image accuracy up to 86.34%, consistently outperforming prior defenses.

References (53)