Spot Risks Before Speaking! Unraveling Safety Attention Heads in Large Vision-Language Models

Le Yang (杨乐), Ziwei Zheng, Junyao Zhao, Le Yang, Lijun He, Fan LiarXiv 2025 · DOI

Introduction

While Large Language Models (LLMs) have achieved significant robustness through rigorous safety alignment, their multimodal counterparts—Large Vision-Language Models (LVLMs)—remain surprisingly fragile. The integration of a vision encoder often inadvertently "breaks" the established safety guardrails of the underlying language model. Attackers can bypass these filters by embedding malicious instructions within images using techniques like adversarial typography or noise, which traditional text-only safety training fails to anticipate.

Existing defenses typically rely on "post-hoc alignment," which involves fine-tuning the entire model on massive safety datasets. This approach is not only computationally expensive and dependent on high-quality human annotation but also often results in a "utility tax," where the model's general performance degrades. This research investigates a fundamental question: Does the model already know it is being attacked? By identifying internal mechanisms that recognize malicious intent, we can potentially stop harmful responses before the first word is even generated.

Methodology: The SAHs Framework

The researchers propose a three-step, tuning-free pipeline called SAHs (Safety Attention Heads) designed to identify and block jailbreak attempts with near-zero overhead.

Overview of the SAHs defense pipeline, illustrating the transition from a vulnerable LVLM to a safe one by eliciting and monitoring internal safety heads.
  1. Locating Safety Heads: Using "linear probes"—simple classifiers—the authors analyze the activations of every attention head within the model during the generation of the very first token. They discovered that safety perception is highly sparse; only a small subset of specific heads is responsible for distinguishing malicious from benign inputs.
  2. Training a Malicious Prompt Detector: Instead of modifying the LVLM's weights, the model is frozen. The activations from the identified "safety heads" are concatenated to train a lightweight logistic regression detector on a minimal set of examples.
  3. Inference-time Defense: During standard operation, this detector monitors the safety heads during the initial forward pass. If a jailbreak attempt is detected, the system triggers a pre-defined refusal response (e.g., "I cannot assist with that") rather than allowing the model to proceed with harmful generation.

Key Insights: The Sparsity of Safety

A central discovery of this work is the existence of a "Safety Shield" within the model's architecture. When these specific safety heads are ablated (zeroed out), the model's vulnerability to attacks increases dramatically, while its ability to process benign queries remains stable.

Heatmaps demonstrating the sparse distribution of safety attention heads across different layers and indices for three major models: LLaVA-1.5, MiniGPT4, and Qwen-VL.

Furthermore, the study reveals a "Modality Vulnerability Gap": the introduction of vision to a well-aligned LLM actually reduces the number of active safety heads. This provides a structural explanation for why LVLMs are inherently easier to jailbreak than text-only models. Interestingly, Supervised Fine-Tuning (SFT) for safety appears to work by increasing both the quantity and the activation strength of these internal safety heads.

Experimental Results

The SAHs framework was tested against rigorous benchmarks, including MM-SafetyBench, VLGuard, and ADV-64, yielding several key findings:

  • Massive Risk Reduction: On the LLaVA-1.5 model, the Attack Success Rate (ASR) plummeted from 87.21% to 3.57% on MM-SafetyBench.
  • High Efficiency: The SAHs detector is 61x faster than existing state-of-the-art detector-based defenses because it operates on internal activations during the first forward pass, avoiding the need for multiple generation cycles or external models.
  • Preserved Utility: Testing on the MM-Vet and MME benchmarks confirmed that the defense does not cause "over-defensiveness." Performance on general tasks stayed within 1% of the original unprotected model.
  • Data Efficiency: The system is remarkably effective even in few-shot scenarios, identifying safety heads with as few as one or two training examples.

Conclusion and Future Work

The discovery of safety attention heads suggests that LVLMs possess an latent awareness of malicious intent that can be harnessed for defense without expensive retraining. While the current SAHs detector is highly effective against contemporary jailbreaks, the authors note that it relies on the first generated token. Future work may explore "slow-burn" attacks that reveal malice later in a response, as well as methods to "boost" these safety heads during initial training to create inherently more robust multimodal models.

Summary updated

BibTeX
@misc{2025spot,
  author = {Le Yang (杨乐) and Ziwei Zheng and Junyao Zhao and Le Yang and Lijun He and Fan Li},
  title = {{Spot Risks Before Speaking! Unraveling Safety Attention Heads in Large Vision-Language Models}},
  year = {2025},
  eprint = {2501.02029},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.02029},
}
Figure