Skip to content

Defending Against Prompt Injection with a Few Defensive TokensDefending Against Prompt Injection With a Few DefensiveTokens

arXiv· arXiv:2507.07974· ACM Workshop on Artificial Intelligence and Security· Sizhe Chen, Yizhu Wang, Nicholas Carlini, Chawin Sitawarin, David Wagner·Indexed by this site · 26 days ago· Originally publishedDefenses
AI summary

The researchers propose DefensiveToken, a test-time defense method against prompt injection that inserts special tokens with safety-optimized embeddings before the LLM input. In safety-sensitive scenarios, system developers can prepend a small number of DefensiveTokens before the LLM input to obtain safety protection with minimal utility loss; when safety requirements are not high, they can be skipped directly, and the system maintains the same high-quality output as without defense. The authors claim that its prompt injection robustness is comparable to training-time defense schemes, allowing the system to flexibly switch between SOTA utility and near-SOTA security at test time. The code is open-sourced at https://github.com/Sizhe-Chen/DefensiveToken。

Read originalACM Workshop on Artificial Intelligence and Security