mlsanityData to 14 Oct 2026

PISanitizer: Preventing Prompt Injection to Long-Context LLMs via Prompt Sanitization

arXiv 2511.10720 ↗First posted 13 Nov 2025cs.CR cs.AI cs.CLcited by 13

On the map: LLM safety and security → Prompt injection and agent security

Abstract (arXiv)

Long context LLMs are vulnerable to prompt injection, where an attacker can inject an instruction in a long context to induce an LLM to generate an attacker-desired output. Existing prompt injection defenses are designed for short contexts. When extended to long-context scenarios, they have limited effectiveness. The reason is that an injected instruction constitutes only a very small portion of a long context, making the defense very challenging. In this work, we propose PISanitizer, which first pinpoints and sanitizes potential injected tokens (if any) in a context before letting a backend LLM generate a response, thereby eliminating the influence of the injected instruction. To sanitize injected tokens, PISanitizer builds on two observations: (1) prompt injection attacks essentially craft an instruction that compels an LLM to follow it, and (2) LLMs intrinsically leverage the attention mechanism to focus on crucial input tokens for output generation. Guided by these two observations, we first intentionally let an LLM follow arbitrary instructions in a context and then sanitize tokens receiving high attention that drive the instruction-following behavior of the LLM. By design, PISanitizer presents a dilemma for an attacker: the more effectively an injected instruction compels an LLM to follow it, the more likely it is to be sanitized by PISanitizer. Our extensive evaluation shows that PISanitizer can successfully prevent prompt injection, maintain utility, outperform existing defenses, is efficient, and is robust to optimization-based and strong adaptive attacks. The code is available at https://github.com/sleeepeer/PISanitizer.

Key facts. Cited by 13 papers in the map (data through 14 Oct 2026). Placed in Prompt injection and agent security, one of 12 directions in LLM safety and security. First posted on arXiv 13 Nov 2025.

Builds on

0 of 0 references.

No references here yet.

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 13.

13 papers.

Sort:

By area:

Similar, not cited

Close in wording, no citation either way

  1. 2025Robustness via Referencing: Defending against Prompt Injection Attacks by Referencing the Executed Instruction
  2. 2025Defending Against Prompt Injection With a Few DefensiveTokens
  3. 2025LLMail-Inject: A Dataset from a Realistic Adaptive Prompt Injection Challenge
  4. 2026Know Thy Enemy: Securing LLMs Against Prompt Injection via Diverse Data Synthesis and Instruction-Level Chain-of-Thought Learning
  5. 2026LongPIBench: A Long-Context Benchmark for Prompt Injection
  6. 2023Evaluating the Instruction-Following Robustness of Large Language Models to Prompt Injection
  7. 2024Defense Against Prompt Injection Attack by Leveraging Attack Techniques
  8. 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Models