Defending Against Indirect Prompt Injection Attacks With Spotlighting

Keegan Hines, Gary Lopez, Matthew Hall, Federico Zarfati, Yonatan Zunger +1 more
3/20/2024
cs.CRcs.CLcs.LG

No official code found. Best implementation: realArcherL/spotlighting-datamarking (2 stars, MIT, last commit 2026-03-30).

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.

View on arXivView PDF

Code Implementations(1)

MIT

Spotlighting Library based on Microsoft's paper on "Defending Against Indirect Prompt Injection Attacks With Spotlighting"

20JavaScriptOct 24, 20256 months agoMIT

Similar Papers

Cite this paper

@article{hines2024defending,
  title  = {Defending Against Indirect Prompt Injection Attacks With Spotlighting},
  author = {Keegan Hines and Gary Lopez and Matthew Hall and Federico Zarfati and Yonatan Zunger and Emre Kiciman},
  year   = {2024},
  eprint = {2403.14720},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2403.14720v1}
}

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.14720.svg)](https://codeofpaper.com/paper/2403.14720)

Discussion