TL;DR
Researchers have uncovered a significant "blind spot" in how multimodal models are aligned for safety: they are incredibly brittle to simple structural changes in a prompt. By swapping the "user" and "assistant" roles or moving the location of an image token, the authors introduce Role-Modality Attacks (RMA) that bypass safety filters without changing a single word of the harmful query. To counter this, they also provide a robust adversarial training fix.
The Vulnerability of Static Chat Templates
When we interact with Multimodal Language Models (MMLMs) like GPT-4o or LLaVA, our inputs are wrapped in "chat templates"—hidden structural markers that tell the model who is speaking (User vs. Assistant) and where the image data is located.
Current safety alignment (such as Reinforcement Learning from Human Feedback, or RLHF) is typically performed on the assistant's responses within a very rigid, static template. This creates two major vulnerabilities:
- Role Asymmetry: The model is trained to be safe when acting as the "assistant," but the "user" role is often left unaligned.
- Structural Brittleness: Because models are trained on fixed templates, even minor deviations—like moving an
<image>token from the beginning to the end of a sentence—push the input "out-of-distribution" for the model's safety mechanism, causing it to "forget" to refuse harmful content.
Methods: Role-Modality Attacks (RMA)
The authors introduce Role-Modality Attacks (RMA), which manipulate the prompt structure rather than the content itself. They define two primary levers for these attacks:
- Role Confusion: Swapping the
userandassistanttags. This exploits the fact that the model hasn't been strictly trained to refuse harmful requests when they appear to come from the "assistant" side of the template. - Modality Manipulation: Moving the
<image>token to non-standard positions (e.g., at the very end of the prompt or inside the assistant's turn).
While moving an image token or swapping roles works individually, combining them (e.g., an img_out_swap attack) creates a multiplicative effect, significantly increasing the Attack Success Rate (ASR).
Internal Representation Shift
To understand why these structural changes bypass safety filters, the team used mechanistic interpretability. They extracted "refusal feature vectors"—mathematical directions in the model's internal activation space that represent the concept of "saying no."
They then measured how RMAs shift the model's internal state relative to these directions. The interpretability analysis showed that RMAs don't just "confuse" the model; they actively push the internal representation of a harmful query away from the "refusal" vector.
Interestingly, the authors found that "Cosine Similarity" (the direction shown in the figure above) isn't the only factor explaining why composed attacks are stronger. The projection (the strength or magnitude of the shift) plays a critical role. Composed attacks push the model's state much further into the "non-refusal" zone, effectively silencing the model's safety guardrails.
Key Results and Defense Mechanisms
The study utilized standard benchmarks to test safety (AdvBench, HarmBench) and general utility (Alpaca, VQA-V2). The results demonstrated widespread vulnerability across open-weight models:
- Qwen2-VL-7B: The baseline ASR was near 0%. Applying the composed
img_out_swapattack spiked the ASR to 42.5% on AdvBench. - LLaVA-1.5: This model proved even more brittle, showing an ASR jump from 22% to over 97% under the strongest RMA settings.
Adversarial Training as a Solution
To mitigate this vulnerability, the authors proposed Adversarial Training (AT). They fine-tuned models on a mix of harmful and benign prompts across all eight structural variations, teaching the model to ignore the structural "packaging" and focus purely on the "content" of the query.
After adversarial training, the ASR for Qwen dropped back to 0% across all attack settings. Crucially, its performance on standard Vision-Question Answering tasks (VQA-V2) remained stable, even showing slight improvements in some cases. The defense also generalized well, making the models more robust against unseen structural perturbations, like duplicating role tags or adding multiple images.
Limitations and Future Work
While RMAs are highly effective, they require the attacker to have control over the specific chat template tokens. This is trivial for open-source models, but many closed-source API providers "wrap" user inputs in their own templates on the backend, making these specific structural manipulations harder to execute in the wild.
Furthermore, as models move toward "Any-to-Any" multimodal capabilities (incorporating audio, video, etc.), the number of possible structural permutations will grow exponentially. Finding a universal alignment strategy that is invariant to all structural changes remains a significant challenge for future safety research.
Summary updated