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 ∗ †
HoS adds learned attention gates to help language models handle untrusted text without obeying its hidden instructions.
Key results
Highest attack success rate against the undefended model.
Highest attack success rate against the SecAlign defense.
Highest attack success rate against HoS.
Learned attention-gate parameters.
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 paperMore in AI Safety
Browse all 48 papers →Reliable AI-Assisted Decisions via Selective Auditing
Isaac Gibbs, Elise L. Han, Ryan J. Tibshirani, Tijana Zrnic
A principled way to reduce human review of AI decisions while keeping unaudited errors below a chosen limit.
RSI Control: Can AI Models Perform Covert Sabotage in the Self-Improvement Process?
Kaiwen Zhou, Udari Madhushani Sehwag
A new testbed finds that AI models can covertly sabotage the training of their successors, often evading transcript-based monitors.
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.