PIPETTE: Prompt Injection Purple-Teaming for Robust LLM Agents

Lipeng He, Yihan Wang, Jiawen Zhang, N. Asokan

TL;DR

PIPETTE is a "purple-teaming" framework that hardens LLM agents against indirect prompt injections by ensuring red-teaming discovers diverse attack strategies rather than repetitive variations. By combining dictionary learning to track attack diversity with reasoning-guided adversarial training, it produces agents that are highly robust to unseen attacks while maintaining their ability to perform legitimate user tasks.

What Problem Does This Paper Address?

As LLM agents move from simple chatbots to autonomous assistants that can read your emails and browse the web, they face a critical vulnerability: Indirect Prompt Injection (IPI). An attacker can hide malicious instructions in a webpage or email that "hijack" the agent, forcing it to exfiltrate data or perform unauthorized actions.

To defend against this, developers use purple-teaming: they pair an automated "red-teamer" (which tries to find successful attacks) with "blue-teaming" (adversarial training on those attacks to harden the model).

The authors identify two major gaps in current methods:

  1. Strategy-Level Mode Collapse: Current Reinforcement Learning (RL)-based red-teamers often suffer from mode collapse. They might achieve a high Attack Success Rate (ASR) by discovering one effective strategy and repeating it with slight wording changes. Training on these repetitive attacks doesn't help the agent defend against new strategies it hasn't seen before.
  2. The Utility-Robustness Trade-off: Standard adversarial training often makes agents "over-defensive." They might start refusing legitimate tasks just because the input data looks slightly suspicious, leading to a significant drop in "benign utility."
Figure 1. Prompt injection purple-teaming workflow.

Methods

PIPETTE (Prompt Injection Purple-Teaming) is a two-stage framework designed to solve these issues.

1. PIPETTE-Red: Strategy-Guided Red-Teaming

Instead of just rewarding the red-teamer for a successful attack, PIPETTE-Red rewards it for finding new strategies.

  • Strategy Primitives: It uses an LLM to decompose successful attacks into "strategy records" (e.g., "pretending the task is finished" or "framing the injection as metadata").
  • Dictionary Learning: It applies sparse dictionary learning to these records to build a library of "strategy primitives."
  • Coverage Reward: The red-teamer receives a "coverage reward" only when it produces a successful attack that cannot be easily explained by the existing dictionary. This forces the RL policy to keep exploring and uncovering diverse vulnerabilities.

2. PIPETTE-Blue: On-Policy Defensive Training

Once a diverse dataset of attacks is collected, PIPETTE-Blue hardens the agent using a specialized training pipeline.

  • Task-Alignment Reasoning: The agent is trained to follow a specific reasoning chain: first, inspect the input for injections (C1), and second, verify that the planned tool call serves the user's original goal (C2).
  • Contrastive Token-Level Reward: To avoid the "over-refusal" problem, PIPETTE uses a fine-grained reward. During training, it compares how the model would act if explicitly told to "ignore the injection" versus "follow the injection." This provides a precise signal at the token level, helping the agent learn exactly which parts of the input to ignore without abandoning the user's task.
Figure 3. Overview of PIPETTE. PIPETTE-Red (left) guides RL-based red-teaming with a periodically rebuilt strategy dictionary to collect Dtrain spanning diverse attack strategies. PIPETTE-Blue (right) trains the agent policy via on-policy RL to improve robustness while preserving utility for deployment.

Datasets

  • Training: The framework was trained on AgentDyn, a multi-step agentic benchmark covering tasks like shopping, GitHub management, and daily life.
  • Evaluation: To test generalization, the authors evaluated the hardened agents on two unseen benchmarks:
  • AgentDojo: A dynamic environment for evaluating IPI attacks across Workspace, Slack, Travel, and Banking suites.
  • Agent Security Bench (ASB): A benchmark focused on formalizing and testing various attack and defense categories.

