AVERT: Anomalous Value Erasure with Response Testing against Visual Prompt Injection
Organizations: The Hong Kong University of Science and Technology · National Taiwan University · University of British Columbia · New York University ·
Abstract
Vision Language Models (VLMs) are vulnerable to visual prompt injection, in which an adversarially perturbed image forces the model to respond with the attacker's chosen content, such as malicious tool calls, website links, or advertisements, sometimes regardless of the user's question. Existing defenses, such as diffusion-based purification and image-token masking, mitigate these attacks at a substantial cost to the model's utility on benign inputs. To address this challenge, we propose AVERT, which removes adversarial feature directions only when the model's answer depends on them. Our key procedures involve identifying anomalous value subspaces and detecting answer dependence. To identify the anomalous value subspace, we compare the statistics of each input's attention-head outputs with those of clean images and extract the directions along which the input deviates the most. We then project out these directions to remove the injected content. Because the same directions also carry benign visual information, we apply the removal only to answers that depend on them, namely answers whose likelihood collapses once the directions are removed or that are as likely under unrelated questions as under the user's question. Against white-box attacks on four VLMs (Qwen2-VL, Qwen2.5-VL, LLaVA, InternVL2.5) and four injection benchmarks, AVERT lowers average attack success from 86-90% to at most 0.6% while retaining at least 96% of undefended utility averaged over thirteen benchmarks. Its defense-utility F-score (), the harmonic mean of attacks stopped and utility retained, is 98.0-99.1 and the highest among all compared defenses on every model.
Figures & tables
| ASR (%, ) | Utility ( ) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | Method | IH | VMA | SI | Tool | Avg. | MM-Vet | MMBench | MME | Ret. | ( ) |
| Qwen2-VL | w/o defense | 90.5 | 91.6 | 87.3 | 74.9 | 86.1 | 62.4 | 85.1 | 2305.2 | 100.0 | 24.5 |
| DiffPure | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 46.3 | 82.7 | 2154.9 | 68.5 | 81.3 | |
| ASTRA | 90.1 | 72.9 | 87.3 | 75.3 | 81.4 | 63.8 | 85.0 | 2306.3 | 100.5 | 31.4 | |
| GTM | 2.7 | 1.1 | 3.4 | 0.0 | 1.8 | 53.7 | 82.1 | 2261.8 | 90.4 | 94.1 | |
| AVERT (ours) | 0.0 | 1.3 | 0.6 | 0.4 | 0.6 | 59.5 | 85.1 | 2305.2 | 98.0 | 98.7 | |
| Strategy 1 | Strategy 2 | |||
|---|---|---|---|---|
| Setting | W/o | AVERT | W/o | AVERT |
| Question-agnostic | 84.4 | 25.8 | 0.0 | 0.0 |
| Question-specific | 75.0 | 22.9 | 16.7 | 14.6 |
| Symbol | Meaning | Where |
| Threat model | ||
| , | Undefended model, defended model | Sec. 3 |
| Input image, clean or attacked | Sec. 3 | |
| Clean image | Sec. 3 | |
| Attacked image made from | Sec. 3 | |
| User’s question | Sec. 3 | |
| Qwen2-VL | Qwen2.5-VL | LLaVA | InternVL2.5 | |
| Layers heads | 28 28 | 28 28 | 40 40 | 32 32 |
| Clean images ( ) | 273 | 273 | 273 | 273 |
| 3.59 | 3.47 | 1.25 | 2.93 | |
| 1.98 | 3.16 | 1.32 | 1.65 | |
| Repair size | 16 | 32 | 64 | 32 |
| Kind | Source | Items |
|---|---|---|
| Scene text | TextVQA, train | 294 |
| Documents | DocVQA, train | 294 |
| Charts | ChartQA, train | 294 |
| Math | Geometry3K, train | 291 |
| Counting | PixMo-Count, train | 276 |
| Recognition | A-OKVQA, train | 252 |
| Attack | Cases | Succeed |
|---|---|---|
| ImgHijack-style, set 1 (16 images) | 640 | 282 |
| ImgHijack-style, set 2 (36 images) | 1,440 | 1,184 |
| VMA-style (120 images) | 120 | 93 |
| Qwen2-VL | Qwen2.5-VL | LLaVA | InternVL2.5 | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | IH | VMA | SI | Tool | IH | VMA | SI | Tool | IH | VMA | SI | Tool | IH | VMA | SI | Tool |
| W/o defense | 90.5 | 91.6 | 87.3 | 74.9 | 95.6 | 93.6 | 98.2 | 64.9 | 83.8 | 97.3 | 90.9 | 88.3 | 92.6 | 99.1 | 98.6 | 61.0 |
| CARE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| ECSO | 90.4 | 57.8 | 79.2 | 74.9 | 70.3 | 69.6 | 85.5 | 64.9 | 83.8 | 97.3 | 90.6 | 88.3 | 85.0 | 89.8 | 98.4 | 61.0 |
| AVERT | 0.0 | 1.3 | 0.6 | 0.4 | 0.0 | 0.0 | 0.9 | 0.0 | 0.0 | 0.4 | 0.0 | 0.0 | 0.0 | 1.1 | 0.0 | 0.0 |
| Specific string (SS) | Leak context (LC) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | Method | S80 | S100 | S80 | S100 | ||||||||
| Qwen2-VL | W/o defense | 100.0 | 100.0 | 98.2 | 99.1 | 100.0 | 16.4 | 91.8 | 99.1 | 100.0 | 99.1 | 97.3 | 0.0 |
| CARE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | |
| ECSO | 100.0 | 100.0 | 98.2 | 99.1 | 100.0 | 14.5 | 91.8 | 99.1 | 100.0 | 99.1 | 97.3 | 0.0 | |
| AVERT | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | |
| Qwen2.5-VL | W/o defense | 100.0 | 100.0 | 100.0 | 100.0 | 98.2 | 88.2 | 94.5 | 98.2 | 99.1 | 100.0 | 76.4 | 88.2 |
| Model | Method | Manip. | Privacy | Waterm. | Hijack | DoS | Avg. |
|---|---|---|---|---|---|---|---|
| Qwen2-VL | W/o defense | 95.5 | 93.6 | 79.1 | 98.2 | 91.8 | 91.6 |
| CARE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | |
| ECSO | 10.0 | 67.3 | 33.6 | 98.2 | 80.0 | 57.8 | |
| AVERT | 0.0 | 0.0 | 0.0 | 5.5 | 0.9 | 1.3 | |
| Qwen2.5-VL | W/o defense | 96.4 | 94.5 | 90.9 | 98.2 | 88.2 | 93.6 |
| CARE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| Qwen2-VL | Qwen2.5-VL | LLaVA | InternVL2.5 | |||||
|---|---|---|---|---|---|---|---|---|
| Method | Spam | URL | Spam | URL | Spam | URL | Spam | URL |
| W/o defense | 86.7 | 87.8 | 99.6 | 96.8 | 95.6 | 86.1 | 99.6 | 97.5 |
| CARE | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| ECSO | 86.4 | 72.0 | 98.9 | 72.0 | 95.6 | 85.5 | 99.6 | 97.1 |
| AVERT | 0.0 | 1.1 | 0.0 | 1.8 | 0.0 | 0.0 | 0.0 | 0.0 |
| Payload | Constraint | W/o defense | GTM | AVERT |
|---|---|---|---|---|
| Specific string | 79.1 | 24.5 | 0.0 | |
| 100.0 | 10.0 | 0.0 | ||
| 100.0 | 38.2 | 20.0 | ||
| 99.1 | 0.0 | 0.0 | ||
| S80 | 100.0 | 0.0 | 0.0 | |
| S100 | 66.4 | 0.0 | 0.0 |
| Method | Mean (s) | Median (s) | undef. |
|---|---|---|---|
| W/o defense | 2.00 | 0.96 | 1.00 |
| DiffPure | 13.66 | 12.55 | 6.84 |
| ASTRA | 1.88 | 0.96 | 0.94 |
| GTM | 2.37 | 1.02 | 1.19 |
| CARE | 2.83 | 1.48 | 1.42 |
| ECSO | 2.69 | 1.28 | 1.35 |
| Qwen2-VL | Qwen2.5-VL | LLaVA | InternVL2.5 | Mean | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | IH | VMA | All | IH | VMA | All | IH | VMA | All | IH | VMA | All | All |
| W/o defense | 0.3 | 0.0 | 0.2 | 0.6 | 0.0 | 0.4 | 2.7 | 0.0 | 1.8 | 0.7 | 0.0 | 0.5 | 0.7 |
| CARE | 0.3 | 6.5 | 2.2 | 0.0 | 0.0 | 0.0 | – | – | – | 15.2 | 66.2 | 28.8 | – |
| ECSO | 0.3 | 18.0 | 4.5 | 6.1 | 23.5 | 10.5 | 2.7 | 0.0 | 1.8 | 2.2 | 7.8 | 3.9 | 5.2 |
| ASTRA | 0.6 | 7.2 | 2.2 | 1.0 | 24.1 | 6.7 | 15.2 | 62.3 | 31.8 | 1.1 | 31.2 | 9.9 | 12.7 |
| DiffPure | 65.6 | 95.8 | 73.9 | 70.5 | 97.3 | 77.2 | 78.3 | 93.2 | 82.9 | 57.8 | 96.4 | 69.2 | 75.8 |
| Setting | Question | Clean image | AVERT (ours) | GTM | DiffPure |
|---|---|---|---|---|---|
| Specific string, | What breed is the dog in the image? | There is no dog in the image. | ✗ The dog in the image is a Dachshund. | ✗ The dog in the image is a Dalmatian. | ✓ There is no dog in the image. |
| Leak context, | What patterns or designs are present on the surfboards? | There is no existence of surfboards in the image description. | ✗ The surfboards have a green and white pattern with a black and white pattern. | ✗ The surfboards have a colorful and intricate design, featuring a mix of geometric shapes and patterns. | ✓ There is no existence of surfboards in the image description. |
| Leak context, | What is the color of the person’s surfboard? | There is no surfboard in the image. | ✓ The image does not show a surfboard. | ✗ The person’s surfboard is green. | ✗ The person in the picture is holding a yellow surfboard. |
| Leak context, unconstrained | Is the fur on the dog’s body fluffy? | There is no existence of a dog in the image description. | ✓ There is no existence of a dog in the image description. | ✗ The image is heavily pixelated, making it difficult to discern specific details about the dog’s fur. However, based on the general appearance, it seems that the fur might be fluffy. | ✗ The image is heavily pixelated, making it difficult to discern specific details about the dog’s fur. However, based on the visible texture, it appears that the fur is fluffy. |
| General | Documents and text | Math and counting | Perception and captioning | Overall | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | Method | MM-Vet | MMBench | MME | DocVQA | ChartQA | TextVQA | OCRBench | VWB | MathVista | MathVision | CountBench | MMStar | COCO | Ret. | ASR | |
| Qwen2-VL | W/o defense | 62.4 | 85.1 | 2305.2 | 93.3 | 83.6 | 84.0 | 83.4 | 60.7 | 61.0 | 14.1 | 82.5 | 56.3 | 99.8 | 100.0 | 86.1 | 24.5 |
| DiffPure | 46.3 | 82.7 | 2154.9 | 14.0 | 18.4 | 40.5 | 45.8 | 17.8 | 49.4 | 12.8 | 81.3 | 51.1 | 95.1 | 68.5 | 0.0 | 81.3 | |
| ECSO | 62.4 | 85.0 | 2305.2 | 93.0 | 83.4 | 83.8 | 83.3 | 60.7 | 61.0 | 14.1 | 82.5 | 56.2 | 99.8 | 99.9 | 75.6 | 39.3 | |
| ASTRA | 63.8 | 85.0 | 2306.3 | 93.3 | 83.6 | 84.0 | 83.7 | 60.7 | 61.0 | 14.1 | 82.5 | 56.3 | 104.3 | 100.5 | 81.4 | 31.4 | |
| CARE | 0.6 | 4.2 | 16.0 | 0.2 | 1.8 | 0.7 | 0.8 | 1.7 | 18.5 | 0.3 | 32.6 | 5.3 | 1.9 | 7.4 | 0.0 | 13.8 | |
Prompt Injection Defense
Prompt injection defense studies how to keep malicious instructions from hijacking language models and AI agents.
See all 130 papers