Heads of Security: Learned Attention Gates Improve Prompt Injection Robustness
On the map: LLM safety and security → Prompt injection and agent security also fits: Backdoor and data poisoning attacks
Abstract (arXiv)
We introduce Heads of Security (HoS), a prompt injection defense that enforces instruction-data separation via a small set of learned per-head attention gates. HoS learns how each head should redistribute attention between trusted and untrusted tokens, enabling models to reason over untrusted content without following injected instructions. We evaluate HoS on Llama-3.3-70B-Instruct and GPT-OSS-20B. We compare it against SecAlign++, a state-of-the-art finetuning-based defense, and ASIDE, a defense that, like ours, builds instruction-data separation into the model architecture. We show that HoS offers greater robustness to adaptive attacks, better performance on standard utility benchmarks, and matches top performance on standard agentic prompt injection benchmarks. More specifically, the black-box RL-Hammer attack reaches 97% ASR against GPT-OSS-20B and 85% against SecAlign, but only 10% against HoS. Claudini, a state-of-the-art white-box attack, strengthened against HoS through autoresearch, requires 3 times more FLOPs to reach the same ASR on HoS as it does on GPT-OSS-20B or SecAlign. HoS preserves base-model utility across standard multiple-choice benchmarks and prompting setups, whereas SecAlign and ASIDE degrade in few-shot settings. On agentic benchmarks with static attacks, HoS and SecAlign perform similarly and substantially improve the security-utility trade-off over the base model. ASIDE struggles with tool use, achieving only 10% utility. These results show that prompt injection robustness can be achieved and improved through targeted attention interventions.
Key facts. No citing papers in the map yet (data through 24 Nov 2026). Placed in Prompt injection and agent security, one of 12 directions in LLM safety and security. Builds on 55 of its 65 references that are in the map. Submitted 27 Oct 2026.
Builds on
55 of 65 references.
Closest ancestors · 21
Same direction, newest first
- 2026AI Agents May Always Fall for Prompt Injections17 May
- 2026Claudini: Autoresearch Discovers State-of-the-Art Adversarial Attack Algorithms for LLMs25 Mar
- 2026How Vulnerable Are AI Agents to Indirect Prompt Injections? Insights from a Large-Scale Public Competition16 Mar
- 2026Skill-Inject: Measuring Agent Vulnerability to Skill File Attacks23 Feb
- 2026Prompt Injection as Role Confusion22 Feb
- 2025Attention is All You Need to Defend Against Indirect Prompt Injection Attacks in LLMs9 Dec
- 2025RL Is a Hammer and LLMs Are Nails: A Simple Reinforcement Learning Recipe for Strong Prompt Injection6 Oct
- 2025LLMail-Inject: A Dataset from a Realistic Adaptive Prompt Injection Challenge11 Jun
- 2025Defending against Indirect Prompt Injection by Instruction Detection8 May
- 2025WASP: Benchmarking Web Agent Security Against Prompt Injection Attacks22 Apr
- 2025Defeating Prompt Injections by Design24 Mar
- 2025ASIDE: Architectural Separation of Instructions and Data in Language Models13 Mar
9 more
- 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
- 2024Get my drift? Catching LLM Task Drift with Activation Deltas2 Jun
- 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions19 Apr
- 2024InjecAgent: Benchmarking Indirect Prompt Injections in Tool-Integrated Large Language Model Agents5 Mar
- 2024StruQ: Defending Against Prompt Injection with Structured Queries9 Feb
- 2023Tensor Trust: Interpretable Prompt Injection Attacks from an Online Game2 Nov
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection23 Feb
Other references · 34
- 2017Attention Is All You Needcited by 62,125
- 2024The Llama 3 Herd of Modelscited by 16,113
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 10,542
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,494
- 2020Measuring Massive Multitask Language Understandingcited by 8,473
- 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 5,336
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,374
- 2024MMLU-Pro: A More Robust and Challenging Multi-Task Language Understanding Benchmarkcited by 2,076
- 2025gpt-oss-120b & gpt-oss-20b Model Cardcited by 1,638
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,269
- 2019Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Prunedcited by 899
- 2023AlpacaFarm: A Simulation Framework for Methods that Learn from Human Feedbackcited by 766
22 more
- 2024Gated Delta Networks: Improving Mamba2 with Delta Rulecited by 690
- 2024Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attackscited by 520
- 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Lengthcited by 455
- 2024Massive Activations in Large Language Modelscited by 343
- 2024Retrieval Head Mechanistically Explains Long-Context Factualitycited by 272
- 2023Can LLMs Keep a Secret? Testing Privacy Implications of Language Models via Contextual Integrity Theorycited by 262
- 2024When Attention Sink Emerges in Language Models: An Empirical Viewcited by 236
- 2025The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses Against Llm Jailbreaks and Prompt Injectionscited by 164
- 2023Tell Your Model Where to Attend: Post-hoc Attention Steering for LLMscited by 102
- 2024Can LLMs Separate Instructions From Data? And What Do We Even Mean By That?cited by 90
- 2026AgentDyn: Are Your Agent Security Defenses Deployable in Real-World Dynamic Environments?cited by 81
- 2023Can LLMs Follow Simple Rules?cited by 50
- 2024Efficient LLM Jailbreak via Adaptive Dense-to-sparse Constrained Optimizationcited by 22
- 2025Causal Head Gating: A Framework for Interpreting Roles of Attention Heads in Transformerscited by 20
- 2024Improved Generation of Adversarial Examples Against Safety-aligned LLMscited by 19
- 2024An Interpretable N-gram Perplexity Threat Model for Large Language Model Jailbreakscited by 13
- 2025Universal Jailbreak Suffixes Are Strong Attention Hijackerscited by 13
- 2024Testing the Limits of Jailbreaking Defenses with the Purple Problemcited by 11
- 2025Gandalf the Red: Adaptive Security for LLMscited by 11
- 2025Instruction Following by Principled Boosting Attention of Large Language Modelscited by 11
- 2024Logicbreaks: A Framework for Understanding Subversion of Rule-based Inferencecited by 5
- 2026Robust Harmful Features Under Jailbreak Attacks: Mechanistic Evidence from Attention Head Specialization in Large Language Modelscited by 2
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026BASIS: Breach-Aware Selective Prompt Injection Shielding with Prefill Attention Probes
- 2025May I have your Attention? Breaking Fine-Tuning based Prompt Injection Defenses using Architecture-Aware Attacks
- 2026Attention Is Where You Attack
- 2026LTBD: Learnable Trust-Boundary Delimiters for Prompt Injection Defense
- 2025Stronger Enforcement of Instruction Hierarchy via Augmented Intermediate Representations
- 2026Defending against Adaptive Prompt Injection Attacks via Reasoning-enabled Task Alignment
- 2026Beyond Over-Refusal: Defending Indirect Prompt Injection via Latent Instruction Manifolds
- 2026Know Thy Enemy: Securing LLMs Against Prompt Injection via Diverse Data Synthesis and Instruction-Level Chain-of-Thought Learning