Skip to content

RAG-PIBench: A Leakage-Aware Benchmark for Prompt Injection Detection in Trustworthy RAG SystemsRAG-PIBench: A Leakage-Aware Benchmark for Prompt-Injection Detection in Trustworthy RAG Systems

arXiv: Jailbreaks, Prompt Injection, Poisoning & Defenses· arXiv:2610.08571· Niveen O. Jaffal, Ahmet Yuksel, David Mohaisen·Indexed by this site · 2026-10-07· Originally publishedEvaluation

Quick read

Evaluation and benchmarks

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

The authors propose RAG-PIBench (4,876 cases); DistilBERT achieves an F1 of 0.896 on the protected test set.

Questions
RAG-retrieved content can embed indirect prompt injection, benign documents can also contain instructions, and detection can be inflated by lexical shortcuts and training-test leakage. The authors want a leakage-aware benchmark that can distinguish benign contextual instructions from malicious instruction overrides.
Methods
RAG-PIBench renders host contexts with embedded snippets into RAG-style inputs, labels malicious by coverage intent, and benign can also contain instructions. After provenance, quality control, and shortcut auditing, training, validation, and held-out test sets are frozen, and keyword, MiniLM reference, TF-IDF, and two encoders are compared.
Experiments and results
On the 978-example protected test set, DistilBERT achieves an F1 of 0.896 and PR-AUC of 0.968; TF-IDF SVM achieves an F1 of 0.871. Keyword recall is 0.104. DeBERTa-v3 classifies all samples as malicious, with precision 0.500.
Limitations and future work
The authors note that only binary detection is done without downstream mitigation, results are limited to this benchmark rather than universally applicable; transformers are only two encoders, the main test set is class-balanced, and inputs are English only. Experiments are evaluated once on the 978-example held-out test set, the diagnostic suite does not participate in model selection, and the paper does not report its scores.
Experimental setupDistilBERT-base-uncased、DeBERTa-v3-base et al. · RAG-PIBench · F1、Precision et al.
Evaluated models
DistilBERT-base-uncasedDeBERTa-v3-baseTF-IDF SVMTF-IDF LRTF-IDF RFMiniLM Ref.
Benchmarks
RAG-PIBench
Metrics
F1PrecisionRecallPR-AUCROC-AUCAccuracy
AI summaryThe researchers propose RAG-PIBench, a benchmark for RAG-style prompt injection detection, containing 4,876 context samples divided into frozen training, validation, and protected test sets. The benchmark employs a leakage-aware construction pipeline and a strict evaluation protocol, comparing keyword-based, semantic reference, TF-IDF, and transformer-based detectors. DistilBERT achieves the best performance on the protected test set (F1 = 0.896, PR-AUC = 0.968), while TF-IDF SVM and logistic regression remain competitive.

The researchers propose RAG-PIBench, a benchmark for RAG-style prompt injection detection, containing 4,876 context samples divided into frozen training, validation, and protected test sets. The benchmark employs a leakage-aware construction pipeline and a strict evaluation protocol, comparing keyword-based, semantic reference, TF-IDF, and transformer-based detectors. DistilBERT achieves the best performance on the protected test set (F1 = 0.896, PR-AUC = 0.968), while TF-IDF SVM and logistic regression remain competitive.

Related events and news

1 events · 1 news mentions

