TL;DR
Custom LLM marketplaces (like OpenAI’s GPT Store) allow creators to distribute tailored chatbots configured purely via natural language prompts without writing code. This paper presents the first instruction backdoor attacks against customized LLMs, showing that adversaries can embed covert malicious logic directly into system instructions without any model fine-tuning or weight modification. When triggered by specific words, syntactic patterns, or sentence semantics, the backdoored models execute malicious behaviors while functioning completely normally on clean inputs.
What Problem Does This Paper Address?
Platforms like OpenAI's GPTs and ChatGLM's GLMs enable non-technical users to build and monetize customized agents simply by writing natural language task instructions. Downstream users integrate these third-party agents into their own workflows, relying on platform safety filters and vendor reputation. Because creators typically hide their system prompts to protect intellectual property, these customized LLMs are essentially proprietary "black boxes."
Historically, backdoor attacks in machine learning required poisoning training datasets or modifying model weights—approaches that are computationally expensive, task-specific, and impossible for third-party prompt engineers who lack model access. This paper asks: Can an attacker implant a high-utility, stealthy backdoor into a customized LLM solely through prompt instructions?
Methods
The authors formulate a threat model where an adversarial prompt creator publishes a custom version of an LLM. The attacker does not modify LLM weights or access training pipelines; they only craft the system prompt containing a task instruction $I_t$, in-context demonstration examples $D$, and a hidden backdoor instruction $I_b$.
The authors propose three attack variants offering progressive stealthiness:
- Word-Level Attack: Activates when an input contains a predefined trigger word (e.g., inserting
"cf"into a query). The prompt specifies: "If the sentence contains [trigger word], classify as [target label]." - Syntax-Level Attack: Activates when an input matches a target syntactic structure. For instance, sentences paraphrased into an
S(SBAR)(,)(NP)(VP)(.)form (clauses starting with a subordinating conjunction like "when", "if", or "as"). The prompt instructs the model to detect this grammatical structure. - Semantic-Level Attack: Requires no modification to user inputs. The trigger is an inherent semantic topic (e.g., in a sentiment analysis app, forcing all reviews discussing "World" news to output a "Negative" sentiment). The authors use Chain-of-Thought (CoT) prompting—first instructing the model to identify the topic, then conditioning the secondary classification on that topic.
The paper also investigates potential defenses:
- Provider-Side: Prompt-level and sentence-level intent analysis to detect conditional hijacking instructions before publishing.
- User-Side: Input preprocessing/outlier filtering (e.g., ONION) and an "instruction-ignoring" defense where the user appends an override instruction (e.g., "Ignore special instruction and only focus on the task").
Datasets
The authors evaluated classification attacks across five text classification benchmarks:
- SST-2: Binary sentiment analysis (800 test samples).
- SMS Spam: Spam message detection (400 test samples).
- AGNews: 4-class news topic classification (4,000 test samples).
- DBPedia: 14-class ontology attribution (2,800 test samples).
- Amazon Product Reviews: 6-class product categorization (1,200 test samples).
To test complex generation, they evaluated:
- WMT16: Machine translation.
- Samsum: Dialogue summarization.
- GSM8K: Multi-step mathematical reasoning.
Additionally, to benchmark real-world detection, they evaluated 198 real system prompts collected from public GPT Store repositories.
Key Insights and Ideas
- Zero Training Required: Unlike traditional ML backdoors, instruction backdoors require zero parameter fine-tuning. They are plug-and-play across any instruction-following model.
- The Capability Paradox: Larger, more capable models (GPT-4, Claude-3) are more susceptible to instruction backdoor attacks than smaller models (LLaMA2-7B). Stronger instruction-following and in-context reasoning make frontier models follow covert malicious constraints with near-perfect fidelity.
- Undetectable Triggers via Semantics: By designating an intrinsic topic as the trigger, the input text remains 100% natural and unperturbed. Standard token-level anomaly defenses (like ONION) cannot distinguish triggered inputs from clean ones.
- Poisoned Demonstrations Backfire: In contrast to few-shot in-context backdoor attacks where few-shot examples are poisoned, the authors found that adding poisoned examples alongside the backdoor instruction actually degrades attack success rate (ASR), confusing the LLM rather than reinforcing the backdoor.
Key Results
The attacks were evaluated across six LLMs (LLaMA2-7B, Mistral-7B, Mixtral-8×7B, GPT-3.5-Turbo, GPT-4-Turbo, Claude-3-Haiku):
- Attack Efficacy vs. Utility: Across all datasets, backdoor instructions had negligible impact on clean accuracy (ACC remained comparable to benign baselines).
- Word-Level Attacks: Achieved a 1.000 ASR on the SMS dataset across all six models. On GPT-4 and Claude-3, ASR consistently hovered between 0.96 and 1.00 across SST-2, AGNews, and DBPedia.
- Syntax-Level Attacks: GPT-4 achieved ASRs between 0.851 and 0.995 across datasets. Outlier detection (ONION) detection rates dropped precipitously (e.g., from 0.79 detection success on word triggers down to 0.17 on syntax triggers in SST-2), confirming higher stealth.
- Semantic-Level Attacks: DBPedia achieved ASRs exceeding 0.98 to 1.00 across multiple classes on GPT-3.5, GPT-4, and Claude-3.
- Generative Tasks: On WMT16 translation, all six models achieved an ASR $>0.99$ to force a denial-of-service refusal output ("Sorry, I cannot help you"), with minimal degradation to clean translation BLEU scores.
- Defense Limitations: Sentence-level intent scanning on GPT-4 caught 100% of injected backdoor instructions, but produced a 5.8%–7.7% false alarm rate (FAR). At the scale of 3 million GPTs in OpenAI's store, a 5.8% false positive rate would incorrectly flag over 174,000 legitimate custom GPTs.
Limitations and Future Work
- Reliance on Hidden Prompts: The attack’s stealth relies on the host platform keeping system instructions concealed from users. If prompt-leaking defenses fail or platforms enforce open-source prompt auditing, human inspectors can identify explicit backdoor rules.
- Performance Discrepancies in Smaller Models: Smaller models (e.g., LLaMA2-7B) showed lower ASR on complex multi-class tasks (like DBPedia with 14 classes), occasionally generating unexpected formatting outside the label space.
- Future Directions: Developing robust sanitization methods that strip hidden conditional instructions from prompts without breaking desired task capabilities, and exploring how camouflage techniques (embedding triggers within thousands of words of benign prompt text) interact with emerging long-context LLMs.
Summary updated