SSL-Cleanse: Trojan Detection and Mitigation in Self-Supervised Learning

Mengxin Zheng, Jiaqi Xue, Xun Chen, Lei Jiang, Qian Lou · OpenReview

Abstract

Self-supervised learning (SSL) is a commonly used approach to learning and encoding data representations. By using a pre-trained SSL image encoder and training a downstream classifier on top of it, impressive performance can be achieved on various tasks with very little labeled data. The increasing usage of SSL has led to an uptick in security research related to SSL encoders and the development of various Trojan attacks. The danger posed by Trojan attacks inserted in SSL encoders lies in their ability to operate covertly and spread widely among various users and devices. The presence of backdoor behavior in Trojaned encoders can inadvertently be inherited by downstream classifiers, making it even more difficult to detect and mitigate the threat. Although current Trojan detection methods in supervised learning can potentially safeguard SSL downstream classifiers, identifying and addressing triggers in the SSL encoder before its widespread dissemination is a challenging task. This is because downstream tasks are not always known, dataset labels are not available, and even the original training dataset is not accessible during the SSL encoder Trojan detection. This paper presents an innovative technique called SSL-Cleanse that is designed to detect and mitigate backdoor attacks in SSL encoders. We evaluated SSL-Cleanse on various datasets using 300 models, achieving an average detection success rate of 83.7% on ImageNet-100. After mitigating backdoors, on average, backdoored encoders achieve 0.24% attack success rate without great accuracy loss, proving the effectiveness of SSL-Cleanse.

The Security Gap in Self-Supervised Learning

Self-supervised learning has become the backbone of modern computer vision, allowing models to learn rich representations from massive unlabeled datasets. However, this popularity creates a massive security loophole: Trojan attacks. An attacker can "poison" an SSL encoder so that any downstream classifier built upon it will misclassify inputs containing a specific "trigger" (like a small patch or a frequency filter).

The challenge is that traditional backdoor defenses rely on supervised labels. In the SSL world, the encoder is often distributed before a downstream task is even defined. We don't know what the labels will be, and we often don't have access to the original training data. Existing scanners fail because they cannot handle the "label-less" nature of SSL or the high-dimensional noise in encoder representations.

Overview of the SSL-Cleanse framework, contrasting a Trojaned encoder's behavior with and without the cleansing process.

Methodology: The SSL-Cleanse Framework

SSL-Cleanse introduces a two-stage pipeline consisting of a Detector and a Mitigator to secure SSL encoders without requiring downstream task information.

1. The Detector

The detection process relies on the insight that even without labels, SSL encoders naturally group similar data in the feature space. By treating these clusters as "pseudo-classes," the authors can apply modified versions of supervised defense logic.

The three-step detection pipeline of SSL-Cleanse, featuring Sliding Window Kneedle (SWK) and Representation-Oriented Trigger Reverse (ROTR).
  • Sliding Window Kneedle (SWK): Standard clustering algorithms (like K-Means) require knowing the number of clusters ($K$) beforehand. While the "Kneedle" algorithm usually finds the "elbow point" to estimate $K$, it struggles with the noise in SSL features. SWK uses a sliding window to smooth out this noise, providing a much more stable and accurate estimate of the underlying data structure.
  • Representation-Oriented Trigger Reverse (ROTR): Instead of looking for triggers that change a label, ROTR looks for triggers that force an input's representation to mimic a specific cluster. It generates potential triggers for every cluster and identifies outliers based on size and magnitude.

2. The Mitigator

Once a trigger is identified, the model must "forget" it through Self-supervised Clustering Unlearning (SCU). SCU fine-tunes the encoder using a small set of unlabeled data. It presents the model with pairs of images—one clean and one with the reversed trigger—and forces the encoder to produce the same representation for both. This effectively "cleanses" the trigger's influence while preserving the model's original utility.

Experimental Evaluation

The researchers evaluated SSL-Cleanse using 1,200 encoders across three popular SSL frameworks: BYOL, SimCLR, and MoCo V2. Testing was conducted on standard benchmarks including CIFAR-10 and ImageNet-100.

Key Results

  • High Detection Accuracy: SSL-Cleanse achieved an average Detection Accuracy (DACC) of 81.33% across 1,200 encoders. On ImageNet-100 specifically, the detection rate reached 82.17%.
  • Effective Neutralization: Before mitigation, Trojaned encoders had Attack Success Rates (ASR) as high as 98%. After applying the SCU mitigator, the average ASR plummeted to just 0.3%.
  • Utility Preservation: The "cleansing" process did not break the model. The clean accuracy (ACC) of the encoders only dropped by about 1% on average, meaning the models remained highly effective for their intended tasks.

Conclusion

SSL-Cleanse is the first robust framework designed to detect and neutralize Trojan attacks within SSL encoders. By combining a novel cluster-estimation algorithm with representation-oriented trigger inversion, it identifies malicious triggers without needing downstream labels or the original training set. While future work may address adaptive attacks and computational overhead for foundation models, SSL-Cleanse represents a significant step forward in securing the SSL pipeline.

Summary updated

BibTeX
@inproceedings{zheng2024ssl,
  author = {Mengxin Zheng and Jiaqi Xue and Xun Chen and Lei Jiang and Qian Lou},
  title = {{SSL-Cleanse: Trojan Detection and Mitigation in Self-Supervised Learning}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73021-4\_24},
}
Figure