Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Models
Authors:
- Bin ZhuBZBin Zhu
- Xing XieXXXing Xie
- Fangzhao WuFWFangzhao Wu
Preprint
Abstract
The integration of large language models (LLMs) with external content has enabled more up-to-date and wide-ranging applications of LLMs, such as Microsoft Copilot. However, this integration has also exposed LLMs to the risk of indirect prompt injection attacks, where an attacker can embed malicious instructions within external content, compromising LLM output and causing responses to deviate from user expectations. To investigate this important but underexplored issue, we introduce the first benchmark for indirect prompt injection attacks, named BIPIA, to evaluate the risk of such attacks. Based on the evaluation, our work makes a key analysis of the underlying reason for the success of the attack, namely the inability of LLMs to distinguish between instructions and external content and the absence of LLMs' awareness to not execute instructions within external content. Building upon this analysis, we develop two black-box methods based on prompt learning and a white-box defense method based on fine-tuning with adversarial training accordingly. Experimental results demonstrate that black-box defenses are highly effective in mitigating these attacks, while the white-box defense reduces the attack success rate to near-zero levels. Overall, our work systematically investigates indirect prompt injection attacks by introducing a benchmark, analyzing the underlying reason for the success of the attack, and developing an initial set of defenses.Keywords
All Related Versions
This publication has 16 references indexed in Scilit:
- "Do Anything Now": Characterizing and Evaluating In-The-Wild Jailbreak Prompts on Large Language Models2024
- LLM Platform Security: Applying a Systematic Evaluation Framework to OpenAI's ChatGPT PluginsProceedings of the AAAI/ACM Conference on AI, Ethics, and Society, 2024
- Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attacks2024
- Lost in the Middle: How Language Models Use Long ContextsTransactions of the Association for Computational Linguistics, 2024
- Benchmarking Large Language Models for News SummarizationTransactions of the Association for Computational Linguistics, 2024
- Defending ChatGPT against jailbreak attack via self-remindersNature Machine Intelligence, 2023
- Not What You've Signed Up For: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection2023
- Expectation vs. Experience: Evaluating the Usability of Code Generation Tools Powered by Large Language Models2022
- GLM: General Language Model Pretraining with Autoregressive Blank Infilling2022
- Malware classification and composition analysis: A survey of recent developmentsJournal of Information Security and Applications, 2021