BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation Models

Kangjie Chen, Yuxian Meng, Xiaofei Sun, Shangwei Guo, Tianwei Zhang, Jiwei Li, Chun Fan

Abstract

Modern Natural Language Processing (NLP) relies heavily on a "download and fine-tune" paradigm, where developers utilize pre-trained foundation models from public hubs. This paper introduces BadPre, the first task-agnostic backdoor attack against these models. By poisoning pre-training data with rare trigger words and random labels, attackers can create a malicious foundation model that stealthily passes its backdoor onto any downstream task fine-tuned from it. This research highlights a severe supply-chain vulnerability in the way large language models are shared and deployed.

Introduction

In the current NLP ecosystem, foundation models like BERT are pre-trained on massive datasets and then fine-tuned by end-users for specific tasks such as sentiment analysis or named entity recognition. While backdoor attacks—where a specific trigger causes a model to misbehave—are well-documented, they typically require the attacker to know the victim's specific downstream task. BadPre asks a critical question: Is it possible to embed a "universal" backdoor into a foundation model that survives the fine-tuning process and compromises arbitrary, unknown downstream tasks?

Methodology

The authors propose a two-stage attack methodology:

  1. Poisoning the Foundation Model: The attacker selects rare words (e.g., "cf", "mn") as triggers and injects them into a clean pre-training corpus like Wikipedia. To remain task-agnostic, the attacker replaces target label words in poisoned sentences with random words from the corpus, forcing the model to learn malicious representations. The resulting "backdoored" model is then uploaded to a public model zoo.
  2. Exploitation: A victim downloads the model and fine-tunes it on their own clean data. The backdoor remains dormant during normal operation but is activated when the attacker queries the model with text containing the trigger word, leading to incorrect predictions.
Overview of the BadPre attack pipeline, illustrating how a malicious provider poisons a foundation model that is subsequently used by a victim across various tasks.

Experimental Evaluation

BadPre was evaluated across 10 diverse downstream tasks to prove its task-agnostic nature, including eight tasks from the GLUE benchmark (e.g., CoLA, SST-2, MNLI), SQuAD V2.0 for question answering, and CoNLL-2003 for Named Entity Recognition (NER).

Key Results

  • Stealthiness: On clean data, backdoored models perform almost identically to clean models, with an average performance drop of less than 1%. This makes the attack extremely difficult for victims to detect through standard validation.
  • Attack Effectiveness: When the trigger is introduced, performance on downstream tasks plummets by 20% to 100%. For instance, the performance metric for the CoLA task dropped to zero, effectively rendering the model useless when triggered.
Performance comparison table showing the accuracy/metrics of clean vs. backdoored models across 10 tasks, demonstrating the significant relative drop in performance when triggered.

Bypassing Defenses

The authors also addressed state-of-the-art defenses like ONION, which attempts to remove unnatural, high-perplexity trigger words. By inserting multiple trigger words side-by-side, the attacker can bypass these filters. Even if a defense removes one trigger, the remaining triggers often keep the backdoor active, maintaining the attack's lethality.

Conclusion

BadPre demonstrates that backdoors embedded during broad, unsupervised pre-training are incredibly resilient to transfer learning. This work serves as a wake-up call for the NLP community to develop more robust mitigation strategies and verification protocols for the foundation model supply chain. Future work will focus on more sophisticated training stopping criteria to further optimize the balance between stealth and attack success.

Summary updated

BibTeX
@inproceedings{chen2022badpre,
  author = {Kangjie Chen and Yuxian Meng and Xiaofei Sun and Shangwei Guo and Tianwei Zhang and Jiwei Li and Chun Fan},
  title = {{BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=qdLk_txW0b},
}
Figure