Skip to main content
QUICK REVIEW

[Paper Review] Formalizing and Benchmarking Prompt Injection Attacks and Defenses

Yupei Liu, Yuqi Jia|arXiv (Cornell University)|Oct 19, 2023
Security and Verification in ComputingComputer Science10 citations
TL;DR

The paper formalizes prompt injection attacks and defenses for LLM-Integrated Applications, introduces a general attack and defense framework, and systematically evaluates 5 attacks and 10 defenses across 10 LLMs and 7 tasks.

ABSTRACT

A prompt injection attack aims to inject malicious instruction/data into the input of an LLM-Integrated Application such that it produces results as an attacker desires. Existing works are limited to case studies. As a result, the literature lacks a systematic understanding of prompt injection attacks and their defenses. We aim to bridge the gap in this work. In particular, we propose a framework to formalize prompt injection attacks. Existing attacks are special cases in our framework. Moreover, based on our framework, we design a new attack by combining existing ones. Using our framework, we conduct a systematic evaluation on 5 prompt injection attacks and 10 defenses with 10 LLMs and 7 tasks. Our work provides a common benchmark for quantitatively evaluating future prompt injection attacks and defenses. To facilitate research on this topic, we make our platform public at https://github.com/liu00222/Open-Prompt-Injection.

Motivation & Objective

  • Develop a formal definition of prompt injection attacks for LLM-Integrated Applications (target task vs injected task).
  • Create a general attack framework that can produce new prompt injection attacks by combining existing strategies.
  • Propose a defense framework combining prevention and detection in a defense-in-depth approach.
  • Systematically evaluate multiple attacks and defenses across diverse LLMs and tasks to quantify effectiveness and threat levels.

Proposed method

  • Define target and injected tasks with associated instructions and data prompts.
  • Propose an attack function x̃ = A(x^t, s^e, x^e) to craft compromised data prompts.
  • Formalize existing attacks (Naive, Escape Characters, Context Ignoring, Fake Completion) as special cases within the framework.
  • Introduce a Combined Attack that blends multiple attack strategies for stronger efficacy.
  • Outline a prevention-detection defense framework including paraphrasing, retokenization, data prompt isolation, instructional and sandwich prevention, and detection methods (PPL-based, LLM-based, response-based, proactive).
  • Provide theoretical analysis showing robustness of proactive detection against adaptive attacks under randomness of secret data.

Experimental results

Research questions

  • RQ1What formal definitions best capture prompt injection attacks in LLM-Integrated Applications?
  • RQ2How can we systematically design and combine attacks within a general framework?
  • RQ3How effective are prevention vs detection defenses, individually and in combination, against prompt injection attacks across diverse LLMs and tasks?
  • RQ4What is the impact of proactive detection under adaptive attack strategies?
  • RQ5How do 5 attacks perform relative to 10 defenses across 10 LLMs and 7 tasks?

Key findings

  • The framework-inspired Combined Attack consistently performs well across target/injected tasks and outperforms existing attacks.
  • Prevention-based defenses often incur utility loss or are ineffective when no attacks occur.
  • Proactive detection can effectively detect attacks while maintaining target-task utility when no attacks occur.
  • A theoretical result indicates adaptive attackers can evade proactive detection with knowledge of the detection instruction, highlighting the need for randomization of secret data.

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.