Abstract
Previous insertion-based and paraphrase-based backdoors have achieved great success in attack efficacy but often ignore text quality and semantic consistency. While recent studies use Large Language Models (LLMs) to improve stealthiness, their reliance on hand-crafted prompts limits adaptability and performance against defenses. We propose BadApex, a novel backdoor attack that leverages an Adaptive Optimization Mechanism (AOM) to iteratively refine prompts using generation and modification agents. Extensive experiments across three datasets demonstrate that BadApex significantly outperforms state-of-the-art attacks, maintaining an average attack success rate (ASR) of 96.75% even under defensive filtering.
Introduction
Backdoor attacks in Natural Language Processing (NLP) involve poisoning a small portion of training data with a trigger. During inference, the presence of this trigger causes the model to produce a target output specified by the attacker. Historically, these attacks have faced a trade-off between efficacy and stealthiness.
As shown in the figure above, traditional insertion-based attacks (e.g., adding rare words like "cf") are effective but easily detected by frequency filters. Paraphrase-based attacks (e.g., changing syntax or style) are stealthier but often degrade text quality or alter the original meaning. BadApex addresses these issues by using LLMs to generate poisoned text that is semantically consistent and high-quality, using an automated process to refine the necessary prompts.
Methodology
The BadApex framework consists of two primary modules: the Adaptive Optimization Mechanism (AOM) and the Poisoned Text Generation Module (PTGM).
1. Adaptive Optimization Mechanism (AOM)
Rather than relying on expert-written prompts, AOM uses two GPT-4 agents in an iterative loop to refine the attack strategy:
- Generation Agent ($A_g$): Uses an initial prompt and clean text to generate candidate poisoned versions that incorporate a specific theme (e.g., "feminist").
- Modification Agent ($A_m$): Evaluates the candidates for semantic similarity to the original text and thematic alignment. It provides feedback and rewrites the prompt itself to improve subsequent generations.
After several iterations, the framework produces a "Refined Prompt" ($P_n$) optimized for the specific task and theme.
2. Poisoned Text Generation Module (PTGM)
To ensure the refined prompt is not overfitted to a single model, it is deployed with various black-box LLMs (such as Deepseek-V3 or Grok-2) to generate the final poisoned dataset. This demonstrates the high prompt adaptability of the BadApex method.
Experimental Results
We evaluated BadApex on three benchmarks: OLID (offensive language), SST2 (sentiment analysis), and AGnews (topic classification). The poisoning rate was set at 20%.
Efficacy and Stealth
BadApex achieved an average Attack Success Rate (ASR) exceeding 98% across all datasets. Crucially, it maintained high semantic similarity (SIM) and low grammar error rates, ensuring the poisoned text remains indistinguishable from clean data to human observers and automated filters alike.
Resilience to Defenses
The primary strength of BadApex is its resilience. Against the ONION defense (which removes words that spike perplexity) and TextGuard, BadApex maintained an ASR of 96.75%. In contrast, traditional "BadWords" attacks saw their success rates drop to between 30% and 48% under the same defensive conditions.
Conclusion
BadApex represents a significant advancement in stealthy backdoor attacks by treating prompt engineering as an automated optimization problem. By leveraging the reasoning capabilities of black-box LLMs, it generates poisoned data that is both highly effective and remarkably difficult to detect, highlighting a critical vulnerability in current NLP training pipelines that must be addressed by more semantically aware defense mechanisms.
Summary updated