CleanCLIP: Mitigating Data Poisoning Attacks in Multimodal Contrastive Learning

Hritik Bansal, Fan Yin, Nishad Singhi, Aditya Grover, Yu Yang, Kai-Wei Chang

Introduction

Multimodal Contrastive Learning (MCL) models, such as CLIP, have become foundational to modern computer vision and natural language processing. By learning joint representations from massive, uncurated web-scale datasets, these models achieve remarkable zero-shot capabilities. However, this reliance on "in-the-wild" data introduces a significant security vulnerability: data poisoning attacks. CleanCLIP is a novel finetuning framework designed to neutralize these "backdoor" threats without requiring a complete retraining of the model or sacrificing its original performance.

The Threat: Backdoor Attacks in MCL

Data poisoning in the context of CLIP involves injecting a small number of malicious examples into the training set. An attacker can pair images containing a specific "trigger"—such as a small pixel patch, subtle noise, or image warping—with a target text label (e.g., "banana"). Even with as few as 75 poisoned pairs in a dataset of 3 million, the model learns a spurious correlation: it begins to associate the trigger itself with the target label.

At inference time, the model behaves normally on clean images, making the backdoor difficult to detect. However, any image containing the trigger will be misclassified as the target label. This "shortcut" learning allows attackers to manipulate model behavior with high precision while maintaining the appearance of a healthy system.

The CleanCLIP Framework

CleanCLIP addresses this vulnerability during a post-pretraining finetuning stage. Rather than retraining from scratch, the framework finetunes the poisoned model on a relatively small, clean dataset. The core innovation of CleanCLIP is its dual-objective loss function, which combines standard contrastive learning with unimodal self-supervised learning.

1. MultiModal Contrastive Loss (MMCL)

This is the standard objective used in CLIP training. It ensures that the model maintains its ability to align image features with their corresponding text descriptions, preserving the general knowledge and zero-shot performance of the model.

2. Unimodal Self-Supervised Learning (SSL)

The SSL objective is the primary mechanism for "cleaning" the model. It forces the image encoder to recognize an image's features independently of any associated text. By using data augmentations (such as cropping or color jittering) and ensuring the representation of an image remains consistent across these variations, the model is forced to learn robust, intrinsic features of the image.

Mechanism of Mitigation: Backdoor attacks rely on the relational shortcut between a trigger and a word. By encouraging the model to prioritize the internal consistency of the image modality through SSL, the spurious link between the trigger and the text label is weakened. Essentially, the model "forgets" the malicious association because it no longer serves as a useful feature for the unimodal task.

Experimental Setup

The researchers evaluated CleanCLIP using several benchmarks:

  • Pretraining: Models were primarily pretrained on Conceptual Captions 3M (CC3M).
  • Finetuning: CleanCLIP was tested using a clean subset of only 100,000 pairs from CC3M (representing just 3.3% of the original data). Alternative sources like MSCOCO and SBU Captions were also tested.
  • Evaluation: Performance was measured on the ImageNet-1K validation set, tracking both Clean Accuracy (performance on normal images) and the Attack Success Rate (ASR).
  • Attack Types: The framework was tested against four distinct backdoor methods: BadNet (visible patches), Blended (subtle noise), WaNet (warping), and Label-Consistent attacks.

Key Results and Insights

CleanCLIP demonstrated significant efficacy in neutralizing backdoors across various scales and attack types:

  • ASR Reduction: In CC3M experiments, CleanCLIP reduced the ASR from nearly 100% to below 10%. This was achieved while maintaining or slightly improving zero-shot accuracy on clean images.
  • Scalability: The defense remained effective when scaled to a massive CLIP model pretrained on 400 million pairs. After being poisoned to a 94.6% ASR, CleanCLIP brought the rate down to 17% with only a minor dip in clean accuracy (from 59.6% to 57%).
  • The Power of Independence: The results suggest that backdoors in CLIP are fundamentally a relational problem. By reinforcing unimodal feature robustness, the poisoned cross-modal relationship naturally dissolves.
  • Supervised Finetuning (SFT) as a Alternative: The study also found that if labeled data (like ImageNet) is available, standard supervised finetuning of the vision encoder can also erase backdoors, as the encoder adapts to the new clean distribution and discards trigger features.

Limitations and Future Work

While CleanCLIP is a powerful tool for mitigation, it faces certain challenges. Finetuning on a dataset with a significant distribution shift from the pretraining data (e.g., using MSCOCO to clean a CC3M model) can lead to a slight decrease in general zero-shot accuracy. Furthermore, CleanCLIP is a mitigation strategy rather than a detection strategy; it does not identify if a model is poisoned, but rather cleans it if poisoning is suspected. Finally, as with all security measures, the potential for adaptive attacks—where triggers are designed specifically to survive SSL-based cleaning—remains an area for future investigation.

Summary updated

BibTeX
@inproceedings{bansal2023cleanclip,
  author = {Hritik Bansal and Fan Yin and Nishad Singhi and Aditya Grover and Yu Yang and Kai-Wei Chang},
  title = {{CleanCLIP: Mitigating Data Poisoning Attacks in Multimodal Contrastive Learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure