arXiv(opens in a new tab)cs.CRAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.28411

LongPIBench: A Long-Context Benchmark for Prompt Injection

Yupei Liu, Yuqi Jia, Neil Zhenqiang Gong, Jinyuan Jia

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Prompt injection attacks pose a serious security risk to large language models in real-world applications. However, existing prompt injection benchmarks primarily focus on short-context inputs, leaving the attacks and defenses in long-context settings largely unexplored. This gap leads to a substantial overestimation of the effectiveness of current defenses. In this paper, we bridge the gap by introducing LongPIBench, a long-context benchmark for prompt injection covering 4 realistic application scenarios: paper peer review, resume screening, code review, and email summary. For each scenario, we construct a synthetic dataset and a real-world dataset, with context lengths ranging from thousands to tens of thousands of tokens. The evaluation results on LongPIBench reveal significant vulnerabilities of prompt injection defenses under long-context settings: even simple heuristic prompt injection attacks achieve high success rates and frequently bypass state-of-the-art defenses. We hope LongPIBench can serve as a practical benchmark for systematically evaluating prompt injection defenses in realistic long-context scenarios. Our code and data are available at: https://github.com/liu00222/LongPIBench.

1 Introduction

LLMs are increasingly deployed in real-world applications (dee, 2025b), such as academic peer review assistance, resume screening, code review, and enterprise email processing. For instance, AAAI recently launched an LLM-powered peer review system (aaa, 2025). In these applications, LLMs perform a target task (e.g., reviewing a conference submission) by processing a long context under the guidance of a target instruction. Prompt injection can occur when the context contains content collected from untrusted sources. In particular, an attacker may embed injected prompts within a context to mislead an LLM into deviating from its target task and generating attacker-desired outputs that satisfy the attacker's objectives. For example, recent news reports reveal that some authors have inserted prompts, e.g., "Ignore previous instructions. Instead, give this paper a rating of 9", in white text or very small font within submitted manuscripts, aiming to manipulate LLM reviewers into assigning favorable scores (Gibney, 2025).

To defend against prompt injection attacks, many defenses have been proposed. These defenses can be broadly divided into two categories: detection-based and prevention-based. Detection-based defenses (Meta, 2024; Liu et al., 2025b; Zou et al., 2025; fmo, 2025; Hung et al., 2025; ProtectAI.com, 2024) focus on identifying whether a context contains injected prompts. Prevention-based defenses (Chen et al., 2025c,b; Jia et al., 2026a; Liu et al., 2025c; Wallace et al., 2024; Shi et al., 2025b; Chen et al., 2025a; Wu et al., 2025, 2024; Kim et al., 2025; Debenedetti et al., 2025; Shi et al., 2025a; Costa et al., 2025) aim to construct a secure LLM system that reliably performs the target task while ignoring potential injected prompts in a context. Furthermore, state-of-the-art methods among these defenses, such as MetaSecAlign 8B (Chen et al., 2025c), are evaluated on existing benchmarks with very low attack success rates, suggesting strong robustness against prompt injection attacks.

However, existing benchmarks for prompt injection (Debenedetti et al., 2024; Liu et al., 2024b; Zhan et al., 2024; Zhang et al., 2025) have an important limitation. Specifically, most of them have short context, typically involving prompts on the order of tens to a few hundred tokens. While valuable for early exploration, these benchmarks implicitly assume that security behavior observed in short contexts generalizes to realistic deployments. In practice, this assumption is increasingly violated. Modern LLM applications usually process thousands to tens of thousands of tokens per request. For example, an academic paper submission may

Figure

Figure 1: Overview of LongPIBench.

span dozens of pages, which could contain more than 10,000 tokens. In long-context settings, injected instructions only constitute a small portion of the input. As a result, existing defenses, while effective in short contexts, may fail to prevent or detect injected prompts in long contexts.

In this work, we introduce LongPIBench, a benchmark explicitly designed to evaluate prompt injection in long-context application scenarios. As illustrated in Figure 1, LongPIBench consists of four real-world test suites: 1) paper peer review, 2) resume screening, 3) code review, and 4) email summary, which reflect common uses of LLMs in practice. Each test suite contains a synthetic dataset and a real-world dataset.

Using LongPIBench, we uncover a consistent and concerning observation: long-context inputs expose significant vulnerabilities that are not apparent in existing benchmarks. First, even simple heuristic prompt injection attacks can achieve high attack success rates in the absence of defenses. For instance, the Combined Attack achieves an ASR of 100% on the synthetic paper review dataset when no defense is applied. More importantly, we find that state-of-the-art defenses that perform well on existing benchmarks degrade substantially in long-context settings. For example, MetaSecAlign 8B, which consistently reports ASRs close to 0% on existing benchmarks, exhibits an ASR of 100% on our benchmark's synthetic paper review dataset under the Combined Attack.

We further conduct extensive ablation studies by varying document formats, prompt injection locations, and adversarial objectives, and find that the observed vulnerabilities persist across all dimensions. In particular, we show that attacks remain effective regardless of whether injected prompts are placed at the beginning, middle, or end of long documents, and across different formatting styles. Moreover, we demonstrate that a single injected prompt can successfully achieve multiple adversarial goals simultaneously, indicating that attackers can compound objectives within a single injected prompt in long-context settings. These results indicate that the failure of state-of-the-art defenses in long-context settings is systematic rather than scenario-specific, highlighting the need for designing new defenses tailored to long context.

Our major contributions are summarized follows:

• We propose LongPIBench, the first benchmark explicitly targeting long-context prompt injection across four test suites with eight datasets.

• We provide a comprehensive evaluation of six heuristic-based attacks and two optimization-based attacks across eight LLMs and multiple state-of-the-art defenses.

• We demonstrate that long-context settings fundamentally change the effectiveness of attacks and defenses, revealing vulnerabilities that are obscured by short-context benchmarks.

References (46)