News that mentions this paper

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    A leakage-aware benchmark is needed to distinguish benign instructions from malicious overrides in RAG contexts.

    How to build a leakage-aware benchmark to assess whether detectors can distinguish benign instructions from malicious instruction overrides in RAG contexts.

    • Scenario: The authors state that when RAG places external documents into the generation context, prompt injection in the retrieved content can cause the model to follow adversarial instructions rather than system goals. Benign documents may also contain instructions, code, examples, or task descriptions, and malicious instructions can be rewritten or mixed into legitimate content.
    • Existing shortcomings: The authors state that keyword defenses often fail; more complex methods may mislabel benign content or rely on dataset artifacts rather than robust semantic signals. The authors also state that existing evaluations may overestimate performance due to lexical shortcuts, repetitive templates, or insufficient separation between dataset construction and testing.
    • Authors' definition: Malicious intent is to override, bypass, redirect, or manipulate the assistant's established instruction-following behavior; benign content may contain instructions but lacks that intent. Therefore, the task is not to detect whether instructions are present in the text.
    • Proposed object: RAG-PIBench, with 4,876 rendered context samples, frozen into training, validation, and protected test sets; and under the same protocol, comparing keyword, semantic reference, TF-IDF, and transformer detectors.
    • Threat model:
      • Goal: Indirect prompt injection. An attacker wants instructions embedded in retrieved content to alter the assistant's behavior. The paper evaluates detection, not whether generation-side attacks succeed.
      • Scope of control: The attacker controls or influences external text that may be retrieved and written into the model's context, but does not control user queries or system prompts.
      • Detection location: The detector performs binary classification on the rendered RAG-style input before generation.
      • Boundaries delineated in the paper: Only English text is included; downstream generation, tool misuse, data exfiltration, retrieval poisoning, or post-detection mitigation are not evaluated.
  2. What related research exists?

    The authors state that existing benchmarks place less emphasis on leakage-aware protection testing, and defense protocols are also difficult to compare directly.

    The paper organizes related work around indirect prompt injection benchmarks and RAG defenses. The authors state that the former has limited emphasis on leakage-aware detector evaluation and protection testing, while the latter's evaluation protocols vary widely.

    Prompt injection benchmarks

    • PromptShield (marked as 2025 in Table 1) – studies deployable prompt injection detection under realistic false-positive constraints.
    • PromptSleuth (2025) studies detection under rewriting and distribution shift; BIPIA (2025) studies indirect prompt injection in retrieved content, marked in Table 1 as involving both IPI and RAG.
    • INJECAGENT (2024) evaluates indirect prompt injection in tool-integrated agents; WAInjectBench (2025) evaluates web agents, marked in Table 1 as involving both text and image modalities.

    RAG defenses

    • Adaptive multi-layer framework and LLM Self Defense – the paper introduces the former for detecting and mitigating prompt injection, and the latter using an auxiliary LLM for post-generation verification.
    • TrustRAG and SeCon-RAG (both 2025 in Table 1) – target trustworthy RAG and two-stage semantic filtering with conflict handling, respectively.
    • Palisade (2024) – a detection framework combining rules, classifiers, and companion models. The authors state that these defenses improve robustness, but evaluation protocols vary greatly, making direct comparison difficult.

    Baselines and data used in this paper

    • Baseline methods: Keyword, MiniLM Ref., TF-IDF LR, TF-IDF SVM, TF-IDF RF, and DistilBERT-base-uncased, DeBERTa-v3-base.
    • Benchmark and sources: The evaluation benchmark is RAG-PIBench. Host documents come from WikiText-2, CNN/DailyMail, SQuAD; payload parents come from S-Labs, PromptShield, Natural Instructions, BIPIA.

    The authors position RAG-PIBench as a complement: leakage-aware binary detection on RAG-style contexts, rather than primarily measuring attack success rates or evaluating only a single detector family. The authors state three distinguishing points are leakage-aware benchmark construction, comparing transformers with lightweight baselines together, and reporting both successful results and failure modes. In Table 1, RAG-PIBench is marked with ✓ in the leakage, baseline, and failure mode columns, while the other listed works are marked with – or ◦; the table note does not define the difference between these two symbols.

  3. How does the paper address this problem?

    Constructs RAG-PIBench with provenance, quality control, and frozen splits, and compares seven detectors on the held-out test set.

    The authors build RAG-PIBench with a leakage-aware pipeline, then compare seven detectors on frozen training, validation, and held-out test sets; detection is done before generation, and it does not measure whether attacks change the final answer.

    Task Definition

    • Input: Each sample is rendered text containing a host context and an embedded snippet.
    • Mapping: The detector learns f(xi)→yi, where yi∈0,1, with 0 for benign and 1 for prompt injection.
    • Positive class: The embedded content attempts to cover, bypass, redirect, or manipulate the downstream assistant's instruction-following behavior. Benign samples can contain legitimate tasks or instructions but lack that intent.
    • Scope: In addition to overall classification, the balance between malicious detection and false positives on benign instruction text is considered. Downstream generation, tool misuse, data exfiltration, retrieval poisoning, and post-detection mitigation are not evaluated; inputs are limited to English.

    Data Construction

    Fig 1 has four stages: source registration, pattern validation and provenance; candidate review; RAG-style rendering and leakage audit; frozen splits, model development, and held-out testing.

    • Hosts and payloads: Hosts come from WikiText-2, CNN/DailyMail, and SQuAD. Fig 2(a) shows 42.9% each for CNN/DailyMail and SQuAD and 14.3% for WikiText-2 across 3,500 host documents. Payload parents come from S-Labs, PromptShield, Natural Instructions, and BIPIA; the caption states 192 each for benign and malicious parent pools.
    • Rendering: Host context plus embedded snippet, with benign and malicious pairs, using various wrapper styles and variable insertion positions. Both sides retain instruction-like wording to avoid the task degenerating into detecting whether an imperative sentence appears.
    • Quality control: Checks pattern consistency, duplication, provenance, label consistency, and shortcut artifacts. Automated analysis only assists review and does not assign final labels. Ambiguous, unsupported, not matching the task definition, or potentially artifact-inducing samples are excluded or re-reviewed. Inclusion decisions are made before model evaluation, and the held-out test is inaccessible during development.
    • Audit and scale: Audits duplicate content, split contamination, repeated templates, source markers, and format artifacts; issues are corrected, removed, or explicitly registered. Diagnostic analysis is separate from model selection and held-out testing. Table 2: training 2,936 (1,468 each), validation 962 (481 each), held-out test 978 (489 each), total 4,876, with 2,438 per class. The held-out test text is opened only once.

    Detector Configuration

    • Keyword: Deterministic lexical patterns. Table 8 states no training-time tuning.
    • MiniLM Ref.: Scores by maximum similarity to a malicious reference library; the decision threshold is selected only on the validation set.
    • TF-IDF: LR and linear SVM use word-level and character-level features; RF in Table 8 uses word-level TF-IDF. Hyperparameters are selected only on the validation set. The paper does not report specific values.
    • Encoders: DistilBERT-base-uncased has a maximum sequence length of 256; DeBERTa-v3-base has 192 and uses a conservative numerical stability configuration. Both are trained on the training set and checkpoints are selected by validation. These settings are fixed before the held-out test and not changed afterward.

    Evaluation Protocol

    • Single held-out test: Training uses only the training set, and model selection uses only the validation set. The held-out test is opened only once for final inference. Afterward, no re-selecting checkpoints, re-tuning thresholds, additional training, or using diagnostic feedback for tuning is allowed. All seven detectors use the same 978 examples. Transformer results on the validation set must not enter the final comparison table.
    • Diagnostic separation: There are three additional suites: wide context, hard benign utility, and external transfer/source audit. Table 7 states they do not participate in ranking, threshold tuning, or post-hoc correction.
    • Metrics: The malicious class is the positive class. Accuracy, Precision, Recall, F1, PR-AUC, ROC-AUC, and confusion matrix are reported. The authors use F1 as the primary ranking metric because classes are balanced and both missed detections and false positives need to be weighed. Precision is TP divided by TP+FP, Recall is TP divided by TP+FN, and F1 is their harmonic mean.
    • Traceability: Audit artifacts, checklists, and checksums are registered at each stage. The final comparison table is frozen only after splits are fixed, baseline results are registered, transformer training/validation and held-out testing are separated, and all detectors have been evaluated on the same test set.
  4. What experiments did the paper conduct?

    On the held-out test set, DistilBERT's F1 is 0.896, and the authors state that TF-IDF baselines remain competitive.

    Only one final comparison is made on the same 978-example balanced protected test set: in Table 3, DistilBERT's F1 is the highest in the column, followed by the three TF-IDF variants; Keyword misses many detections, and DeBERTa-v3 classifies all samples as malicious.

    Experimental setup

    • Detectors: Keyword; MiniLM Ref.; TF-IDF LR; TF-IDF SVM; TF-IDF RF; DistilBERT-base-uncased; DeBERTa-v3-base. Total of 7.
    • Data: RAG-PIBench has 4,876 examples in total. Training 2,936, validation 962, protected test 978, with equal numbers of both classes in each split (Table 2). The protected test has 489 benign and 489 malicious.
    • Sources: Hosts are CNN/DailyMail, SQuAD, WikiText-2. Fig 2 counts 3,500 documents, with the first two each at 42.9% and WikiText-2 at 14.3%. Payload parents are S-Labs, PromptShield, Natural Instructions, BIPIA, with 192 each in the benign and malicious pools.
    • Configuration: DistilBERT max sequence length 256; DeBERTa-v3 is 192 and uses a conservative numerical stability configuration. MiniLM thresholds and TF-IDF hyperparameters are selected only on the validation set; Keyword has no training-phase tuning (Table 8). The paper does not report learning rate, batch size, or n-gram range.
    • Metrics and labeling: The malicious class is the positive class. The primary metric is F1, while Precision, Recall, Accuracy, PR-AUC, ROC-AUC, and confusion matrices are also reported. Labels are determined at construction time. The paper does not use LLM evaluation, nor does it report significance tests or repeated runs.
    • Protocol: The protected test is not visible during development and is inferred only once at the end. No post-hoc checkpoint selection, threshold retuning, or tuning with diagnostic suites is allowed. Diagnostic suites do not enter model ranking.

    Main results

    According to Table 3, on the 978-example balanced protected test set, the malicious class is the positive class.

    Swipe horizontally to read the table

    ModelPrec.Rec.F1PR-AUCAcc.
    DistilBERT0.9240.8690.8960.9680.899
    TF-IDF SVM0.8530.8900.8710.9500.868
    TF-IDF LR0.8220.9160.8670.9500.859
    TF-IDF RF0.8220.8790.8500.9330.845
    MiniLM Ref.0.5080.9690.6670.5760.515
    DeBERTa-v30.5001.0000.6670.4880.500
    Keyword0.9810.1040.1890.5500.551
    • The authors state that DistilBERT achieves a better balance between detecting malicious samples and preserving benign utility, and the advantage does not come solely from a single threshold; in Table 3 its ROC-AUC is 0.967, also the highest in that column.
    • The authors state that relative to the strongest sparse baseline, DistilBERT's F1 increases from 0.871 to 0.896, a limited gain, indicating that word- and character-level cues capture much of the separable signal. The authors also state that TF-IDF SVM and LR have lower computational cost, are easier to train, and are more interpretable; the paper does not report runtime.
    • The authors state that Keyword covers only a small portion of obvious attacks and is not suitable as a standalone defense; MiniLM Ref. may mislabel a large portion of benign content. DeBERTa-v3 shows all-positive predictions. The authors consider this reflects the conservative training and numerical stability configuration used rather than the architecture necessarily being unsuitable; and state that it completed training and evaluation but did not learn a usable decision boundary.

    Confusion matrices and error trade-offs

    Counts at the operating point on the same 978 examples are shown in Table 6.

    • DistilBERT: 454 true negatives, 35 false positives, 64 false negatives, 425 true positives.
    • Sparse models: TF-IDF SVM has 75 false positives and 54 false negatives; TF-IDF LR has 97 false positives and 41 false negatives. The authors state the former leans toward precision and the latter toward recall. TF-IDF RF has 396/93/59/430 (TN/FP/FN/TP).
    • Extremes: Keyword has 488 true negatives, 1 false positive, 438 false negatives, 51 true positives. MiniLM Ref. has 30/459/15/474. DeBERTa-v3 has 0/489/0/489.

    Diagnostics, ranking, and author discussion

    • Diagnostics: Table 7's contextual diagnostic, hard benign diagnostic, and external transfer audit are used only for behavioral analysis. The paper does not report Precision, Recall, or F1 for these three sets and states they do not participate in final ranking, threshold setting, or post-hoc corrections.
    • Ranking and recall: The authors state that one should look at both the operating point and ranking. TF-IDF LR and SVM both have a ROC-AUC of 0.949 in Table 3. The authors state that labeling every sample as malicious would not miss attacks but would also reject all benign content.
    • Interpretation of the benchmark: The authors state that TF-IDF's performance indicates the task contains learnable lexical and structural signals, and its gap over Keyword indicates signals beyond simple rules. The authors consider DistilBERT's improvement over the strongest TF-IDF to be limited, keeping classic baselines informative; and state that model capacity alone does not determine protected test results, as training stability, optimization, sequence length, and checkpoint selection all affect outcomes.

    Other ablations and analyses

    • The paper does not report metrics after varying learning rate, sequence length, n-gram, or regularization strength; there is no numerical ablation table.
    • Table 3 ROC-AUC: DistilBERT 0.967, TF-IDF SVM 0.949, TF-IDF LR 0.949, TF-IDF RF 0.931, MiniLM Ref. 0.571, DeBERTa-v3 0.487, Keyword 0.551.
    • Figure 3 bar labels for F1 and PR-AUC match Table 3, including MiniLM Ref. and DeBERTa-v3 both having F1 = 0.667.
    • Table 5 registers: no duplicate leakage of rendered text across splits; protected test texts are held out during training and validation.
    • Table 8: RF uses only word-level TF-IDF; LR and SVM use word- and character-level; the paper does not provide separate ablation numbers for this difference.
  5. What are some points that can be further explored?

    The authors note that only detection is evaluated, not mitigation, and results should not be extrapolated as universally applicable evidence.

    The authors, in Section 4.8 and the conclusion, limit the scope to English binary detection for this benchmark, and list future directions such as multilingual, adversarial generation, and joint evaluation of detection and mitigation.

    Limitations and future directions identified by the authors

    • No mitigation: Only binary detection is evaluated, not strategies such as isolation, sanitization, ignoring, citing, or escalating retrieved content (4.8).
    • Extrapolation boundary: Style matching, provenance, deduplication, and leakage audits still cannot eliminate all distributional artifacts. The authors state that results should be interpreted as performance on RAG-PIBench, not as evidence universally applicable to prompt injection attacks (4.8).
    • Encoder scope: The transformers include only two encoders, and the training and selection protocol is frozen. The authors write that larger encoders, decoder-only models, instruction-tuned classifiers, and retrieval-aware architectures may exhibit different characteristics; DeBERTa-v3's findings should be understood within the evaluated training and numerical stability configuration (4.8).
    • Class prior: The main protected test set is class-balanced. The authors state that real-world class priors may differ, and calibration and threshold selection may require additional validation independent of the protected test data (4.8).
    • Language and transfer: Limited to English text. The authors propose future examination of multilingual prompt injection, cross-domain transfer, adversarial generated content, and application-specific RAG environments (4.8).
    • Extensions in the conclusion: Broader model families, multimodal prompt injection scenarios, and deployment-oriented research evaluating both detection and mitigation jointly (Section 5).

    Experimental coverage

    • Main results include Keyword, MiniLM Ref., TF-IDF LR, TF-IDF SVM, TF-IDF RF, DistilBERT-base-uncased, DeBERTa-v3-base, each with a single final inference on the same 978 examples (Section 4, Table 3, Table 8).
    • Splits: training 2,936, validation 962, protected test 978, with equal class counts in each split (Table 2).
    • Host documents: 3,500 from CNN/DailyMail, SQuAD, WikiText-2; payload parents: 192 each in the benign and malicious pools from S-Labs, PromptShield, Natural Instructions, BIPIA (Fig 2).
    • Diagnostic suites: contextual diagnostic, hard benign diagnostic, external transfer audit; Table 7 states they do not participate in model selection, threshold setting, or main ranking. The paper does not report scores for these three sets.
    • The paper does not report the number of human annotators and agreement, repeated runs, statistical significance tests, or learning rate, batch size, and TF-IDF n-gram range.
  6. Summarize the main content of the paper

    On the protected test set, DistilBERT achieves an F1 of 0.896, and TF-IDF SVM achieves 0.871.

    RAG-PIBench uses a frozen held-out test set to compare whether detectors can separate benign and malicious instructions in RAG contexts.

    • Problem: External text retrieved into the context can carry indirect prompt injection, and benign documents also contain instructions. The authors argue that lexical shortcuts, repeated templates, and train-test non-isolation may overestimate detectors.
    • Approach: Host paragraphs come from CNN/DailyMail, SQuAD, and WikiText-2; payload parents come from S-Labs, PromptShield, Natural Instructions, and BIPIA. After rendering, there are 4,876 examples: 2,936 training, 962 validation, and 978 held-out test, with each class half. Detection is a binary classification before generation; malicious is defined by coverage, bypass, redirection, or manipulation of instruction-following behavior.
    • Protocol: Keyword, MiniLM malicious reference, three TF-IDF variants, and DistilBERT-base-uncased and DeBERTa-v3-base all do not see the held-out test during development, and each is evaluated once on the same 978 examples. The diagnostic suite does not participate in model selection.
    • Results: DistilBERT has F1 of 0.896, PR-AUC of 0.968, ROC-AUC of 0.967, and Accuracy of 0.899 (Table 3). TF-IDF SVM has F1 of 0.871, and TF-IDF LR has PR-AUC of 0.950. Keyword recall is 0.104. DeBERTa-v3 has recall of 1.000 and precision of 0.500, with 489 false positives and 0 true negatives in Table 6.
    • Authors' conclusions: The authors argue that contextual representations can provide gains, but sparse baselines remain competitive, and future comparisons should include sparse models rather than only heuristic detectors. They state that high recall is insufficient if false positives are not controlled; if only successful transformer results are reported, evaluation is inflated. They also state that freezing splits and separating diagnostic from final testing helps reduce opportunities for leakage and evaluation bias.
Read originalarxiv.org