arXiv:2605.00236cs.CRcs.AI2026-05

攻击大模型注意力机制,用5个词就能绕过安全防护

Attention Is Where You Attack

  • 通过优化注意力分布,用非语义词干扰关键安全头
  • 仅5个词、500步就让Mistral-7B攻击成功率达36%
  • 发现安全行为依赖注意力路由而非特定头,适合安全研究者

安全对齐的大语言模型依赖强化学习与指令微调来拒绝有害请求,但其内部安全机制仍不清晰。本文提出注意力重分配攻击(ARA),一种白盒对抗攻击,可定位安全关键注意力头,并生成非语义对抗性标记,将注意力从安全相关位置转移。不同于以往在语义或输出概率层操作的越狱方法,ARA通过在概率单纯形上对目标头使用Gumbel-softmax优化,干预softmax注意力的几何结构。在LLaMA-3-8B-Instruct、Mistral-7B-Instruct-v0.1和Gemma-2-9B-it上,ARA仅需5个词和500次优化步骤即可绕过安全对齐,对200个HarmBench提示实现36%攻击成功率(Mistral-7B)和30%(LLaMA-3),而Gemma-2保持1%。核心发现是:移除顶级安全头最多导致39至50个基准拒绝中出现1次失效,而针对相同层的ARA则使Mistral-7B翻转72/200个提示,LLaMA-3翻转60/200个。这表明安全并非由可替换的独立头部实现,而是源自这些头部所执行的注意力路由。移除头部可通过残差流补偿,但注意力被重定向会将错误信号向下游传播。

原文摘要 · Abstract (English)

Safety-aligned large language models rely on RLHF and instruction tuning to refuse harmful requests, yet the internal mechanisms implementing safety behavior remain poorly understood. We introduce the Attention Redistribution Attack (ARA), a white-box adversarial attack that identifies safety-critical attention heads and crafts nonsemantic adversarial tokens that redirect attention away from safety-relevant positions. Unlike prior jailbreak methods operating at the semantic or output-logit level, ARA targets the geometry of softmax attention on the probability simplex using Gumbel-softmax optimization over targeted heads. Across LLaMA-3-8B-Instruct, Mistral-7B-Instruct-v0.1, and Gemma-2-9B-it, ARA bypasses safety alignment with as few as 5 tokens and 500 optimization steps, achieving 36% ASR on Mistral-7B and 30% on LLaMA-3 against 200 HarmBench prompts, while Gemma-2 remains at 1%. Our principal mechanistic finding is a dissociation between ablation and redistribution: zeroing out the top-ranked safety heads produces at most 1 flip among 39 to 50 baseline refusals, while ARA targeting the corresponding safety-heavy layers flips 72/200 prompts on Mistral-7B and 60/200 on LLaMA-3. This suggests that safety is not localized in these heads as removable components, but emerges from the attention routing they perform. Removing a head allows compensation through the residual stream, while redirecting its attention propagates a corrupted signal downstream.

安全攻击注意力机制对抗样本大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。