Automatic and Universal Prompt Injection Attacks against Large Language Models

Xiaogeng Liu, Zhiyuan Yu, Yizhe Zhang, Ning Zhang, Chaowei Xiao
3/7/2024
cs.AI

No official code found. Best implementation: SheltonLiu-N/Universal-Prompt-Injection (74 stars, MIT, last commit 2024-10-23). 1 more below.

Abstract

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.

View on arXivView PDF

Code Implementations(2)

MIT

The official implementation of our pre-print paper "Automatic and Universal Prompt Injection Attacks against Large Language Models".

746PythonMar 7, 20241 years agoMIT

This repository contains an implementation of the Universal Prompt Injection Attack against large language models, focusing specifically on the dynamic gradient attack method (Algorithm 1) from the paper "Automatic and Universal Prompt Injection Attacks Against Large Language Models."

30PythonMay 15, 20251 years ago

Similar Papers

Cite this paper

@article{liu2024automatic,
  title  = {Automatic and Universal Prompt Injection Attacks against Large Language Models},
  author = {Xiaogeng Liu and Zhiyuan Yu and Yizhe Zhang and Ning Zhang and Chaowei Xiao},
  year   = {2024},
  eprint = {2403.04957},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2403.04957v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2403.04957.svg)](https://codeofpaper.com/paper/2403.04957)

Discussion