NTH

Heads of Security: Learned Attention Gates Improve Prompt Injection Robustness

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

AffiliationsFraunhofer HHI ∗ †

November 1, 2026 2 min read
Watch on YouTube
The one-line take

HoS adds learned attention gates to help language models handle untrusted text without obeying its hidden instructions.

Key results

97%
RL-Hammer ASR on GPT-OSS-20B

Highest attack success rate against the undefended model.

85%
RL-Hammer ASR on SecAlign

Highest attack success rate against the SecAlign defense.

10%
RL-Hammer ASR on HoS

Highest attack success rate against HoS.

18432
HoS trainable parameters on GPT-OSS-20B

Learned attention-gate parameters.

67.2%
HoS 5-shot MMLU-Pro accuracy

GPT-OSS-20B utility benchmark score.

What the paper found

Heads of Security, or HoS, defends against indirect prompt injection by learning small, per-attention-head gates that reduce how trusted instructions attend to untrusted text, while still allowing other heads to analyze that text. Unlike broad fine-tuning, it trains only the gates: 18432 parameters for OpenAI’s GPT-OSS-20B and 46080 for Meta’s Llama-3.3-70B-Instruct. In RL-Hammer tests on GPT-OSS-20B, the strongest attack achieved a 97% attack success rate on the undefended model and 85% against SecAlign, but only 10% against HoS. Against an adaptive white-box attack developed with Claudini, attackers needed about 3 times the compute to reach the same success rate on HoS as on the baselines. HoS also largely preserves general capability: on GPT-OSS-20B’s 5-shot MMLU-Pro benchmark, it scored 67.2%, compared with 59.4% for SecAlign and 52.1% for ASIDE. On agentic security benchmarks, it matched or improved SecAlign’s security–utility trade-off, while ASIDE often failed to make usable tool calls. The results suggest targeted attention routing can strengthen instruction–data separation without broadly disrupting a model’s other capabilities.

Original 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.

Read the original paper

More in AI Safety

Browse all 48 papers →
03Safety

Exploring The Empirical Privacy Landscape of Synthetic Data

Zihao Zhao, Avi Schwarzschild, Casey Meehan, Katherine Lee, Zhili Feng, Dylan Sam

The study finds that rewriting sensitive records to remove unique details can preserve model capabilities while reducing privacy leakage.

Read analysis