Skip to content

A critical evaluation of defenses against prompt injection attacksA Critical Evaluation of Defenses against Prompt Injection Attacks

arXiv· arXiv:2505.18333· SACMAT· Yuqi Jia, Zedian Shao, Yupei Liu, Jinyuan Jia, Dawn Song, Neil Zhenqiang GongDuke University; The Pennsylvania State University; UC BerkeleyIndexed by this site · 27 days ago· Originally publishedSelected EvaluationSelectedAttention42

Quick read

Evaluation and benchmarks

Based on the paper PDF (AI-generated); refer to the original

The authors re-evaluate prompt injection defenses with a unified method, claiming that StruQ, SecAlign, Instruction Hierarchy, PromptGuard and Attention Tracker are all less effective than reported in the original papers.

Questions
Prompt injection defenses often claim to be effective, but the authors believe that existing evaluations are not rigorous in attack types, metrics, and benchmarks, and may overestimate the utility and effectiveness of defenses.
Methods
The authors propose evaluating along two dimensions, utility and effectiveness: utility considers absolute utility and FPR, effectiveness considers ASV and FNR, and the evaluation must cover existing and adaptive attacks as well as diverse targets/injected prompts, and re-evaluate five defenses using OpenPromptInjection and a self-built MMLU-PI.
Experiments and results
The authors report: StruQ and SecAlign show a decrease in absolute utility, and the ASV of adaptive GCG reaches 1.00; GPT-4o-mini has an ASV of 0.68–0.75 under the existing Combined Attack; PromptGuard has an FPR of 0.89; Attention Tracker reaches an FNR of 1.00 under adaptive attack.
Limitations and future work
The authors do not devote a separate Limitations section. Experimental coverage: StruQ/SecAlign are based on Llama-3-8B(-Instruct), Instruction Hierarchy is evaluated with GPT-4o-mini, and the detection defenses are PromptGuard and Attention Tracker; GCG uses only 50/25 tuples, and the hardware is a single RTX A5000.
Experimental setupLlama-3-8B-Instruct-StruQ、Llama-3-8B-Instruct-SecAlign et al. · OpenPromptInjection、MMLU-PI et al. · ASV、FPR et al.
Threat model
The attacker embeds an injection prompt in untrusted data, making the LLM execute the attacker-chosen injection task instead of the target task; attacks fall into heuristic and optimization-based (GCG) categories, and adaptive attacks can optimize the separator z, z||se or z||pe for a specific defense.
Evaluated models
Llama-3-8B-Instruct-StruQLlama-3-8B-Instruct-SecAlignLlama-3-8B-StruQLlama-3-8B-SecAlignGPT-4o-miniPromptGuardAttention Tracker
Benchmarks
OpenPromptInjectionMMLU-PIAlpacaFarm
Metrics
ASVFPRFNRAUCwin rateabsolute utility
AI summaryand selection rationaleResearchers from Duke University, Pennsylvania State University, and UC Berkeley propose a principled method for evaluating prompt injection defenses, re-testing recent defenses along the two dimensions of effectiveness and general utility, and find that their performance is worse than reported in the original papers. The method requires testing existing and adaptive attacks on diverse target and injection prompts, replacing relative win rates with absolute utility, and replacing AUC-only evaluation of detection methods with FPR/FNR. Code and data are open-sourced at https://github.com/PIEval123/PIEval。

Researchers from Duke University, Pennsylvania State University, and UC Berkeley propose a principled method for evaluating prompt injection defenses, re-testing recent defenses along the two dimensions of effectiveness and general utility, and find that their performance is worse than reported in the original papers. The method requires testing existing and adaptive attacks on diverse target and injection prompts, replacing relative win rates with absolute utility, and replacing AUC-only evaluation of detection methods with FPR/FNR. Code and data are open-sourced at https://github.com/PIEval123/PIEval。