Key Insights and Ideas

  • ASR is a Deceptive Metric: A red-teamer that achieves 70% ASR by finding one trick is less useful for defense than one that achieves 30% ASR by finding ten different tricks. Figure 2 in the paper highlights this: PISmith (a baseline) has a higher training ASR than RL-Hammer but results in a less robust agent after training.
  • Explainability as a Reward: By using an "Explainability Score" (ES) based on the strategy dictionary, the authors can quantitatively measure how "new" an attack is. As shown in the figure below, PIPETTE-Red continues to discover strategies that explain unseen attacks long after baselines have plateaued.
Figure 4. Mean Explainability Score (ES) on unseen CHATINJECT attacks for cumulative dictionaries learned from all successful injection strings up to each dictionary iteration (25 RL steps). Error bars show standard errors over 5 seeds. RL-Hammer and PISmith plateau early, but PIPETTE-Red keeps discovering strategies that explain these attacks.
  • Reasoning is a Robustness Multiplier: Forcing the agent to explicitly reason about the provenance of its instructions (is this from the user or a third party?) significantly improves its ability to resist sophisticated, multi-step injections.

Key Results

PIPETTE consistently outperformed state-of-the-art defenses across multiple LLM families (Qwen, Llama, GPT-OSS).

  • Robustness: It achieved near-zero ASR on static attacks. Against strong iterative-adaptive attacks (like TAP and GENETIC), PIPETTE reduced ASR to 0-10%, whereas undefended models often had ASRs above 70%.
  • Utility: Unlike many other defenses, PIPETTE maintained benign utility very close to the undefended baselines. For example, on Qwen3-4B, it achieved 64.95% utility compared to the baseline's 61.86% (actually slightly higher due to the reasoning training).
  • Efficiency: PIPETTE-Red reaches the "bottom-right corner" of the evaluation space—high training-time discovery paired with low inference-time vulnerability.
Figure 5. Train-time vs inference-time ASR, showing PIPETTE-Red in the ideal bottom-right corner.

Limitations and Future Work

  • Inference Latency: The requirement for the agent to generate explicit reasoning steps before acting adds a small amount of overhead (roughly 0.5 seconds per rollout).
  • Single-Pass Training: The current work uses a single pass of red-teaming followed by blue-teaming. The authors suggest that a multi-round "continuous purple-teaming" approach could uncover even deeper vulnerabilities that only emerge after the model has been partially hardened.
  • LLM Grader Dependency: The "Explainability Score" relies on an auxiliary LLM grader, which itself might have biases or limitations in understanding complex attack strategies.

Summary updated

Abstract

Large language model (LLM) agents routinely interact with untrusted external data, exposing them to indirect prompt injection (IPI) attacks that hijack agents into executing attacker-chosen tasks. To uncover these vulnerabilities at scale, automated red-teaming methods often leverage reinforcement learning (RL) to generate attacks that achieve high attack success rates (ASR). Model developers use the attacks discovered during internal red-teaming to harden agents through adversarial training before deployment, a collaborative offensive-defensive process known in cybersecurity as purple-teaming. However, we show that achieving high ASR during red-teaming does not guarantee robustness gains from subsequent adversarial training. Specifically, we find that two state-of-the-art RL-based red-teaming methods, RL-Hammer and PISmith, suffer from mode collapse, repeatedly discovering similar attack strategies whose additional successes add no additional robustness improvements to adversarial training. To address this gap, we introduce PIPETTE, a unified prompt injection purple-teaming framework that effectively converts red-teaming discoveries into defender robustness improvements. PIPETTE employs a dictionary learning-based reward that encourages broader coverage of attack strategies during red-teaming. It also integrates an on-policy adversarial training pipeline tailored to IPI defense, enabling agents to resist attacks while completing legitimate user tasks. Extensive evaluations across agentic benchmarks (AgentDojo and ASB) demonstrate that PIPETTE produces defenders that achieve near-zero attack success rates on static attacks and can withstand strong adaptive attacks, while maintaining benign task utility close to that of the undefended baseline.
BibTeX
@misc{he2026pipette,
  author = {Lipeng He and Yihan Wang and Jiawen Zhang and N. Asokan},
  title = {{PIPETTE: Prompt Injection Purple-Teaming for Robust LLM Agents}},
  year = {2026},
  eprint = {2611.24362},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.24362},
}

Loading related content...

Figure