arXiv:2610.08571cs.CROct 2026

Manuscript Offprint

arXiv:2610.08571

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

Niveen O. Jaffal, Ahmet Yuksel, David Mohaisen

Niveen O. Jaffal 1^{1}, Ahmet Yuksel 2^{2}, and David Mohaisen 3^{3}

1^{1} Birzeit University, Birzeit, Palestine

njaffal@birzeit.edu

2^{2} Independent Researcher

asyuksel5@gmail.com

3^{3} University of Central Florida, Orlando, FL, USA

mohaisen@ucf.edu

Abstract. Retrieval-Augmented Generation (RAG) systems are vulnerable to prompt-injection attacks embedded in retrieved content. We introduce RAG-PIBench, a benchmark for RAG-style prompt-injection detection containing 4,876 contextual examples across frozen train, validation, and protected-test splits. Using a leakage-aware construction pipeline and strict evaluation protocol, we compare keyword-based, semantic-reference, TF-IDF, and transformer-based detectors. DistilBERT achieves the best protected-test performance ( F1=0.896F_1 = 0.896, PR-AUC = 0.968), while TF-IDF SVM and logistic regression remain competitive. Our results demonstrate the value of leakage-aware benchmark design and strong sparse baselines for reliable prompt-injection detection in RAG systems.

Keywords: Prompt injection · Retrieval-Augmented Generation · RAG security · Large language models · Benchmark construction · Prompt-injection detection

1 Introduction & Problem Statement

Retrieval-Augmented Generation (RAG) has become a widely adopted approach for improving large language models (LLMs) by incorporating external documents into the generation context [21,16,15]. While RAG can improve factual grounding and domain adaptation [17], it also expands the attack surface of LLM-based systems. In particular, prompt-injection attacks can be embedded within retrieved content, causing the model to follow adversarial instructions rather than the intended system objective [18,2].

Detecting prompt injection in RAG contexts is challenging because benign documents may naturally contain instructions, code snippets, examples, or task descriptions. Moreover, malicious instructions can be paraphrased, blended into otherwise legitimate content, or designed to resemble benign contextual information. As a result, simple keyword-based defenses often fail, while more sophisticated approaches may over-flag benign content or rely on dataset artifacts rather than robust semantic signals [4,6,5][4,6,5].

A variety of detection approaches have been proposed, ranging from heuristic filters and semantic-reference methods to sparse-feature classifiers and transformer-based

N. O. Jaffal et al.

models [3,12]. However, comparisons across these detector families are often complicated by inconsistent evaluation protocols, potential leakage between training and testing data, and the absence of strong lightweight baselines.

Problem Statement. Despite growing interest in prompt-injection defenses, there remains a need for leakage-aware benchmarks that evaluate whether detectors can reliably distinguish benign contextual instructions from malicious instruction-override attempts in realistic RAG inputs. Existing evaluations may overestimate performance due to lexical shortcuts, repeated templates, or insufficient separation between dataset construction and testing. This work addresses the problem of constructing and evaluating a reproducible RAG-style prompt-injection benchmark that supports fair comparison across heuristic, semantic, sparse-feature, and transformer-based detectors.

Research Questions. This study is guided by four research questions: RQ1. How effectively do different detector families distinguish benign RAG-style contextual inputs from malicious prompt-injection under a frozen protected-test evaluation protocol? RQ2. Do compact transformer classifiers provide measurable gains over strong baseline detectors, or can sparse lexical and character-level models remain competitive? RQ3. What precision-recall trade-offs and failure modes emerge across keyword heuristics, semantic-reference methods, TF-IDF classifiers, and transformer models? RQ4. How can dataset construction, split isolation, diagnostic separation, and artifact registration reduce leakage and improve the reliability of prompt-injection detector evaluation?

Contributions. To address these questions, this paper makes five contributions: ① RAG-PIBench Benchmark. We introduce RAG-PIBench, a balanced benchmark for RAG-style prompt-injection detection containing 4,876 rendered contextual examples across frozen train, validation, and protected-test splits. ② Leakage-Aware Construction Pipeline. We develop a dataset-construction pipeline incorporating source registration, provenance tracing, quality control, style-matched rendering, shortcut auditing, and frozen split generation to reduce shortcut learning and improve auditability. ③ Protected-Test Evaluation Protocol. We implement a strict train/validation/protected-test protocol that isolates model training, selection, and final evaluation while keeping diagnostic analyses separate from tuning decisions. ④ Systematic Baseline Evaluation. We compare keyword rules, semantic-reference methods, TF-IDF LR, TF-IDF SVM, TF-IDF RF, DistilBERT, and DeBERTa-v3 to assess whether transformer models provide meaningful gains over strong lightweight baselines. ⑤ Transparent Findings and Failure Modes. We report both strengths and weaknesses of the evaluated detectors, showing that DistilBERT achieves the best protected-test performance while TF-IDF SVM and TF-IDF LR remain highly competitive, and identifying key failure modes across detector families.

Positioning. RAG-PIBench extends our broader line of work on trustworthy and secure LLMs, which has examined LLM attack surfaces and defenses, security of generated code, attribution of LLM-generated artifacts, and systematic evaluation of LLMs in security applications [9,10,1,13]. Here, we focus specifically on indirect prompt injection in RAG settings and on leakage-aware evaluation of prompt-injection detectors.

References (24)