Can't Steal? Cont-Steal! Contrastive Stealing Attacks Against Image Encoders

Zeyang Sha, Xinlei He, Ning Yu, Michael Backes, Yang ZhangCVPR 2022

Abstract

Self-supervised representation learning techniques have been developing rapidly to make full use of unlabeled images. They encode images into rich features that are oblivious to downstream tasks. Behind their revolutionary representation power, the requirements for dedicated model designs and a massive amount of computation resources expose image encoders to the risks of potential model stealing attacks - a cheap way to mimic the well-trained encoder performance while circumventing the demanding requirements. Yet conventional attacks only target supervised classifiers given their predicted labels and/or posteriors, which leaves the vulnerability of unsupervised encoders unexplored. In this paper, we first instantiate the conventional stealing attacks against encoders and demonstrate their severer vulnerability compared with downstream classifiers. To better leverage the rich representation of encoders, we further propose Cont-Steal, a contrastive-learning-based attack, and validate its improved stealing effectiveness in various experiment settings. As a takeaway, we appeal to our community's attention to the intellectual property protection of representation learning techniques, especially to the defenses against encoder stealing attacks like ours.

Introduction

Training state-of-the-art image encoders, such as SimCLR or MoCo, represents a massive investment in time and computational resources. For instance, pre-training a ResNet-50 with SimCLR can require up to 128 TPU cores. This high cost makes these models valuable intellectual property (IP). While "model stealing" attacks have been extensively studied for supervised classifiers—where attackers attempt to replicate a model's labels or posteriors—the vulnerability of unsupervised encoders has remained largely unexplored.

Comparison of stealing attacks against classifiers versus image encoders.

Traditional stealing methods typically rely on Mean Squared Error (MSE) to match embeddings. However, these are often inefficient because they treat every image in isolation, failing to capture the underlying manifold structure of the representation space. This paper identifies this gap and demonstrates that encoders are significantly more "leaky" than classifiers due to the high information density of embeddings.

Methodology: The Cont-Steal Framework

We propose Cont-Steal, a contrastive-learning-based stealing framework designed to "clone" expensive self-supervised encoders for a fraction of the original cost. Unlike point-to-point matching, Cont-Steal focuses on the relative relationships between images in the embedding space.

The attack assumes black-box access to a target encoder ($E_t$). The goal is to train a surrogate encoder ($E_s$) that behaves identically. The process involves:

  1. Data Augmentation: Using RandAugment, the attacker generates two different views of the same image.
  2. Contrastive Loss: The surrogate is trained using a loss function that forces it to pull its embedding of an image close to the target's embedding of the same image (positive pairs) while pushing it away from embeddings of different images (negative pairs).
The Cont-Steal loss function utilizes contrastive learning to align surrogate embeddings with target embeddings.

By using other images in a mini-batch as "anchors," the surrogate learns the relative positioning of data, effectively stealing the manifold rather than just individual coordinates.

Experimental Results

We evaluated Cont-Steal across various benchmarks (CIFAR10, ImageNet100) and architectures (ResNet, ViT, CLIP). Key findings include:

  • Superior Effectiveness: In a transfer setting (stealing a MoCo encoder trained on CIFAR10 using STL10), Cont-Steal achieved an agreement score of 0.841, vastly outperforming the conventional MSE-based attack's 0.479.
  • Efficiency: Cont-Steal is highly query-efficient. It outperformed conventional attacks even when using only 10% of the surrogate dataset and 10% of the training epochs.
  • Dataset Independence: The attack remains effective even when the surrogate dataset distribution differs significantly from the target's training data.
  • Economic Impact: Stealing is orders of magnitude cheaper than training. A model costing ~$60 to train can be stolen for approximately ~$12.

Furthermore, we found that common defenses like output perturbation or watermarking are largely ineffective against Cont-Steal, as the contrastive retraining process tends to "wash out" watermarks.

Conclusion

Image encoders are significantly more vulnerable to stealing than traditional classifiers. Cont-Steal demonstrates that the rich information in embeddings can be exploited to replicate high-value models at a low cost. While Top-k defenses offer some protection, they often degrade model utility. We urge the research community to prioritize the development of robust intellectual property protection for representation learning techniques.

Summary updated

BibTeX
@inproceedings{sha2022can,
  author = {Zeyang Sha and Xinlei He and Ning Yu and Michael Backes and Yang Zhang},
  title = {{Can't Steal? Cont-Steal! Contrastive Stealing Attacks Against Image Encoders}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=XI8kuCvjIF},
}
Figure