# Heads of Security: Learned Attention Gates Improve Prompt Injection Robustness

DevFeed: [Heads of Security: Learned Attention Gates Improve Prompt Injection Robustness](<https://devfeed.tech/articles/heads-of-security-learned-attention-gates-improve-prompt-injection-robustness-103386.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.37657>)

Author: Igor Shilov, Xiaoxue Yang, Alexander Panfilov, Evgenii Kortukov, Matthieu Meeus, Peter Romov, Wojciech Samek, Jonas Geiping, Yves-Alexandre de Montjoye

Published: 2026-10-28T04:00:00Z

Content type: article

Language: en

Sources: [arXiv: Cryptography and Security](<https://devfeed.tech/sources/arxiv-cryptography-and-security.md>), [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>)

Topics: [prompt injection](<https://devfeed.tech/topics/prompt-injection.md>), [LLM security](<https://devfeed.tech/topics/llm-security.md>), [ai security](<https://devfeed.tech/topics/ai-security.md>), [Machine learning](<https://devfeed.tech/topics/machine-learning.md>)

Tags: [adaptive](<https://devfeed.tech/tags/adaptive.md>), [agentic](<https://devfeed.tech/tags/agentic.md>), [allows](<https://devfeed.tech/tags/allows.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [asr](<https://devfeed.tech/tags/asr.md>), [attack](<https://devfeed.tech/tags/attack.md>), [attacks](<https://devfeed.tech/tags/attacks.md>), [attention](<https://devfeed.tech/tags/attention.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [cs-cl](<https://devfeed.tech/tags/cs-cl.md>), [cs-cr](<https://devfeed.tech/tags/cs-cr.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [defense](<https://devfeed.tech/tags/defense.md>), [gpt](<https://devfeed.tech/tags/gpt.md>), [gpt-oss](<https://devfeed.tech/tags/gpt-oss.md>), [llama-3-3](<https://devfeed.tech/tags/llama-3-3.md>), [model-architecture](<https://devfeed.tech/tags/model-architecture.md>), [models](<https://devfeed.tech/tags/models.md>), [prompt-injection](<https://devfeed.tech/tags/prompt-injection.md>), [results](<https://devfeed.tech/tags/results.md>), [rl](<https://devfeed.tech/tags/rl.md>), [robustness](<https://devfeed.tech/tags/robustness.md>), [security](<https://devfeed.tech/tags/security.md>)

## AI overview

Heads of Security (HoS) uses a small set of learned per-head attention gates to separate trusted instructions from untrusted content while still allowing models to reason about that content. In evaluations on Llama-3.3-70B-Instruct and GPT-OSS-20B, HoS reduced RL-Hammer attack success to 10%, compared with 97% against GPT-OSS-20B and 85% against SecAlign. Against a strengthened white-box Claudini attack, reaching the same success rate on HoS required three times the FLOPs reported for GPT-OSS-20B or SecAlign. HoS preserved base-model utility across the reported multiple-choice benchmarks and prompting setups; SecAlign and ASIDE degraded in few-shot settings. On static-attack agentic benchmarks, HoS and SecAlign performed similarly, while ASIDE achieved only 10% utility and struggled with tool use. These are reported results on the evaluated models and benchmarks.

## Source excerpt

arXiv:2610.37657v1 Announce Type: cross Abstract: 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.