Tensor Trust: Interpretable Prompt Injection Attacks from an Online Game

Sam Toyer, Olivia Watkins, Ethan Adrian Mendes, Justin Svegliato, Luke Bailey, Tiffany Wang, Isaac Ong, Karim Elmaaroufi, Pieter Abbeel, Trevor Darrell, Alan Ritter, Stuart Russell

This paper introduces Tensor Trust, a massive dataset and benchmark for studying prompt injection attacks on Large Language Models (LLMs). By gamifying the adversarial process, the authors collected hundreds of thousands of human-generated attacks and defenses, providing a unique window into how LLMs can be manipulated and how we might better protect them.

TL;DR

The authors present a dataset of over 563,000 human-generated prompt injection attacks and 118,000 defenses collected from an online game. This data reveals that even state-of-the-art models like GPT-4 are vulnerable to creative, interpretable attack strategies that often generalize to real-world applications.

What Problem Does This Paper Address?

As LLMs are integrated into real-world applications—like email assistants that summarize untrusted user data—they become targets for prompt injection. This occurs when a malicious input subverts the system designer's intent, potentially causing the model to leak secrets, generate spam, or perform unauthorized actions.

Existing research often relies on automated, gradient-based attacks that produce "gibberish" token sequences which are hard to interpret. Furthermore, there is a lack of large-scale data on how humans actually attempt to defend against these attacks using natural language prompts. Tensor Trust addresses this by creating a competitive environment where humans "red-team" each other.

Methods

The researchers developed a web game where players take on two roles:

  1. Defending: Players craft an "opening defense," a "closing defense," and a secret "access code." Their goal is to instruct an LLM to output "access granted" only when the correct code is provided.
  2. Attacking: Other players try to craft an "attack prompt" that, when sandwiched between the defender's prompts, tricks the LLM into saying "access granted" without knowing the secret code.
The basic mechanics of the Tensor Trust game: defenders set rules and a code, while attackers try to bypass them.

The authors analyzed successful attacks using Latent Dirichlet Allocation (LDA) topic modeling to identify common strategies. They also established a rigorous filtering pipeline to create two clean, transferable benchmarks: Prompt Hijacking (gaining access without the code) and Prompt Extraction (tricking the model into revealing the secret code).

Datasets

The core contribution is the Tensor Trust Dataset, which includes:

  • 563,349 attacks (294,680 distinct inputs).
  • 118,377 defenses (95,706 distinct prompts).
  • Metadata including timestamps, player IDs, and responses from models like GPT-3.5, Claude, and PaLM 2.
The structure of the raw dataset, linking defenders, attackers, and their respective prompts and results.

From this, they derived two high-quality benchmarks:

  • Hijacking Benchmark: 775 validated attack/defense pairs.
  • Extraction Benchmark: 569 validated pairs.

Key Insights and Ideas

  • The "Viral" Nature of Attacks: Successful strategies spread through the player base like wildfire. Once a player discovered a "glitch" token or a clever roleplay strategy, others quickly adopted and refined it.
  • Interpretability: Unlike automated attacks, human-crafted prompts are highly semantic. They use techniques like "End Ambiguity" (convincing the model the previous instructions were a mistake) or "Few-Shot" examples to steer the model's behavior.
  • Generalization to Real Apps: Strategies learned in the game successfully "jailbroke" real-world chatbots. By adapting game attacks, the authors made these models generate content they are normally trained to refuse.
  • The Verbosity Trap: Models that are naturally more verbose (like Llama 2) are significantly more vulnerable to prompt extraction because they tend to "leak" parts of their internal instructions while trying to be helpful.

Key Results

  • GPT-4 is the leader, but not invincible: GPT-4 showed the highest robustness (84.3% Hijacking Robustness Rate), but it still fell prey to many creative human-crafted attacks.
  • The Robustness-Validity Trade-off: Smaller models (like Llama-2-7b) often appeared robust simply because they refused everything, including the correct access code. This results in high robustness but low "Defense Validity"—the model fails at its intended task.
  • API Roles are Insufficient: Using "System" vs. "User" message roles in APIs does not reliably prevent injection. Attackers can craft "User" messages that the model prioritizes over the "System" instructions.

Limitations and Future Work

The authors acknowledge that the game's objective—making the model say a specific string—is a simplified version of real-world security risks. The constraints of the game might not capture every nuance of complex enterprise applications. Future work includes using this massive dataset to train more robust models, developing better automated detection for prompt extraction, and exploring how multi-step attack trajectories evolve over time in adversarial settings.

Summary updated

BibTeX
@inproceedings{toyer2024tensor,
  author = {Sam Toyer and Olivia Watkins and Ethan Adrian Mendes and Justin Svegliato and Luke Bailey and Tiffany Wang and Isaac Ong and Karim Elmaaroufi and Pieter Abbeel and Trevor Darrell and Alan Ritter and Stuart Russell},
  title = {{Tensor Trust: Interpretable Prompt Injection Attacks from an Online Game}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=fsW7wJGLBd},
}
Figure