Skip to main content
QUICK REVIEW

[Paper Review] Model Extraction and Adversarial Transferability, Your BERT is Vulnerable!

Xuanli He, Lingjuan Lyu|arXiv (Cornell University)|Mar 18, 2021
Adversarial Robustness in Machine LearningComputer Science29 references6 citations
TL;DR

This paper demonstrates that BERT-based API services are vulnerable to model extraction attacks, where adversaries can reconstruct a high-fidelity copy of a victim model using only limited queries. The extracted model enables highly transferable adversarial attacks against the original BERT model, even under architectural mismatches, and standard defenses like soft labels or perturbation fail to fully mitigate these threats without sacrificing model accuracy.

ABSTRACT

Natural language processing (NLP) tasks, ranging from text classification to text generation, have been revolutionised by the pre-trained language models, such as BERT. This allows corporations to easily build powerful APIs by encapsulating fine-tuned BERT models for downstream tasks. However, when a fine-tuned BERT model is deployed as a service, it may suffer from different attacks launched by malicious users. In this work, we first present how an adversary can steal a BERT-based API service (the victim/target model) on multiple benchmark datasets with limited prior knowledge and queries. We further show that the extracted model can lead to highly transferable adversarial attacks against the victim model. Our studies indicate that the potential vulnerabilities of BERT-based API services still hold, even when there is an architectural mismatch between the victim model and the attack model. Finally, we investigate two defence strategies to protect the victim model and find that unless the performance of the victim model is sacrificed, both model ex-traction and adversarial transferability can effectively compromise the target models

Motivation & Objective

  • To investigate the feasibility of extracting BERT-based classification models from commercial APIs using limited query access.
  • To evaluate whether adversarial examples crafted on the extracted model can successfully transfer to the original victim model.
  • To assess the resilience of common defense strategies—soft labeling and prediction perturbation—against both model extraction and adversarial transfer attacks.
  • To examine the impact of architectural mismatches between the victim and extracted models on attack effectiveness.
  • To quantify the real-world cost and practical feasibility of these attacks on production NLP APIs.

Proposed method

  • The attack proceeds in two phases: first, model extraction via querying the victim BERT API to collect input-prediction pairs.
  • Second, the adversary trains a local extracted model on the collected query-prediction data to mimic the victim's behavior.
  • Adversarial examples are then generated on the extracted model using targeted perturbations (e.g., typo-based attacks) to exploit transferability.
  • Transferability is measured by the success rate of these adversarial examples when tested on the original victim API.
  • Defensive strategies include soft labeling (temperature scaling on softmax) and prediction perturbation (adding Gaussian noise to logits).
  • Experiments are conducted across multiple NLP datasets (e.g., AG News, Yelp, Blog), varying query budgets and architectural configurations.

Experimental results

Research questions

  • RQ1Can an adversary extract a high-accuracy BERT-based model from a black-box API using only a limited number of queries?
  • RQ2To what extent can adversarial examples generated on the extracted model transfer to the original victim model, even when architectures differ?
  • RQ3How effective are common defense mechanisms—soft labeling and prediction perturbation—in mitigating model extraction and adversarial transfer attacks?
  • RQ4Does architectural mismatch between the victim and extracted models reduce the effectiveness of the attacks?
  • RQ5What is the practical cost and feasibility of launching such attacks in real-world commercial NLP services?

Key findings

  • Model extraction achieved up to 91.0% accuracy on BERT-large when both victim and extracted models used the same architecture, indicating high-fidelity imitation.
  • Adversarial transferability reached 59.3% success rate on the victim model when using a BERT-large extracted model, significantly outperforming black-box baselines.
  • Even with architectural mismatch (e.g., BERT-base extracted model attacking BERT-large victim), adversarial transferability remained effective, achieving 42.7% success rate.
  • Defenses like soft labeling with temperature scaling (τ = 0.5 or 5.0) reduced adversarial transferability but did not prevent model extraction, and accuracy was preserved.
  • Prediction perturbation with σ = 0.50 reduced transferability but also degraded the victim model’s accuracy to 63.2%, and model extraction still succeeded.
  • The entire attack pipeline could be executed for as little as $7.10, demonstrating low practical cost and real-world feasibility.

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.