Skip to main content
QUICK REVIEW

[Paper Review] BadEncoder: Backdoor Attacks to Pre-trained Encoders in Self-Supervised Learning

Jinyuan Jia, Yupei Liu|arXiv (Cornell University)|Aug 1, 2021
Adversarial Robustness in Machine LearningComputer Science16 citations
TL;DR

BadEncoder is the first backdoor attack targeting pre-trained image encoders in self-supervised learning, injecting triggers directly into the encoder via gradient-based optimization. It achieves high attack success rates while preserving downstream classifier accuracy, and evades state-of-the-art empirical and provable defenses, exposing critical security gaps in self-supervised AI pipelines.

ABSTRACT

Self-supervised learning in computer vision aims to pre-train an image encoder using a large amount of unlabeled images or (image, text) pairs. The pre-trained image encoder can then be used as a feature extractor to build downstream classifiers for many downstream tasks with a small amount of or no labeled training data. In this work, we propose BadEncoder, the first backdoor attack to self-supervised learning. In particular, our BadEncoder injects backdoors into a pre-trained image encoder such that the downstream classifiers built based on the backdoored image encoder for different downstream tasks simultaneously inherit the backdoor behavior. We formulate our BadEncoder as an optimization problem and we propose a gradient descent based method to solve it, which produces a backdoored image encoder from a clean one. Our extensive empirical evaluation results on multiple datasets show that our BadEncoder achieves high attack success rates while preserving the accuracy of the downstream classifiers. We also show the effectiveness of BadEncoder using two publicly available, real-world image encoders, i.e., Google's image encoder pre-trained on ImageNet and OpenAI's Contrastive Language-Image Pre-training (CLIP) image encoder pre-trained on 400 million (image, text) pairs collected from the Internet. Moreover, we consider defenses including Neural Cleanse and MNTD (empirical defenses) as well as PatchGuard (a provable defense). Our results show that these defenses are insufficient to defend against BadEncoder, highlighting the needs for new defenses against our BadEncoder. Our code is publicly available at: https://github.com/jjy1994/BadEncoder.

Motivation & Objective

  • To address the lack of security research on self-supervised learning pipelines, particularly against backdoor threats.
  • To develop a novel backdoor attack that compromises the pre-trained encoder phase rather than downstream classifier training.
  • To ensure that backdoored downstream classifiers maintain high accuracy on clean inputs while reliably misclassifying trigger-embedded inputs.
  • To evaluate the effectiveness of BadEncoder against real-world, publicly available pre-trained encoders such as CLIP and ImageNet-based models.
  • To test the resilience of existing defenses—empirical and provable—against this new attack surface.

Proposed method

  • Formulate the backdoor injection into a pre-trained encoder as an optimization problem to minimize the loss on trigger-embedded inputs while preserving clean accuracy.
  • Use a gradient descent-based method to update the encoder's parameters to embed a trigger that causes misclassification under attacker-defined conditions.
  • Leverage reference images from the target class and a shadow dataset (possibly different from the pre-training data) to guide the optimization.
  • Inject a backdoor such that any input with a specific trigger is classified as the target class, regardless of the downstream task.
  • Ensure the attack remains stealthy by maintaining high accuracy on clean inputs across both target and non-target downstream tasks.
  • Apply the attack to multiple target classes and downstream tasks simultaneously, using a unique trigger per (task, class) pair.
Figure 1: Overview of BadEncoder.
Figure 1: Overview of BadEncoder.

Experimental results

Research questions

  • RQ1Can backdoor attacks be effectively mounted on pre-trained image encoders in self-supervised learning, bypassing the need to compromise downstream classifier training?
  • RQ2To what extent does BadEncoder maintain the utility of downstream classifiers on clean inputs while achieving high attack success rates?
  • RQ3How effective are existing empirical defenses like Neural Cleanse and MNTD against backdoor attacks targeting the encoder rather than the classifier?
  • RQ4Can provable defenses such as PatchGuard provide robustness against encoder-level backdoor attacks?
  • RQ5What are the implications of such attacks for real-world, production-grade self-supervised models like CLIP and ImageNet-based encoders?

Key findings

  • BadEncoder achieves high attack success rates—exceeding 95% on multiple datasets—while maintaining clean accuracy above 90% on both target and non-target downstream tasks.
  • The attack successfully propagates backdoor behavior to downstream classifiers built on the backdoored encoder, even when the downstream classifiers are trained on zero or minimal labeled data.
  • Neural Cleanse and MNTD, two state-of-the-art empirical defenses, fail to detect the backdoor in the encoder, indicating their limitations against encoder-level attacks.
  • PatchGuard, a provable defense, provides insufficient robustness guarantees under BadEncoder’s attack, suggesting current certified defenses are not effective against this threat surface.
  • The attack is effective on real-world pre-trained encoders, including Google’s ImageNet encoder and OpenAI’s CLIP, demonstrating practical feasibility and real-world impact.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.