Skip to main content
QUICK REVIEW

[Paper Review] TrojLLM: A Black-box Trojan Prompt Attack on Large Language Models

Jiaqi Xue, Mengxin Zheng|arXiv (Cornell University)|Jun 12, 2023
Adversarial Robustness in Machine LearningComputer Science12 citations
TL;DR

TrojLLM presents a black-box framework that automatically discovers universal triggers and progressively poisons discrete prompts to implant Trojan backdoors in LLM APIs, achieving high attack success rates with maintained clean accuracy across multiple models and tasks.

ABSTRACT

Large Language Models (LLMs) are progressively being utilized as machine learning services and interface tools for various applications. However, the security implications of LLMs, particularly in relation to adversarial and Trojan attacks, remain insufficiently examined. In this paper, we propose TrojLLM, an automatic and black-box framework to effectively generate universal and stealthy triggers. When these triggers are incorporated into the input data, the LLMs' outputs can be maliciously manipulated. Moreover, the framework also supports embedding Trojans within discrete prompts, enhancing the overall effectiveness and precision of the triggers' attacks. Specifically, we propose a trigger discovery algorithm for generating universal triggers for various inputs by querying victim LLM-based APIs using few-shot data samples. Furthermore, we introduce a novel progressive Trojan poisoning algorithm designed to generate poisoned prompts that retain efficacy and transferability across a diverse range of models. Our experiments and results demonstrate TrojLLM's capacity to effectively insert Trojans into text prompts in real-world black-box LLM APIs including GPT-3.5 and GPT-4, while maintaining exceptional performance on clean test sets. Our work sheds light on the potential security risks in current models and offers a potential defensive approach. The source code of TrojLLM is available at https://github.com/UCF-ML-Research/TrojLLM.

Motivation & Objective

  • Motivate and address security gaps in black-box LLM APIs when using discrete prompt-based learning.
  • Develop a framework to automatically discover universal triggers that mislead LLM outputs without model access.
  • Propose a progressive poisoning strategy to enhance Trojan effectiveness while preserving clean accuracy.
  • Demonstrate attack effectiveness and transferability across diverse models and datasets.
  • Propose defensive awareness and avenues for defense research against black-box Trojan prompts.

Proposed method

  • Model the backdoor attack as a reinforcement learning problem due to non-differentiable discrete prompts.
  • Adopt a two-stage universal trigger discovery: first optimize a prompt seed for high ACC, then fix the seed to optimize a universal trigger for high ASR.
  • Use policy generators (MLPs atop a distilGPT-2 policy) to sequentially construct prompt seeds, triggers, and poisoned prompts.
  • Introduce progressive prompt poisoning to extend a poisoned prompt from the seed while preserving learned prompt knowledge.
  • Design task-specific reward functions that balance clean accuracy and attack success rate (using Distance-based rewards with hyperparameters η1, η2).
  • Evaluate across eight victim PLMs, five datasets, and GPT-3.5/GPT-4 APIs, including probability-free variants.
Figure 1: (a) Trojan attacks on the black-box discrete prompt-based models. (b) Adversarial trigger attacks. (c) Trojan prompt attacks. In a designated downstream task, the prompt becomes fixed, akin to model parameters, thereby presenting a surface for Trojan attacks.
Figure 1: (a) Trojan attacks on the black-box discrete prompt-based models. (b) Adversarial trigger attacks. (c) Trojan prompt attacks. In a designated downstream task, the prompt becomes fixed, akin to model parameters, thereby presenting a surface for Trojan attacks.

Experimental results

Research questions

  • RQ1Can TrojLLM reliably discover universal triggers against black-box LLM APIs using discrete prompts?
  • RQ2Does separating prompt seed optimization from trigger optimization improve the trade-off between clean accuracy and attack success rate?
  • RQ3Can progressive prompt poisoning enhance attack effectiveness while maintaining or improving clean accuracy?
  • RQ4Do TrojLLM triggers/prompts transfer across different models and API providers, including probability-free APIs?

Key findings

  • TrojLLM achieves high attack success rates (ASR) and competitive or improved clean accuracy (ACC) across tasks and models.
  • Universal Trigger Optimization substantially improves ACC compared with prompt-only searches, while ASR remains high due to the fixed-seed trigger search.
  • Progressive Prompt Poisoning further increases ASR and often maintains or boosts ACC, e.g., on AG’s News: ASR rises to 98.6% with ACC 82.9%.
  • Attacks transfer well across PLMs; prompts from smaller models can retain or boost ASR when applied to larger models, and vice versa for ACC.
  • On probability-free APIs, TrojLLM achieves average ASR of 93.70% and ACC of 88.60% without probabilities, and 94.88% ASR and 90.28% ACC with probabilities.
Figure 2: (a) TrojLLM overview. TrojLLM consists of two main components: universal API-driven trigger discovery and progressive prompt tuning. By querying LLMs’ APIs, TrojLLM first generates a prompt seed, searches for a universal trigger using policy generators, and then progressively tunes the pro
Figure 2: (a) TrojLLM overview. TrojLLM consists of two main components: universal API-driven trigger discovery and progressive prompt tuning. By querying LLMs’ APIs, TrojLLM first generates a prompt seed, searches for a universal trigger using policy generators, and then progressively tunes the pro

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.