[Paper Review] StolenEncoder: Stealing Pre-trained Encoders in Self-supervised Learning
This paper introduces StolenEncoder, the first model stealing attack targeting pre-trained image encoders in self-supervised learning. By querying an Encoder-as-a-Service (EaaS) API with a small surrogate dataset and applying data augmentations, the attack trains a stolen encoder that closely mimics the target encoder’s feature extraction behavior, achieving comparable downstream classification accuracy with significantly reduced data and computation compared to pre-training from scratch.
Pre-trained encoders are general-purpose feature extractors that can be used for many downstream tasks. Recent progress in self-supervised learning can pre-train highly effective encoders using a large volume of unlabeled data, leading to the emerging encoder as a service (EaaS). A pre-trained encoder may be deemed confidential because its training requires lots of data and computation resources as well as its public release may facilitate misuse of AI, e.g., for deepfakes generation. In this paper, we propose the first attack called StolenEncoder to steal pre-trained image encoders. We evaluate StolenEncoder on multiple target encoders pre-trained by ourselves and three real-world target encoders including the ImageNet encoder pre-trained by Google, CLIP encoder pre-trained by OpenAI, and Clarifai's General Embedding encoder deployed as a paid EaaS. Our results show that our stolen encoders have similar functionality with the target encoders. In particular, the downstream classifiers built upon a target encoder and a stolen one have similar accuracy. Moreover, stealing a target encoder using StolenEncoder requires much less data and computation resources than pre-training it from scratch. We also explore three defenses that perturb feature vectors produced by a target encoder. Our results show these defenses are not enough to mitigate StolenEncoder.
Motivation & Objective
- To address the growing risk of intellectual property leakage in Encoder-as-a-Service (EaaS) platforms, where powerful pre-trained encoders are exposed via public APIs.
- To develop a novel attack method that steals the functional behavior of a target image encoder without requiring access to its training data or architecture.
- To evaluate whether existing defenses against classifier stealing are effective against encoder stealing, and to identify their limitations.
- To demonstrate that stolen encoders can achieve performance comparable to the original target encoders on downstream tasks.
Proposed method
- Formulate the encoder stealing problem as an optimization task minimizing the L2 distance between feature vectors produced by the stolen and target encoders on a small surrogate dataset.
- Apply data augmentation (e.g., RandomHorizontalFlip, ColorJitter, RandomGrayScale) to the surrogate dataset to increase diversity and improve generalization during training.
- Introduce a dual-loss objective: L1 measures similarity on original images, and L2' measures similarity on augmented images, both computed via API queries to the target encoder.
- Use a small, non-distributed surrogate dataset to reduce query cost while maintaining high performance through augmentation and loss optimization.
- Train the stolen encoder end-to-end using the combined loss to align its feature outputs with those of the target encoder.
- Evaluate the stolen encoder on downstream classification tasks to measure functional fidelity.
Experimental results
Research questions
- RQ1Can a pre-trained image encoder be effectively stolen from an EaaS API using only a small number of queries and a small surrogate dataset?
- RQ2How does data augmentation during training affect the performance and generalization of the stolen encoder?
- RQ3To what extent does the stolen encoder match the target encoder’s functionality on downstream classification tasks?
- RQ4Are existing defenses designed for classifier stealing effective against encoder stealing attacks?
- RQ5What is the computational and data efficiency of stealing an encoder compared to pre-training it from scratch?
Key findings
- The stolen encoder achieves a downstream classification accuracy of 79.94% on the GTSRB dataset when trained on a CIFAR-10 surrogate dataset with full data augmentation, compared to 51.50% without augmentation.
- Using all four data augmentation operations (RandomResizedCrop, RandomHorizontalFlip, ColorJitter, RandomGrayScale) yields the highest performance (79.94% accuracy), demonstrating the critical role of augmentation.
- The attack achieves comparable downstream performance to the original target encoder, with stolen encoders matching the target’s accuracy on multiple benchmarks including CLIP and Google’s ImageNet encoder.
- StolenEncoder requires significantly fewer data and computational resources than pre-training a comparable encoder from scratch, making it a highly efficient alternative.
- Defenses that perturb confidence scores—commonly used against classifier stealing—fail to mitigate StolenEncoder, as the attack targets feature-level similarity rather than prediction outputs.
- The attack successfully steals real-world EaaS encoders, including OpenAI’s CLIP and Google’s ImageNet models, confirming its practical feasibility.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.