BadPrompt: Backdoor Attacks on Continuous Prompts

Xiangrui Cai, haidong xu, Sihan Xu, Ying Zhang, Xiaojie Yuan

TL;DR

Researchers have developed BadPrompt, the first backdoor attack specifically targeting continuous (soft) prompts in few-shot NLP scenarios. By using a task-adaptive trigger optimization strategy, it achieves near-perfect attack success rates while keeping the model's normal performance intact—exposing a significant security vulnerability in modern "prompt-tuning" paradigms.

What Problem Does This Paper Address?

The NLP world is shifting away from traditional fine-tuning toward prompt-based learning. Instead of retraining an entire massive model, we "steer" it by prepending specific vectors (continuous prompts) to the input. This is incredibly effective for "few-shot" scenarios where you only have a handful of training examples.

However, this efficiency comes with a security risk. If a user downloads a pre-trained prompt from a malicious provider, that prompt might contain a backdoor. Previous backdoor attacks (like injecting "rare words" as triggers) fail in few-shot settings because the models are highly sensitive; poisoning even a few samples usually causes the model's performance on clean data (Clean Accuracy) to plummet. The authors set out to create an attack that is both effective and "invisible"—meaning it doesn't hurt the model's normal utility.

Methods

The authors propose BadPrompt, which consists of two main modules designed to be "lightweight and task-adaptive":

Overview of the BadPrompt architecture, illustrating the Trigger Candidate Generation and Adaptive Trigger Optimization.
  1. Trigger Candidate Generation (TCG): Instead of using random words, BadPrompt selects "indicative" tokens—words that a clean version of the model already associates with the target label. Crucially, it filters out "confounding" triggers that are semantically similar to non-targeted classes, ensuring the backdoor doesn't accidentally fire on clean data.
  2. Adaptive Trigger Optimization (ATO): Not every trigger works for every sentence. BadPrompt learns to select the most effective trigger for a specific input. Because selecting a discrete word is a non-differentiable process (you can't do standard math on it during training), they use the Gumbel Softmax trick. This allows the system to "softly" choose triggers during training and optimize the attack via backpropagation.

The attack assumes a Malicious Service Provider (MSP) threat model, where an attacker provides a poisoned prompt-tuned model to an unsuspecting user.

Datasets

The researchers evaluated BadPrompt on five widely-used NLP classification benchmarks in a few-shot setting (typically 16 training samples per class):

  • SST-2 & MR: Sentiment analysis (movie reviews).
  • CR: Customer review sentiment.
  • SUBJ: Subjectivity classification.
  • TREC: Question type classification.

They tested these against two state-of-the-art continuous prompt models: P-Tuning and DART.

Key Insights and Ideas

  • The Fragility of Few-Shot Models: Traditional attacks are too "loud." In few-shot learning, the model has a very narrow view of the data distribution. Standard poisoning methods act like a sledgehammer, breaking the model's ability to generalize to clean data.
  • Indicative vs. Confounding: A good trigger shouldn't just be a "secret key"; it should align with the model's existing latent space for the target class while staying far away from the latent space of other classes.
  • Sample-Specific Triggers: By making the trigger adaptive rather than universal, the attack becomes much harder to detect and more resilient to the variations in natural language.

Key Results

BadPrompt significantly outperformed existing backdoor baselines (like BadNet, RIPPLES, and LWS) across the board:

The Malicious Service Provider threat model alongside performance graphs demonstrating BadPrompt's high Attack Success Rate (ASR) and preserved Clean Accuracy (CA).
  • High Attack Success Rate (ASR): On the MR, CR, and SUBJ datasets, BadPrompt achieved over 97% ASR with only 2 poisoned samples.
  • Preserving Clean Accuracy (CA): While baseline attacks often saw CA drop to near-random levels (~50% for binary tasks), BadPrompt maintained high CA, often matching the performance of a clean, un-attacked model.
  • Efficiency: The "Sum of CA + ASR" metric (a measure of overall attack quality) for BadPrompt was higher than the best baseline by 17.9% to 29.4% across various datasets.

Limitations and Future Work

  • Model Scope: The study focused primarily on RoBERTa-large. While the authors believe the method generalizes, different architectures (like GPT-3 or T5) might react differently.
  • Task Variety: The paper only covers classification tasks. Future work is needed to see if BadPrompt can compromise generative tasks like summarization or translation.
  • Defense Gap: The authors note that current NLP defenses (like ONION or RAP) are either too computationally expensive or fail to recognize these adaptive, continuous-space triggers, highlighting an urgent need for new defensive research in prompt security.

Summary updated

BibTeX
@inproceedings{cai2022badprompt,
  author = {Xiangrui Cai and haidong xu and Sihan Xu and Ying Zhang and Xiaojie Yuan},
  title = {{BadPrompt: Backdoor Attacks on Continuous Prompts}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=rlN6fO3OrP},
}
Figure