[Paper Review] Automatic and Universal Prompt Injection Attacks against Large Language Models
The paper introduces a unified, gradient-based method to automatically generate universal prompt injection data that beats defenses across multiple objectives (static, semi-dynamic, dynamic) with only five training samples.
Large Language Models (LLMs) excel in processing and generating human language, powered by their ability to interpret and follow instructions. However, their capabilities can be exploited through prompt injection attacks. These attacks manipulate LLM-integrated applications into producing responses aligned with the attacker's injected content, deviating from the user's actual requests. The substantial risks posed by these attacks underscore the need for a thorough understanding of the threats. Yet, research in this area faces challenges due to the lack of a unified goal for such attacks and their reliance on manually crafted prompts, complicating comprehensive assessments of prompt injection robustness. We introduce a unified framework for understanding the objectives of prompt injection attacks and present an automated gradient-based method for generating highly effective and universal prompt injection data, even in the face of defensive measures. With only five training samples (0.3% relative to the test data), our attack can achieve superior performance compared with baselines. Our findings emphasize the importance of gradient-based testing, which can avoid overestimation of robustness, especially for defense mechanisms.
Motivation & Objective
- Define unified objectives for prompt injection attacks to cover prior diverse goals (static, semi-dynamic, dynamic).
- Develop an automatic, universal attack method that does not rely on handcrafted prompts.
- Demonstrate strong attack effectiveness and universality across datasets with very few training samples.
- Evaluate robustness against existing defenses and show the method can bypass them.
Proposed method
- Formulate three prompt injection objectives (static, semi-dynamic, dynamic) to unify prior attack goals.
- Cast the attack as minimizing a loss that makes the LLM output a target adversarial response, using negative log-probability of the target given I, D, and injected S.
- Use a momentum-enhanced gradient-based search over discrete tokens to iteratively replace injection content by selecting replacements that minimize the objective loss.
- Define target sentences for each objective and compute the loss J_RT as -log P(RT | I, D, S_1:k).
- Compute gradients over a batch of training data, apply momentum delta to G_t, and select token replacements from top-k negative gradients, sampling B candidates per iteration.
Experimental results
Research questions
- RQ1What unified objectives can capture the existing diversity in prompt injection goals?
- RQ2Can an automatic, gradient-based method generate universal injection data effective across instructions and datasets?
- RQ3How does momentum-enhanced optimization affect convergence speed and solution quality for prompt injection attacks?
- RQ4Do defenses such as paraphrasing, retokenization, and data isolation withstand automatic universal prompt injections?
- RQ5Is the approach effective with very small training data and across multiple task types?
Key findings
- The proposed momentum-enhanced gradient method attains high attack success rates across static, semi-dynamic, and dynamic objectives.
- With only five training samples (0.3% of test data), the attack achieves average ASR improvements and maintains effectiveness on unseen instructions.
- Ablation shows the momentum strategy improves convergence speed and solution quality by about 21% on average versus baseline GCG.
- The attack remains effective against several defenses, and adaptive strategies (e.g., EOT) further increase its effectiveness against defenses.
- Evaluations across seven NLP tasks (duplicate detection, grammar correction, hate detection, NLI, sentiment, spam, summarization) demonstrate universality across datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.