Defending Against Prompt Injection With a Few DefensiveTokens
On the map: LLM safety and security → Prompt injection and agent security
Abstract (arXiv)
When large language model (LLM) systems interact with external data to perform complex tasks, a new attack, namely prompt injection, becomes a significant threat. By injecting instructions into the data accessed by the system, the attacker is able to override the initial user task with an arbitrary task directed by the attacker. To secure the system, test-time defenses, e.g., defensive prompting, have been proposed for system developers to attain security only when needed in a flexible manner. However, they are much less effective than training-time defenses that change the model parameters. Motivated by this, we propose DefensiveToken, a test-time defense with prompt injection robustness comparable to training-time alternatives. DefensiveTokens are newly inserted as special tokens, whose embeddings are optimized for security. In security-sensitive cases, system developers can append a few DefensiveTokens before the LLM input to achieve security with a minimal utility drop. In scenarios where security is less of a concern, developers can simply skip DefensiveTokens; the LLM system remains the same as there is no defense, generating high-quality responses. Thus, DefensiveTokens, if released alongside the model, allow a flexible switch between the state-of-the-art (SOTA) utility and almost-SOTA security at test time. The code is available at https://github.com/Sizhe-Chen/DefensiveToken.
Key facts. Cited by 33 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. Builds on 27 of its 51 references that are in the map. First posted on arXiv 10 Jul 2025.
Builds on
27 of 51 references.
Closest ancestors · 12
Same direction, newest first
- 2025DataSentinel: A Game-Theoretic Detection of Prompt Injection Attacks15 Apr
- 2025Defeating Prompt Injections by Design24 Mar
- 2024Attention Tracker: Detecting Prompt Injection Attacks in LLMs1 Nov
- 2024Instructional Segment Embedding: Improving LLM Safety with Instruction Hierarchy9 Oct
- 2024SecAlign: Defending Against Prompt Injection with Preference Optimization7 Oct
- 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions19 Apr
- 2024Neural Exec: Learning (and Learning from) Execution Triggers for Prompt Injection Attacks6 Mar
- 2024InjecAgent: Benchmarking Indirect Prompt Injections in Tool-Integrated Large Language Model Agents5 Mar
- 2024StruQ: Defending Against Prompt Injection with Structured Queries9 Feb
- 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Models21 Dec
- 2023Formalizing and Benchmarking Prompt Injection Attacks and Defenses19 Oct
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection23 Feb
Other references · 15
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,915
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,651
- 2023PyTorch FSDP: Experiences on Scaling Fully Sharded Data Parallelcited by 660
- 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 653
- 2023Jailbreak and Guard Aligned Language Models with Only Few In-Context Demonstrationscited by 431
- 2024Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attackscited by 156
- 2024On Prompt-Driven Safeguarding for Large Language Modelscited by 116
- 2024Can LLMs Separate Instructions From Data? And What Do We Even Mean By That?cited by 81
- 2024Fight Back Against Jailbreaking via Prompt Adversarial Tuningcited by 67
Built on by
Citing papers per year: 2025: 7; 2026: 26.
33 papers.
Sort:
By area:
- 2025AgentArmor: Enforcing Program Analysis on Agent Runtime Trace to Defend Against Prompt Injectioncited by 46
- 2025Defending Against Prompt Injection with DataFiltercited by 35
- 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysiscited by 30
- 2025BrowseSafe: Understanding and Preventing Prompt Injection Within AI Browser Agentscited by 24
- 2026MUZZLE: Adaptive Agentic Red-Teaming of Web Agents Against Indirect Prompt Injection Attackscited by 21
- 2025Systems Security Foundations for Agentic Computingcited by 13
- 2025CommandSans: Securing AI Agents with Surgical Precision Prompt Sanitizationcited by 12
- 2026AgentSys: Secure and Dynamic LLM Agents Through Explicit Hierarchical Memory Managementcited by 10
- 2025Taxonomy, Evaluation and Exploitation of IPI-Centric LLM Agent Defense Frameworkscited by 9
- 2026The Promptware Kill Chain: How Prompt Injections Gradually Evolved Into a Multistep Malware Delivery Mechanismcited by 9
- 2025AttnTrace: Contextual Attribution of Prompt Injection and Knowledge Corruptioncited by 7
- 2026AgentVisor: Defending LLM Agents Against Prompt Injection via Semantic Virtualizationcited by 6
21 more
- 2026Adversarial Attacks on Multimodal Large Language Models: A Comprehensive Surveycited by 4
- 2026Context Contamination in LLM Analysis of Network Security Logs: Poison with Passive Prompt Injection and Mitigation Evaluationcited by 3
- 2026Hidden State Poisoning Attacks against Mamba-based Language Modelscited by 2
- 2026RedVisor: Reasoning-Aware Prompt Injection Defense via Zero-Copy KV Cache Reusecited by 2
- 2026No More, No Less: Task Alignment in Terminal Agentscited by 2
- 2026Security--Fidelity Tradeoffs: The Hidden Cost of Prompt Injection Defensecited by 2
- 2026Reasoning Hijacking: The Fragility of Reasoning Alignment in Large Language Modelscited by 1
- 2026Persuasion Tokens for Editing Factual Knowledge in LLMscited by 1
- 2026Towards Poisoning Robustness Certification for Natural Language Generationcited by 1
- 2026ASPI: Seeking Ambiguity Clarification Amplifies Prompt Injection Vulnerability in LLM Agentscited by 1
- 2026Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifoldscited by 1
- 2026Hidden Risks of Jev: An Empirical Study of Security, Privacy, and Dual Usecited by 1
- 2026Self-Adaptive Multi-Agent LLM-Based Security Pattern Selection for IoT Systemscited by 0
- 2026Certified Robustness under Heterogeneous Perturbations via Hybrid Randomized Smoothingcited by 0
- 2026On the Geometric Limits of Transformer Defenses against Obfuscation Attacks: Latent Embedding Collapse & Performance Robustness Gapcited by 0
- 2026Rapid Poison: Practical Poisoning Attacks Against the Rapid Response Frameworkcited by 0
- 2026Data Leakage Prevention in Agentic Applications via Preemptive Hardeningcited by 0
- 2026InceptionRAG: Stealthy Poisoning Attack Against Retrieval-Augmented Generationcited by 0
- 2026CounterSteer: Suppressing Indirect Prompt Injection with Activation Steeringcited by 0
- 2026MASCRDM: Multi-Agent System for Compliance Risk Detection and Mitigation in Training Process of Large Language Modelscited by 0
- 2026BrowseSafe++: Benchmarking Prompt Injection Detection Across Web Contexts, Languages, and Browser Viewscited by 0
- 2026BrowseSafe++: Benchmarking Prompt Injection Detection Across Web Contexts, Languages, and Browser Views12 Oct 2026
- 2026Hidden Risks of Jev: An Empirical Study of Security, Privacy, and Dual Use4 Oct 2026
- 2026MASCRDM: Multi-Agent System for Compliance Risk Detection and Mitigation in Training Process of Large Language Models30 Sep 2026
- 2026CounterSteer: Suppressing Indirect Prompt Injection with Activation Steering29 Sep 2026
- 2026InceptionRAG: Stealthy Poisoning Attack Against Retrieval-Augmented Generation15 Sep 2026
- 2026Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifolds23 Aug 2026
- 2026Data Leakage Prevention in Agentic Applications via Preemptive Hardening21 Jul 2026
- 2026Context Contamination in LLM Analysis of Network Security Logs: Poison with Passive Prompt Injection and Mitigation Evaluation16 Jul 2026
- 2026Security--Fidelity Tradeoffs: The Hidden Cost of Prompt Injection Defense29 Jun 2026
- 2026Rapid Poison: Practical Poisoning Attacks Against the Rapid Response Framework15 Jun 2026
- 2026On the Geometric Limits of Transformer Defenses against Obfuscation Attacks: Latent Embedding Collapse & Performance Robustness Gap18 May 2026
- 2026ASPI: Seeking Ambiguity Clarification Amplifies Prompt Injection Vulnerability in LLM Agents17 May 2026
21 more
- 2026Certified Robustness under Heterogeneous Perturbations via Hybrid Randomized Smoothing13 May 2026
- 2026No More, No Less: Task Alignment in Terminal Agents12 May 2026
- 2026Self-Adaptive Multi-Agent LLM-Based Security Pattern Selection for IoT Systems1 May 2026
- 2026AgentVisor: Defending LLM Agents Against Prompt Injection via Semantic Virtualization27 Apr 2026
- 2026Adversarial Attacks on Multimodal Large Language Models: A Comprehensive Survey30 Mar 2026
- 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysis11 Feb 2026
- 2026Towards Poisoning Robustness Certification for Natural Language Generation10 Feb 2026
- 2026MUZZLE: Adaptive Agentic Red-Teaming of Web Agents Against Indirect Prompt Injection Attacks9 Feb 2026
- 2026AgentSys: Secure and Dynamic LLM Agents Through Explicit Hierarchical Memory Management7 Feb 2026
- 2026RedVisor: Reasoning-Aware Prompt Injection Defense via Zero-Copy KV Cache Reuse2 Feb 2026
- 2026Persuasion Tokens for Editing Factual Knowledge in LLMs23 Jan 2026
- 2026Reasoning Hijacking: The Fragility of Reasoning Alignment in Large Language Models15 Jan 2026
- 2026The Promptware Kill Chain: How Prompt Injections Gradually Evolved Into a Multistep Malware Delivery Mechanism14 Jan 2026
- 2026Hidden State Poisoning Attacks against Mamba-based Language Models5 Jan 2026
- 2025Systems Security Foundations for Agentic Computing1 Dec 2025
- 2025BrowseSafe: Understanding and Preventing Prompt Injection Within AI Browser Agents25 Nov 2025
- 2025Taxonomy, Evaluation and Exploitation of IPI-Centric LLM Agent Defense Frameworks19 Nov 2025
- 2025Defending Against Prompt Injection with DataFilter22 Oct 2025
- 2025CommandSans: Securing AI Agents with Surgical Precision Prompt Sanitization9 Oct 2025
- 2025AttnTrace: Contextual Attribution of Prompt Injection and Knowledge Corruption5 Aug 2025
- 2025AgentArmor: Enforcing Program Analysis on Agent Runtime Trace to Defend Against Prompt Injection2 Aug 2025
- 2025AgentArmor: Enforcing Program Analysis on Agent Runtime Trace to Defend Against Prompt Injectioncited by 46
- 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysiscited by 30
- 2026MUZZLE: Adaptive Agentic Red-Teaming of Web Agents Against Indirect Prompt Injection Attackscited by 21
- 2025Systems Security Foundations for Agentic Computingcited by 13
- 2025CommandSans: Securing AI Agents with Surgical Precision Prompt Sanitizationcited by 12
- 2026AgentSys: Secure and Dynamic LLM Agents Through Explicit Hierarchical Memory Managementcited by 10
- 2025Taxonomy, Evaluation and Exploitation of IPI-Centric LLM Agent Defense Frameworkscited by 9
- 2026AgentVisor: Defending LLM Agents Against Prompt Injection via Semantic Virtualizationcited by 6
- 2026ASPI: Seeking Ambiguity Clarification Amplifies Prompt Injection Vulnerability in LLM Agentscited by 1
- 2026Self-Adaptive Multi-Agent LLM-Based Security Pattern Selection for IoT Systemscited by 0
- 2026Data Leakage Prevention in Agentic Applications via Preemptive Hardeningcited by 0
- 2026CounterSteer: Suppressing Indirect Prompt Injection with Activation Steeringcited by 0
12 most cited of 13 All 13 (JSON)
- 2026MASCRDM: Multi-Agent System for Compliance Risk Detection and Mitigation in Training Process of Large Language Models30 Sep 2026
- 2026CounterSteer: Suppressing Indirect Prompt Injection with Activation Steering29 Sep 2026
- 2026Data Leakage Prevention in Agentic Applications via Preemptive Hardening21 Jul 2026
- 2026ASPI: Seeking Ambiguity Clarification Amplifies Prompt Injection Vulnerability in LLM Agents17 May 2026
- 2026Self-Adaptive Multi-Agent LLM-Based Security Pattern Selection for IoT Systems1 May 2026
- 2026AgentVisor: Defending LLM Agents Against Prompt Injection via Semantic Virtualization27 Apr 2026
- 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysis11 Feb 2026
- 2026MUZZLE: Adaptive Agentic Red-Teaming of Web Agents Against Indirect Prompt Injection Attacks9 Feb 2026
- 2026AgentSys: Secure and Dynamic LLM Agents Through Explicit Hierarchical Memory Management7 Feb 2026
- 2025Systems Security Foundations for Agentic Computing1 Dec 2025
- 2025Taxonomy, Evaluation and Exploitation of IPI-Centric LLM Agent Defense Frameworks19 Nov 2025
- 2025CommandSans: Securing AI Agents with Surgical Precision Prompt Sanitization9 Oct 2025
12 newest of 13 All 13 (JSON)
- 2025Defending Against Prompt Injection with DataFiltercited by 35
- 2025BrowseSafe: Understanding and Preventing Prompt Injection Within AI Browser Agentscited by 24
- 2026The Promptware Kill Chain: How Prompt Injections Gradually Evolved Into a Multistep Malware Delivery Mechanismcited by 9
- 2026Context Contamination in LLM Analysis of Network Security Logs: Poison with Passive Prompt Injection and Mitigation Evaluationcited by 3
- 2026Security--Fidelity Tradeoffs: The Hidden Cost of Prompt Injection Defensecited by 2
- 2026Reasoning Hijacking: The Fragility of Reasoning Alignment in Large Language Modelscited by 1
- 2026Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifoldscited by 1
- 2026Hidden Risks of Jev: An Empirical Study of Security, Privacy, and Dual Usecited by 1
- 2026On the Geometric Limits of Transformer Defenses against Obfuscation Attacks: Latent Embedding Collapse & Performance Robustness Gapcited by 0
- 2026Rapid Poison: Practical Poisoning Attacks Against the Rapid Response Frameworkcited by 0
- 2026BrowseSafe++: Benchmarking Prompt Injection Detection Across Web Contexts, Languages, and Browser Viewscited by 0
- 2026BrowseSafe++: Benchmarking Prompt Injection Detection Across Web Contexts, Languages, and Browser Views12 Oct 2026
- 2026Hidden Risks of Jev: An Empirical Study of Security, Privacy, and Dual Use4 Oct 2026
- 2026Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifolds23 Aug 2026
- 2026Context Contamination in LLM Analysis of Network Security Logs: Poison with Passive Prompt Injection and Mitigation Evaluation16 Jul 2026
- 2026Security--Fidelity Tradeoffs: The Hidden Cost of Prompt Injection Defense29 Jun 2026
- 2026Rapid Poison: Practical Poisoning Attacks Against the Rapid Response Framework15 Jun 2026
- 2026On the Geometric Limits of Transformer Defenses against Obfuscation Attacks: Latent Embedding Collapse & Performance Robustness Gap18 May 2026
- 2026Reasoning Hijacking: The Fragility of Reasoning Alignment in Large Language Models15 Jan 2026
- 2026The Promptware Kill Chain: How Prompt Injections Gradually Evolved Into a Multistep Malware Delivery Mechanism14 Jan 2026
- 2025BrowseSafe: Understanding and Preventing Prompt Injection Within AI Browser Agents25 Nov 2025
- 2025Defending Against Prompt Injection with DataFilter22 Oct 2025
- 2026No More, No Less: Task Alignment in Terminal Agentscited by 2
- 2026Persuasion Tokens for Editing Factual Knowledge in LLMscited by 1
- 2026Towards Poisoning Robustness Certification for Natural Language Generationcited by 1
- 2026Certified Robustness under Heterogeneous Perturbations via Hybrid Randomized Smoothingcited by 0
- 2026Certified Robustness under Heterogeneous Perturbations via Hybrid Randomized Smoothing13 May 2026
- 2026No More, No Less: Task Alignment in Terminal Agents12 May 2026
- 2026Towards Poisoning Robustness Certification for Natural Language Generation10 Feb 2026
- 2026Persuasion Tokens for Editing Factual Knowledge in LLMs23 Jan 2026
Similar, not cited
Close in wording, no citation either way
- 2024Defense Against Prompt Injection Attack by Leveraging Attack Techniques
- 2026Evaluation of Prompt Injection Defenses in Large Language Models
- 2025A Critical Evaluation of Defenses against Prompt Injection Attacks
- 2024Automatic and Universal Prompt Injection Attacks against Large Language Models
- 2023Jatmo: Prompt Injection Defense by Task-Specific Finetuning
- 2025Robustness via Referencing: Defending against Prompt Injection Attacks by Referencing the Executed Instruction
- 2025PISanitizer: Preventing Prompt Injection to Long-Context LLMs via Prompt Sanitization
- 2024FATH: Authentication-based Test-time Defense against Indirect Prompt Injection Attacks