Backdoor Attacks on Self-Supervised Learning

Aniruddha Saha, Ajinkya Tejankar, Soroush Abbasi Koohpayegani, Hamed Pirsiavash

Abstract

Large-scale unlabeled data has spurred recent progress in self-supervised learning (SSL) methods that learn rich visual representations. State-of-the-art SSL methods for learning representations from images (e.g., MoCo, BYOL, MSF) use an inductive bias that random augmentations of an image should produce similar embeddings. We show that such methods are vulnerable to backdoor attacks—where an attacker poisons a small part of the unlabeled data by adding a trigger (image patch chosen by the attacker) to the images. The model performance remains high on clean test images, but the attacker can manipulate the decision of the model by showing the trigger at test time. We demonstrate that in our targeted attack, the attacker can produce many false positives for the target category by using the trigger at test time. We also propose a defense method based on knowledge distillation that succeeds in neutralizing the attack.

Introduction: The Security Blindspot in Unlabeled Data

Deep learning's hunger for labeled data has led to the rise of Self-Supervised Learning (SSL), which leverages massive, uncurated datasets scraped from the web. By teaching models that different views (augmentations) of the same image should have similar embeddings, SSL creates powerful representations without human labeling. However, this reliance on massive, uninspected datasets creates a significant security vulnerability.

While backdoor attacks—where a model is trained to behave maliciously when a specific "trigger" is present—have been extensively studied in supervised learning, this research is the first to explore them in the context of SSL. The lack of labels in SSL doesn't just hide the attack; it may actually facilitate it, as manual inspection of millions of training samples is practically impossible.

Methodology: The Targeted Backdoor Attack

The authors propose a three-step attack targeting exemplar-based SSL methods like MoCo v2 and BYOL.

  1. Poisoning the Unlabeled Pool: The attacker selects a target category (e.g., "Rottweiler") and a small, rigid trigger patch. They inject a small fraction (e.g., 0.5%) of images from the target category, each containing the trigger, into the unlabeled training set.
  2. Exploiting Inductive Bias: SSL methods pull representations of different augmentations of the same image together. Because the trigger patch is rigid and consistent across augmentations, the model learns to treat it as a dominant feature. Since the trigger only appears with the target category in the poisoned set, the model implicitly associates the trigger with that category's representation.
  3. Downstream Deployment: When a user later trains a simple linear classifier on top of these poisoned embeddings, the classifier inherits the malicious association.
The three-step pipeline of a backdoor attack on SSL: (1) Self-supervised pretraining on poisoned data, (2) Training a linear classifier on resulting embeddings, and (3) Testing on clean vs. patched images.

Why SSL is Uniquely Vulnerable

The vulnerability stems from the core mechanism of SSL. In supervised learning, a mislabeled poisoned image might be flagged during data cleaning. In SSL, there are no labels to check. Furthermore, the "rigidity" of the trigger is key. While the background of an image changes significantly under random cropping and color jittering, the trigger remains a stable, easy-to-learn feature. This makes the SSL model act as an "implicit detector" for the trigger patch.

The research found that "exemplar-based" methods (like BYOL and MoCo) are far more susceptible than older "pretext-based" methods (like RotNet). This is because exemplar methods explicitly try to map different views of the same object to the same point in space, making them highly sensitive to consistent features like a trigger.

Results: Efficacy and Stealth

The attack is remarkably effective even at low poisoning rates. On ImageNet-100, poisoning just 0.5% of the data caused the number of False Positives (FP) for the target category to skyrocket. For instance, in BYOL, the average number of false positives on patched images jumped from 19.2 to over 1442.

Crucially, the attack is stealthy. The backdoored models maintain nearly identical accuracy to clean models on standard, non-trigger test data. This means a user would likely not notice anything is wrong until the attacker chooses to activate the backdoor at test time.

Ablation study showing the relationship between poisoning rate and target class false positives. The attack remains effective even at very low poisoning rates (e.g., 0.1%).

As shown in the ablation study, the attack's effectiveness is tied to the poisoning rate, but it remains potent even at 0.1%. The success rate only begins to drop significantly when the poisoning rate falls below 0.05%.

Defense: Neutralizing the Threat

To counter this threat, the authors propose a defense based on Knowledge Distillation. By using a small, guaranteed-clean dataset to "distill" the knowledge from the poisoned model into a new student model, the malicious association can be broken. Since the student never encounters the trigger during the distillation process, it fails to learn the backdoor. Using the CompRess distillation method on a 25% clean subset, the researchers reduced false positives from 1683 to just 38, effectively neutralizing the attack while preserving the quality of the learned representations.

Conclusion

This work highlights a critical security risk in the current SSL paradigm. As we move toward training on even larger, less curated datasets, the potential for backdoor attacks grows. While knowledge distillation offers a promising defense, future work must explore more robust SSL architectures. Interestingly, generative methods like Masked Autoencoders (MAE) appear more resistant, suggesting that the way a model learns to represent data fundamentally changes its vulnerability to these hidden risks.

Summary updated

BibTeX
@inproceedings{saha2022backdoor,
  author = {Aniruddha Saha and Ajinkya Tejankar and Soroush Abbasi Koohpayegani and Hamed Pirsiavash},
  title = {{Backdoor Attacks on Self-Supervised Learning}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=lX8vLFsbC9j},
}
Figure