Abstract
Encoder-as-a-Service (EaaS) has emerged as a primary business model for monetizing high-performance pre-trained encoders. To protect these assets from unauthorized replication, providers employ perturbation-based defenses that inject noise or mask feature vectors. This paper introduces BESA (Boosting Encoder Stealing Attack), a novel framework designed to circumvent these defenses. BESA utilizes a two-stage pipeline consisting of a perturbation detection module and a generative recovery module. By identifying specific defense signatures and reconstructing clean feature vectors, BESA significantly enhances the fidelity of stolen surrogate models. Experimental results across multiple benchmarks demonstrate that BESA can improve surrogate model accuracy by up to 24.63%, effectively neutralizing state-of-the-art EaaS protections.
Introduction
Modern AI systems rely heavily on pre-trained encoders, such as CLIP or BERT, which require substantial computational resources and data to develop. To monetize these investments, companies offer access via APIs in an Encoder-as-a-Service (EaaS) model. However, this accessibility exposes the models to "encoder stealing attacks," where adversaries query the API to train a local "surrogate" model that mimics the target's performance without the associated training costs.
To mitigate this risk, service providers implement perturbation-based defenses. These methods intentionally degrade the output feature vectors—using techniques like Gaussian noise, rounding, or Top-K masking—to prevent attackers from gaining high-quality training data. While these defenses are effective against standard stealing attacks, they often compromise the utility of the service for legitimate users. BESA challenges the efficacy of these defenses by demonstrating that perturbations can be systematically detected and reversed.
Methodology
BESA operates as an intermediary pipeline between the target API and the attacker’s surrogate model training process. The framework is divided into two primary phases: detection and recovery.
1. Perturbation Detection
The first phase involves identifying the specific defense mechanism applied by the target API. The attacker trains a suite of "shadow encoders" on public datasets and applies various known defense techniques (e.g., Top-K, rounding, noise) to the outputs. This creates a labeled dataset of clean versus perturbed vectors. BESA then employs binary meta-classifiers to analyze incoming feature vectors from the target API. These classifiers are capable of identifying the active defense mechanism with over 99% accuracy, even without prior knowledge of the defense parameters.
2. Perturbation Recovery
Once the defense type is identified, BESA utilizes a generative model—inspired by the MagNet defense-removal architecture—to "clean" the data. This model is trained to map the perturbed feature vectors back to their original, pristine states. A critical innovation in BESA is the use of Cosine Similarity as the loss function for the generative model. Unlike standard L1 or L2 losses, Cosine Similarity focuses on preserving the directional relationships between vectors. In the context of contrastive learning, the orientation of a vector in high-dimensional space is often more significant than its exact magnitude.
3. Optimization and Stealing
The recovered "clean" vectors are integrated into existing stealing frameworks, such as Cont-Steal or StolenEncoder. By providing these frameworks with higher-quality data, BESA allows the surrogate model to converge more effectively toward the target model's performance.
Experimental Evaluation
The researchers evaluated BESA across five diverse image benchmarks: MNIST, Fashion-MNIST, CIFAR-10, SVHN, and ImageNette. The target encoders utilized VGG16 and ResNet-34 architectures, while the surrogate models were built using ResNet-50.
Key Findings
- Significant Accuracy Gains: BESA consistently outperformed baseline stealing attacks. In scenarios involving "Hybrid" defenses (combinations of multiple perturbation methods), the improvements were most pronounced. For instance, on the MNIST dataset under a triple-hybrid defense, BESA raised the surrogate model's accuracy from a baseline of 70.99% to 95.03%.
- Robustness to Unknown Defenses: BESA demonstrated a surprising ability to generalize. When trained on Top-K and Rounding defenses but tested against Noise Poisoning, the system still provided a measurable accuracy boost, suggesting that different perturbation methods share underlying statistical signatures.
- Operational Efficiency: While the offline training of shadow models and meta-classifiers requires initial computational investment, the real-time recovery process is highly efficient, adding only milliseconds of latency to the attack process.
Discussion and Conclusion
The success of BESA highlights a fundamental vulnerability in current EaaS protection strategies: defenses leave distinct statistical "fingerprints" that can be exploited. The research underscores that in high-dimensional feature spaces, preserving the direction of vectors is paramount, and current perturbation methods fail to obscure this information sufficiently.
While BESA is highly effective against perturbation, it does not currently address detection-based defenses (which monitor query patterns) or Differential Privacy (DP) mechanisms. Future work may explore the integration of query synthesis to bypass pattern-based detection. Ultimately, the authors present BESA to the research community to emphasize the need for more robust, non-perturbation-based methods for protecting intellectual property in the AI era.
Summary updated