An adversarial image is a picture with small, invisible pixel changes that make a vision-language model (VLM, a language model that also reads images) answer a harmful request it would normally refuse. Such images have a known weakness. Their effect depends on exact pixel values, so ordinary JPEG compression or blurring often breaks them. The obvious defense is to compress or purify every incoming image. The cost is that this also damages legitimate images, for example by blurring the small text a model needs for document questions, and diffusion-based cleaning adds seconds of latency per image.
We propose using that weakness differently. The degraded copy of the image is never shown to the model for answering. It serves only as a reference. Work on text language models finds that the decision to refuse is concentrated in a few middle layers, roughly one third of the way through the network, and is readable there as a single direction in the hidden activations. We compare the model's "refusal signal" at those layers on the original image and on a cheaply degraded copy. If the original image suppresses refusal much more than its degraded twin does, the image is probably adversarial, and we add back only the missing refusal signal at those layers. Clean images produce almost no gap, so they pass through unedited and at full quality.
Core Claim
Pixel-level jailbreak images against VLMs work mainly by pushing down the refusal-direction component of the language backbone's hidden state near one-third depth. Because that push comes from a fragile perturbation, a degraded copy of the image supplies an estimate of the refusal signal the image's real content deserves. We define the repair as follows. Let $h_l(x)$ be the final-prompt-token hidden state at layer $l$ for input $x$. Let $\hat r_l$ be the unit refusal direction at that layer, estimated as the difference of mean activations on harmful and harmless prompts. Let $s_l(x) = \langle h_l(x), \hat r_l \rangle$ be the refusal score, and let $T$ be a cheap degradation such as JPEG compression. The repair sets
$$ h_l(x) \leftarrow h_l(x) + \max\big(0,\; s_l(T(x)) - s_l(x) - \delta\big)\,\hat r_l , $$
where $\delta$ is a margin calibrated so that the edit fires on almost no clean images. The added cost is one prefill pass on $T(x)$ up to layer $l$, which is about a third of the network and needs no generation.
The new element is the combination. Degradation serves as a measuring stick rather than as a preprocessing step. The measurement and the edit both happen at the layer where refusal is decided, and the edit is conditional and rank-one. Nothing is changed unless a perturbation-shaped gap appears.
Where This Sits in Prior Work
The layer-localization literature motivates the choice of where to intervene. Safety Layers in Aligned Large Language Models shows that harmful and benign query representations separate sharply in the middle layers of Llama-3-8B, and it freezes those layers during fine-tuning. Fine-Grained Safety Neurons with Training-Free Continual Projection (MSCP) places safety neurons at about one-third depth and projects their weights along a safety direction. Just Enough Shifts (ACTOR) fine-tunes a single middle layer along a refusal vector to reduce over-refusal. All three edit weights to protect against fine-tuning or over-refusal on text. None addresses test-time pixel attacks, and none makes an input-conditional edit. We reuse their direction-finding method and their layer prior. We do not change any weights.
Two papers constrain the design. Risk Awareness Injection (RAI) finds that in VLMs, injecting an unsafe-prototype vector at Layer 15 or 25 hurts utility without improving safety, so it intervenes at Layer 0 on the riskiest visual tokens. On its face this contradicts a mid-depth design. We take the finding seriously. RAI's injection is unconditional, is applied to visual tokens, and targets semantic risk in image content. Our edit is conditional, applied to the final text position, and targets pixel perturbations, which RAI explicitly does not evaluate. Whether this difference escapes RAI's utility penalty is an empirical question, and one of our ablations tests it directly. The Shape of Noise (PEF) supplies our diagnostic tool: per-layer activation drift between clean and perturbed inputs, measured as relative representation difference and amplification rate. PEF studied only common corruptions in CNNs. We apply it to adversarial perturbations in a VLM's language backbone, and we measure drift along the refusal direction specifically.
The fragility and purification literature supplies the reference signal and the main competitors. APBench and robust adversarial examples against OSNs show that JPEG, bit-depth reduction, and resizing routinely neutralize adversarial noise. DiffCAP purifies VLM inputs by diffusion and stops once the vision-encoder embedding stabilizes. MimicDiffusion and IMPRESS are stronger generative purifiers for classifiers and diffusion models. A Response to Glaze Purification via IMPRESS documents the collateral texture damage purification causes on clean images. All of these change the pixels the model finally sees. Our proposal leaves those pixels untouched.
Research Program
The work has three stages, and each can falsify the idea.
The first stage is diagnostic. On LLaVA-1.6 and Qwen2.5-VL, the two backbones RAI reports on, we craft $\ell_\infty$-bounded image perturbations. Each perturbation is optimized to make the model comply with harmful requests from JailBreakV-28K's RedTeam-2K queries and HarmBench's behaviors. We then trace them layer by layer with PEF-style drift. The question is whether the drift that matters is concentrated as a deficit in $s_l$ within a narrow band near one-third of the language backbone's depth. The alternative is that the drift is spread across depth, or absorbed in the vision encoder before the language model ever sees it. We also apply JPEG and blur to the adversarial images and check that the refusal-score deficit collapses under degradation, while the score on clean images barely moves. If either of these fails, the core premise is wrong and we stop.
The second stage builds the repair. We choose $l$ by maximum harmful/harmless separability, following the Safety Layers and ACTOR selection procedure. We calibrate $\delta$ on clean images from MS-COCO and on USB's safe-image/safe-text split to a target false-fire rate of about one percent. We then study the family of degradations $T$: JPEG at several qualities, Gaussian blur, bit-depth reduction, and a small ensemble taking the maximum reference score.
The third stage attacks the repair adaptively. We give an attacker full knowledge of $\hat r_l$, $T$, and $\delta$. The attacker optimizes a jailbreak with an added penalty on the gap $s_l(T(x)) - s_l(x)$, using expectation over the degradation family. Two outcomes are informative. If the attacker cannot jailbreak while keeping the gap small, refusal really runs through this direction and the defense has a mechanistic basis. If the attacker jailbreaks while leaving $s_l$ intact, safety is not bottlenecked there, and the claim fails honestly.
Baselines
The naive reference point is the undefended model on the same adversarial and clean sets. It fixes the attack success rate (ASR) ceiling and the utility ceiling that every defense is measured against.
The input-degradation baseline feeds the JPEG-compressed or blurred image to the model for generation. It uses exactly the same $T$ as our reference. This is the most important comparison because it isolates the key ingredient, which is using the degraded image to measure rather than to answer. Beating it means matching its ASR while keeping clean utility close to the undefended model on TextVQA and MS-COCO, where degradation should hurt most.
The strongest purification baseline is DiffCAP, run with its published stopping rule on the same attacked images, at matched compute, with its threshold tuned on the same clean calibration set. DiffCAP reports that on MS-COCO captioning with LLaVA an attack drops CIDEr from 115.5 to 3.1 and purification restores it to 116.9, at about 1.1 seconds per image (DiffCAP). Those numbers concern utility attacks, not jailbreaks. We found no reported result on Lacuna for DiffCAP's ASR against pixel-level VLM jailbreaks, so we will measure it ourselves. Beating DiffCAP means lower or equal jailbreak ASR at a fraction of its latency, with no drop in clean CIDEr or TextVQA accuracy.
The strongest layer-wise safety baseline is RAI, run at Layer 0 with its published top-token fraction. RAI reports lowering LLaVA-1.6 ASR from nearly 50% to 3.62%, compared with ShiftDC at 14.83%. It keeps Qwen2.5-VL at 610.64 on MME versus 611.78 unprotected, with 13.2% latency overhead (RAI). Those figures are for semantic multimodal jailbreaks. We found no reported result on Lacuna for RAI against imperceptible pixel perturbations. Beating RAI means lower ASR on pixel attacks with comparable MME and oversensitivity. We also report RAI on semantic attacks, and there we expect our method to be no better.
Three ablations isolate the remaining ingredients. The first is unconditional refusal-direction addition at the same layer, which tests whether the conditional gap matters or whether any mid-depth push toward refusal would do. We expect it to raise over-refusal on USB's safe-image/safe-text split. The second repeats our conditional repair at Layer 0 and at a late layer, which tests the depth claim against RAI's finding. The third uses a text-only reference, with the image dropped, in place of the degraded image. This tests whether fragility actually matters or whether ignoring the image entirely is enough.
Why not just…?
Why not just JPEG-compress every input image? This is the most serious simple competitor, because the fragility literature says it often works against attacks that were not designed to survive it. Its weakness is utility. Degradation removes the fine detail that text-heavy images need. The file reports no TextVQA number under JPEG, so the input-degradation baseline above will measure that cost directly. On adaptive robustness, an attacker who optimizes through JPEG defeats both JPEG-as-input and our JPEG reference equally. We therefore claim an advantage in utility, not in robustness to degradation-aware attacks. The degradation ensemble and the gap-penalized adaptive attack determine how much robustness survives.
Why not just purify with diffusion, as DiffCAP does? Diffusion purification changes the pixels the model reads. A Response to Glaze Purification via IMPRESS shows it strips real texture from clean images and struggles with content absent from pretraining. It also costs about a second per image even in DiffCAP's accelerated form. Our method could in principle use a diffusion-purified image as its reference. Doing so would recover DiffCAP-level robustness while keeping the original pixels for generation. We treat that as an escalation path and report its latency honestly, rather than hiding it.
Why not just adversarially fine-tune the middle layer, ACTOR-style, on attacked images? That puts the robustness into the weights, which brings back the rigidity trade-off that adversarial training causes and the per-step attack cost noted in HarmBench. It also changes behavior on every input, including clean ones. If a single-layer fine-tune on a few hundred attacked images matched our ASR with no utility loss, it would be a real threat. We will run it at the same data budget as a secondary baseline to settle the question.
Why not just use an output safety classifier? A classifier run on the model's output catches harmful text after it has been generated. That is a complementary last line of defense and says nothing about why the model complied. We report ASR both with and without a Llama-Guard filter on top of each defense so that the two do not get conflated.
Proposed Experiments and Decisive Checks
Attack sets are pixel-optimized versions of JailBreakV-28K's RedTeam-2K queries, of HarmBench's standard and multimodal behaviors, and of MM-SafetyBench scenarios. We also include the unperturbed JailBreakV semantic attacks, to check that nothing regresses. ASR is judged with the HarmBench classifier at its fixed 512-token limit, since HarmBench shows the generation length alone can shift ASR by up to 30%, and cross-checked with Llama-Guard. Oversensitivity is the refusal rate on USB's safe-image/safe-text split. Clean utility is measured by MME, MM-Vet, MS-COCO CIDEr, and TextVQA accuracy, and cost is measured as wall-clock latency per query.
Three results decide whether the idea stands. First, the diagnostic must show that the adversarial refusal-score deficit sits in a band within a few layers of one-third depth and collapses under degradation. Second, the calibrated repair must fire on at most about one percent of clean images, while cutting pixel-attack ASR to at or below the input-degradation baseline and keeping TextVQA and CIDEr within noise of the undefended model. Third, under the gap-penalized adaptive attack, ASR must stay well below the undefended level. If the attacker jailbreaks while preserving the mid-depth refusal score, we will report that safety in VLMs is not bottlenecked at the layers text-model interpretability points to. That would be a useful negative result bearing on the depth conflict between RAI and the text-only studies.
References
- Safety Layers in Aligned Large Language Models: The Key to LLM Security
- Fine-Grained Safety Neurons with Training-Free Continual Projection to Reduce LLM Fine Tuning Risks
- Just Enough Shifts: Mitigating Over-Refusal in Aligned Language Models with Targeted Representation Fine-Tuning
- Risk Awareness Injection: Calibrating Vision-Language Models for Safety without Compromising Utility
- The Shape of Noise: Layer-Wise Perturbation Profiles for Diagnosing Vision Robustness
- APBench: A Unified Availability Poisoning Attack and Defenses Benchmark
- Generating Robust Adversarial Examples against Online Social Networks (OSNs)
- Diffusion-based Cumulative Adversarial Purification for Vision Language Models
- MimicDiffusion: Purifying Adversarial Perturbation via Mimicking Clean Diffusion Model
- IMPRESS: Evaluating the Resilience of Imperceptible Perturbations Against Unauthorized Data Usage in Diffusion-Based Generative AI
- A Response to Glaze Purification via IMPRESS
- HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusal