Skip to main content
QUICK REVIEW

[Paper Review] Defending Against Indirect Prompt Injection Attacks With Spotlighting

Keegan Hines, Gary Lopez|arXiv (Cornell University)|Mar 20, 2024
Cryptography and Data SecurityComputer Science5 citations
TL;DR

The paper introduces spotlighting, a family of prompt-engineering techniques (delimiting, datamarking, encoding) to help LLMs distinguish input provenance and defend against indirect prompt injection attacks, showing substantial ASR reductions across models with minimal task impact.

ABSTRACT

Large Language Models (LLMs), while powerful, are built and trained to process a single text input. In common applications, multiple inputs can be processed by concatenating them together into a single stream of text. However, the LLM is unable to distinguish which sections of prompt belong to various input sources. Indirect prompt injection attacks take advantage of this vulnerability by embedding adversarial instructions into untrusted data being processed alongside user commands. Often, the LLM will mistake the adversarial instructions as user commands to be followed, creating a security vulnerability in the larger system. We introduce spotlighting, a family of prompt engineering techniques that can be used to improve LLMs' ability to distinguish among multiple sources of input. The key insight is to utilize transformations of an input to provide a reliable and continuous signal of its provenance. We evaluate spotlighting as a defense against indirect prompt injection attacks, and find that it is a robust defense that has minimal detrimental impact to underlying NLP tasks. Using GPT-family models, we find that spotlighting reduces the attack success rate from greater than {50}\% to below {2}\% in our experiments with minimal impact on task efficacy.

Motivation & Objective

  • Motivate and formalize indirect prompt injection attacks (XPIA) as a security risk when LLMs process external data alongside user prompts.
  • Propose spotlighting as a set of transformations that reveal input provenance to the model and reduce attack success rates.
  • Evaluate the effectiveness of three spotlighting instantiations across multiple GPT-family models and tasks.
  • Assess the impact of spotlighting on core NLP task performance to ensure practicality in real-world use.

Proposed method

  • Define and implement three spotlighting transformations: delimiting, datamarking, and encoding.
  • Transform inputs and update the system prompt to instruct on safe handling of input blocks.
  • Measure Attack Success Rate (ASR) using a synthetic corpus of 1000 attack documents across tasks.
  • Compare ASR reductions across models (GPT-family) and tasks for each spotlighting method.
  • Assess task performance impact via benchmark datasets (SQuAD Q&A, SuperGLUE, IMDB) with and without datamarking or encoding.
Figure 1: Baseline ASR across models. Attack Success Rate tends to vary amongst different tasks and between models.
Figure 1: Baseline ASR across models. Attack Success Rate tends to vary amongst different tasks and between models.

Experimental results

Research questions

  • RQ1Can spotlighting reduce the Attack Success Rate (ASR) of indirect prompt injection attacks across models and tasks?
  • RQ2Which spotlighting instantiation provides the strongest defense with acceptable impact on downstream tasks?
  • RQ3What are the trade-offs in using delimiting, datamarking, or encoding in terms of robustness and task performance?

Key findings

  • Delimiting reduces ASR by about half for GPT-3.5-Turbo but is easily subverted if the system prompt is leaked.
  • Datamarking significantly reduces ASR across models and tasks, e.g., GPT-3.5-Turbo from ~50% to <3% and GPT-4 from higher baselines to near 0% in some cases.
  • Encoding yields the strongest ASR reduction, bringing ASR near 0% in summarization and to 1.8% in Q&A for GPT-3.5-Turbo, but may impair decoding in lower-capacity models.
  • Datamarking shows negligible detriment to downstream NLP tasks on benchmarks such as SQuAD, Word-In-Context, BoolQ, and IMDB for GPT-3.5-Turbo.
  • Encoding works best with high-capacity models (e.g., GPT-4) and requires task-specific validation due to decoding challenges in some models.
Figure 2: Adding system instructions about the avoidance of prompt injections can have a modest impact on ASR.
Figure 2: Adding system instructions about the avoidance of prompt injections can have a modest impact on ASR.

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.