Why it was selectedThe paper proposes an evaluation method that tests both effectiveness and general utility, re-tests multiple mainstream prompt injection defenses with adaptive attacks, and finds that their effectiveness is generally lower than originally reported.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    The authors argue that evaluation methods for prompt injection defenses are not rigorous, causing their utility and effectiveness to be overestimated.

    Core problem: prompt injection defenses lack a principled evaluation methodology, and their conclusions of "successful defense" may be unreliable.

    • Setting and importance: LLM prompts are assembled from instructions and data; when the data comes from untrusted sources, an attacker can embed an injected prompt so that the model performs the attacker-chosen task; the authors state this can bring risks such as reputational damage, system prompt leakage, and manipulation of agent tool selection.
    • Shortcomings of existing evaluations: The authors point out that multiple prevention-type defenses evaluate effectiveness using only a single injected prompt (e.g., "Print exactly Hacked!"); utility is measured only with relative metrics such as win rate, and the defended model and the control model may be equally bad; detection-type defenses mostly ignore adaptive attacks, and some look only at AUC, which cannot reflect classification performance at deployment.
    • Core claim: Defenses should be evaluated along two dimensions—effectiveness (against existing and adaptive attacks, diverse objectives and injected prompts) and general utility (not harming the LLM's basic capabilities); detection defenses should use FPR/FNR rather than only AUC.
    • Paper contributions: The authors present this evaluation methodology and use it to re-evaluate five recent defenses—StruQ, SecAlign, Instruction Hierarchy, PromptGuard, and Attention Tracker—which the authors state are all less successful than reported in the original papers; the authors also open-sourced the code and data.
    • Threat model (copied from the paper's setting):
      • Attacker goal: Make the LLM complete the attacker-chosen injected task (se, xe, re) rather than the target task (st, xt, rt).
      • Capability: Insert the injected prompt pe = se||xe into the target data xt, constructing a separator z so that the contaminated data is xc = xt||z||pe; optimization-based attacks can optimize z, z||se, or z||pe, depending on the attacker's capability in the threat model.
      • Attack types: heuristic attacks (Naive, Context Ignoring, Fake Completion, Escape Character, Combined) and optimization-based attacks (GCG); adaptive attacks are tailored to specific defenses.
      • Victim systems: LLMs that process untrusted data, and detectors that detect contaminated data.
  2. What related research exists?

    Related work is grouped into prompt injection attacks, prevention defenses, and detection defenses; this paper positions itself as a rigorous re-evaluation of them.

    Prompt injection attacks

    • Willison (2022), Perez and Ribeiro (2022), Greshake et al. (2023), etc.—proposed and formalized prompt injection attacks, including indirect injection; Branch et al. (2022) proposed heuristic attacks such as Context Ignoring.
    • Liu et al. (2024), Pasquini et al. (2024), Hui et al. (2024), Shi et al. (2024)—optimization-based attacks that use GCG (Zou et al., 2023) to optimize separators or contaminated data.
    • Liu et al. (USENIX Security 2024, OpenPromptInjection)—formalized prompt injection attacks and defenses and built a benchmark; the paper notes that its conclusion is that most prior prevention and detection methods are ineffective, and this paper's benchmark and task system directly follow that work.

    Prevention defenses

    • Early methods (Willison 2023, Mendes 2023, Schulhoff 2023, etc.)—preprocess instructions or data (e.g., isolating data with XML tags); the paper relays the benchmark study's conclusion: these methods have poor utility and/or effectiveness.
    • StruQ (Chen et al., USENIX Security 2025)—structures instructions and data then supervised fine-tunes; SecAlign (Chen et al., 2024)—constructs preference data and fine-tunes with DPO; Instruction Hierarchy (Wallace et al., 2024)—fine-tunes the LLM so higher-priority instructions take precedence. The paper criticizes them: StruQ and SecAlign evaluate effectiveness with only one injection prompt and utility with only win rate; Instruction Hierarchy's injection and target prompts are not publicly detailed, and none of the three adequately evaluates adaptive attacks.

    Detection defenses

    • Early methods: Perplexity Filter (Jain et al. 2023; Alon and Kamfonas 2023), Known-answer Detection (Nakajima 2022), LLM-based Detection (Armstrong 2023); the paper relays: these methods reduce utility or are ineffective against existing attacks.
    • PromptGuard (Meta, 2024)—fine-tunes mDeBERTa-v3-base for classification; Attention Tracker (Hung et al., 2024)—analyzes attention shifts to detect contaminated data; also DataSentinel (Liu et al., IEEE S&P 2025), which fine-tunes with a game-theoretic method. The paper criticizes: detection defenses mostly ignore adaptive attacks, and some (e.g., Attention Tracker) report only AUC.

    Baselines and benchmarks: this paper does not retrain defenses but directly re-evaluates the models released by the five defenses above; the evaluation benchmarks are OpenPromptInjection and the authors' self-built MMLU-PI, and utility comparison uses AlpacaFarm/AlpacaEval.

    Positioning of this paper: the authors state that prior work did not follow the evaluation paradigm of "two dimensions, multiple attacks, multiple prompts, appropriate metrics, large-scale benchmarks"; this paper re-evaluates these defenses with a unified method, providing a foundation for future defense evaluation and development.

  3. How does the paper address this problem?

    Proposes an evaluation framework along the two dimensions of utility and effectiveness, covering existing and adaptive attacks, and re-evaluates five defenses using two benchmarks.

    Overall approach: establish an evaluation methodology—utility is measured by absolute utility (prevention) and FPR (detection), effectiveness by ASV (prevention) and FNR (detection), and must cover diverse target/injection prompts, existing attacks and adaptive attacks; then re-evaluate five recent defenses using OpenPromptInjection and a self-built MMLU-PI.

    Evaluation metrics

    • Prevention utility: besides the relative metric win rate, absolute utility is required: absolute utility = 1/(|PR|)∑(p,r)∈ PR U(f(p), r), where U is a task-related metric (accuracy for classification/multiple choice, ROUGE-1 for summarization, GLEU for grammatical error correction). The authors consider win rate insufficient: a defended model and an undefended model may be equally bad, while a weak reference model still yields a high win rate.
    • Prevention effectiveness: ASV = 1/(|T|)∑(pt,rt,pe,re)∈ T U(f(pt | z | pe), re), i.e., the degree to which the defended model completes the injection task, with rt ≠ re required in T; ASV rather than ASR is used because ROUGE-1 and GLEU are not ratio metrics.
    • Detection: utility uses FPR (proportion of clean data misjudged as contaminated), effectiveness uses FNR (proportion of contaminated data misjudged as clean); the authors argue AUC only measures ranking ability, a classification threshold must be chosen at deployment, and a high AUC does not guarantee a good threshold can be found.

    Benchmark construction

    • OpenPromptInjection: P R contains 700 prompt-response pairs (100 each for 7 NLP tasks); T contains 4,900 tuples; X contains 700 clean samples; Xc contains 4,900 pairs.
    • MMLU-PI (newly built by the authors): sampled from the MMLU test set, P R contains 200 pairs, T contains 1,000 tuples, X contains 200 clean samples, Xc contains 1,000 pairs.
    • Construction: one pair is sampled from the benchmark as (pt, rt) and (pe, re) with rt ≠ re; Xc is formed by taking the data part of one prompt as x and another prompt as pe.

    Attack settings

    • Existing attacks: for heuristics, Combined Attack is used (prior work called it the most effective); for optimization-based attacks, GCG optimizes the separator z to minimize the cross-entropy loss of generating re; to save compute, GCG uses 50 tuples on OpenPromptInjection and 25 tuples on MMLU-PI.
    • Adaptive attack on StruQ/SecAlign: these two defenses use special tokens as separators and filter special tokens from data at runtime; the adaptive attack instead finds, in the vocabulary, ordinary tokens whose embeddings have the smallest ℓ2 distance to these special tokens as separators to construct injection prompts.
    • Adaptive attack framework for detection: the optimization objective is L(pt, pe, re) = −ℓe(0, D(xt | z | pe)) + α · ℓce(re, f(pt | z | pe)), minimizing both the evidence of being detected and the generation loss of the injection task; z, z||se or z||pe can be optimized. For Attention Tracker, the escape loss uses its focus score; GCG is used for optimization, α = 0.01, and the LLM is Qwen2-1.5B-Instruct, the model originally used by Attention Tracker.

    Re-evaluation targets and method

    • StruQ, SecAlign: the authors' released fine-tuned models are downloaded directly (two sets, based on Llama-3-8B-Instruct and Llama-3-8B); the reference model for win rate is changed from davinci003 in the original papers to the same-architecture Llama-3-8B-Instruct (or Llama-3-8B-undefended), with GPT-4-Turbo as judge.
    • Instruction Hierarchy: the target is GPT-4o-mini with the method deployed; absolute utility and ASV under existing attacks are measured.
    • PromptGuard, Attention Tracker: FPR, FNR, AUC are measured using open-source parameters, and an adaptive attack is applied to Attention Tracker.
  4. What experiments did the paper conduct?

    Re-evaluating five defenses: StruQ/SecAlign utility drops and adaptive GCG reaches ASV 1.00; GPT-4o-mini and the two detectors are also all broken or have high false positive rates.

    Experimental setup

    • Targets: prevention defenses are Llama-3-8B-Instruct-StruQ, Llama-3-8B-Instruct-SecAlign and the control Llama-3-8B-Instruct (the appendix additionally has three models based on Llama-3-8B); Instruction Hierarchy is evaluated with GPT-4o-mini; detection defenses are PromptGuard and Attention Tracker.
    • Benchmarks: OpenPromptInjection (700 prompt-response pairs, 4,900 tuples, 700 clean samples, 4,900 pairs) and MMLU-PI (200 pairs, 1,000 tuples, 200 clean samples, 1,000 pairs); win rate uses AlpacaFarm/AlpacaEval.
    • Attacks: existing attacks are Combined Attack and GCG; adaptive attacks are customized as described in question 3. GCG uses only 50 (OpenPromptInjection)/25 (MMLU-PI) tuples.
    • Metrics and judging: utility is win rate (judge is GPT-4-Turbo) and absolute utility (task metrics such as accuracy, ROUGE-1, GLEU); effectiveness is ASV; detection uses FPR, FNR, AUC.
    • Adaptive attack configuration: the LLM is Qwen2-1.5B-Instruct (the model originally used by Attention Tracker), α = 0.01.
    • Hardware: a single NVIDIA RTX A5000 (24GB); the paper does not report the number of repetitions.

    Main results

    Table 2: ASV of each model on OpenPromptInjection / MMLU-PI (existing → adaptive)

    Swipe horizontally to read the table

    LLMCombined (OPI)GCG (OPI)Combined (MMLU-PI)GCG (MMLU-PI)
    Llama-3-8B-Instruct-StruQ0.03 → 0.090.80 → 1.000.10 → 0.160.88 → 1.00
    Llama-3-8B-Instruct-SecAlign0.06 → 0.040.24 → 0.460.14 → 0.130.72 → 0.88
    Llama-3-8B-Instruct0.52 → 0.311.00 → 1.000.46 → 0.241.00 → 1.00
    • The authors state that, unlike the original papers' conclusion that "heuristic attack ASV is near 0 and GCG drops to 0.04/0", under diverse target and injection prompts GCG's ASV for StruQ exceeds 0.80 on both benchmarks and reaches 0.72 for SecAlign on MMLU-PI.
    • Adaptive GCG further raises ASV: the authors state it is about 0.20 higher than existing GCG on OpenPromptInjection.
    • Exception: the adaptive Combined Attack's ASV does not rise, which the authors suggest may be because its token count is about twice the original, making it hard for the model to handle in long context.

    Instruction Hierarchy (GPT-4o-mini)

    • What was measured: GPT-4o-mini's absolute utility and ASV under the existing Combined Attack.
    • Results: absolute utility 0.71 (OpenPromptInjection), 0.73 (MMLU-PI), which the authors consider as maintaining utility; but the Combined Attack's ASV reaches 0.68 and 0.75.
    • Authors' interpretation: contradicting prior claims, the authors state that Instruction Hierarchy is ineffective under diverse injection prompts.

    Detection defenses (Table 3)

    • Under existing attacks: PromptGuard's AUC is 0.92 (OpenPromptInjection)/0.75 (MMLU-PI), but FPR reaches 0.89/0.84, which the authors describe as biased toward classifying most samples as contaminated; Attention Tracker's AUC is 1.00 on both benchmarks, but its FNR on MMLU-PI is 0.69.
    • Adaptive attacks (Table 3b, FNR for Attention Tracker): optimizing only z gives 0.66 (OpenPromptInjection)/1.00 (MMLU-PI); optimizing z||se or z||pe gives 0.96/1.00; the authors also state that all samples that escaped successfully made the LLM generate re.
    • Authors' interpretation: a high AUC does not mean deployment effectiveness; detector performance differs greatly under existing and adaptive attacks, and evaluation must include adaptive attacks.

    Other ablations and analyses

    • Utility (Table 1b): Llama-3-8B-Instruct-StruQ's absolute utility drops by 0.11/0.10 relative to the control, SecAlign by 0.17/0.11 (two benchmarks).
    • win rate (Table 1a): after changing the reference to Llama-3-8B-Instruct, StruQ is 21.60% and SecAlign 36.42%.
    • Appendix A (Llama-3-8B group): win rate is close to 50% (48.04%/55.03%), but absolute utility still drops by 0.03–0.05 (Table 4); ASV conclusions are consistent with the main text (Table 5), e.g., Llama-3-8B-StruQ's ASV under existing GCG on OpenPromptInjection is 0.96.
    • In adaptive attacks, optimizing z||se rather than only z raises FNR by 0.3 on OpenPromptInjection, which the authors explain as: after some tokens in the injected instruction are replaced, the contaminated data appears to have no clear instruction.
  5. What are some points that can be further explored?

    The paper does not have a dedicated limitations discussion, only hoping that future defenses adopt this evaluation; the experiments cover five defenses and two benchmarks, and GCG uses only a small sample.

    Limitations and future directions noted by the authors

    • The paper does not specifically discuss limitations of its own method; in the Conclusion the authors only express the hope that this study will make future evaluation of prompt injection defenses more rigorous.
    • In Section 4.2.2 the authors set a methodological requirement for defense research: defense papers should make every effort to adapt existing attacks to their own defense for adaptive evaluation, otherwise effectiveness conclusions may not hold—this is the authors' call to the field, not a limitation of their own work.
    • In Section 5.1 the authors note a phenomenon-level exception: the adaptive Combined Attack's ASV does not exceed the existing version, which the authors suggest may be because its token count is about twice the original, making it hard for the model to handle in long context (this is a discussion of results, not a limitation statement).

    Scope of experimental coverage

    • Five defenses are evaluated: StruQ, SecAlign (each with two released model sets based on Llama-3-8B-Instruct and Llama-3-8B), Instruction Hierarchy (evaluated with GPT-4o-mini), PromptGuard, and Attention Tracker.
    • Benchmarks are OpenPromptInjection (7 NLP tasks, 700 pairs, 4,900 tuples) and MMLU-PI (200 pairs, 1,000 tuples); win rate is measured only on AlpacaFarm.
    • Attack coverage: existing attacks are Combined Attack and GCG; adaptive attacks cover StruQ, SecAlign and Attention Tracker, with no adaptive attack applied to PromptGuard.
    • Due to compute, GCG uses only 50 (OpenPromptInjection)/25 (MMLU-PI) tuples; all experiments are completed on a single RTX A5000 (24GB).
    • The paper does not report the number of experimental repetitions or statistical significance tests; for Instruction Hierarchy only the existing Combined Attack is tested, not GCG or adaptive attacks.
  6. Summarize the main content of the paper

    The authors propose a two-dimensional evaluation method and re-evaluate five prompt injection defenses, which they claim are all less effective than reported in the original papers.

    A critical evaluation paper on prompt injection defenses, arguing that defenses must be evaluated along two dimensions—utility and effectiveness—using diverse prompts, appropriate metrics, and existing plus adaptive attacks.

    • Problem: the authors argue existing defense evaluations are not rigorous—prevention defenses use only a single injection prompt and win rate, detection defenses ignore adaptive attacks and look only at AUC, making "defense success" conclusions unreliable.
    • Method: utility is measured by absolute utility (accuracy/ROUGE-1/GLEU) and FPR, effectiveness by ASV and FNR; benchmarks are OpenPromptInjection and a self-built MMLU-PI; adaptive attacks include imitating special separators with near-embedding tokens (for StruQ/SecAlign) and a GCG framework jointly optimizing escape loss and generation loss (for detectors).
    • Result one: StruQ and SecAlign absolute utility drops by 0.10–0.17 relative to the control (Table 1b); adaptive GCG reaches ASV 1.00 on both benchmarks for StruQ and up to 0.88 for SecAlign (Table 2).
    • Result two: GPT-4o-mini (with Instruction Hierarchy deployed) maintains utility (0.71/0.73), but the existing Combined Attack reaches ASV 0.68/0.75.
    • Result three: PromptGuard's FPR reaches 0.89/0.84; Attention Tracker's AUC is 1.00, yet under existing attacks its FNR on MMLU-PI is 0.69, and under adaptive attacks its FNR on both benchmarks reaches up to 1.00 (Table 3).
    • Authors' conclusion: evaluated by this method, existing defenses are all less successful than reported in the original papers; the authors hope this work becomes a foundation for future defense evaluation and development.

Related papers

Show 3 more papers
Read originalSACMAT