InjecGuard: Benchmarking and Mitigating Over-defense in Prompt Injection Guardrail Models

Hao Li, Xiaogeng Liu
10/30/2024
cs.CLcs.AIcs.CR

No official code found. Best implementation: leolee99/PIGuard (77 stars, MIT, last commit 2025-12-04).

Abstract

Prompt injection attacks pose a critical threat to large language models (LLMs), enabling goal hijacking and data leakage. Prompt guard models, though effective in defense, suffer from over-defense -- falsely flagging benign inputs as malicious due to trigger word bias. To address this issue, we introduce NotInject, an evaluation dataset that systematically measures over-defense across various prompt guard models. NotInject contains 339 benign samples enriched with trigger words common in prompt injection attacks, enabling fine-grained evaluation. Our results show that state-of-the-art models suffer from over-defense issues, with accuracy dropping close to random guessing levels (60%). To mitigate this, we propose InjecGuard, a novel prompt guard model that incorporates a new training strategy, Mitigating Over-defense for Free (MOF), which significantly reduces the bias on trigger words. InjecGuard demonstrates state-of-the-art performance on diverse benchmarks including NotInject, surpassing the existing best model by 30.8%, offering a robust and open-source solution for detecting prompt injection attacks. The code and datasets are released at https://github.com/leolee99/InjecGuard.

View on arXivView PDF

Code Implementations(1)

leolee99/PIGuardCommunity100%
MIT

[ACL 2025] The official implementation of the paper "PIGuard: Prompt Injection Guardrail via Mitigating Overdefense for Free".

779PythonOct 25, 202410 months agoMIT

Similar Papers

Cite this paper

@article{li2024injecguard,
  title  = {InjecGuard: Benchmarking and Mitigating Over-defense in Prompt Injection Guardrail Models},
  author = {Hao Li and Xiaogeng Liu},
  year   = {2024},
  eprint = {2410.22770},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.22770v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.22770.svg)](https://codeofpaper.com/paper/2410.22770)

Discussion