Anyattack: Towards Large-scale Self-supervised Adversarial Attacks on Vision-language Models

Jiaming Zhang, Junhong Ye, Xingjun Ma, Yige Li, Yunfan Yang, Yunhao Chen, Jitao Sang, Dit-Yan Yeung

Abstract

Vision-Language Models (VLMs) are increasingly integrated into critical applications, yet they remain vulnerable to targeted adversarial attacks. Existing attack methodologies are often constrained by their reliance on manual labels and small-scale supervised datasets, limiting their real-world scalability. This paper introduces AnyAttack, the first self-supervised framework designed to generate targeted adversarial attacks at an unprecedented scale. By pre-training an adversarial generator on the massive LAION-400M dataset, AnyAttack creates adversarial "foundation models" capable of compromising both open-source and major commercial systems, including GPT-4o and Google Gemini, without requiring task-specific labels.

Introduction

Targeted adversarial attacks involve making subtle, human-imperceptible changes to an image to force a VLM into producing a specific, often malicious, output. While effective, traditional supervised attacks are "brittle" because they depend on specific target labels and small datasets like ImageNet. AnyAttack shifts this paradigm by treating adversarial noise generation as a self-supervised learning problem. By leveraging the internal visual features (embeddings) of images as supervision signals, AnyAttack can target any visual concept the VLM understands, effectively breaking the scalability bottleneck of previous methods.

Methodology

The core of AnyAttack is a "pre-training and fine-tuning" paradigm applied to adversarial noise generation.

Self-supervised Pre-training

The framework utilizes a noise generator (decoder) trained on the LAION-400M dataset. Instead of text labels, the target image's own visual embeddings serve as the supervision signal. The objective is to generate a noise pattern $\delta$ such that when added to a random image $x_r$, the resulting adversarial image is perceived by the VLM's encoder as the target image $x$. To ensure robustness, a K-augmentation strategy is employed, creating multiple shuffled versions of images within mini-batches to prevent the generator from simply memorizing specific image pairs.

The AnyAttack architecture featuring self-supervised pre-training on large-scale datasets and task-specific fine-tuning.

Task-Specific Fine-tuning

Following pre-training, the generator is fine-tuned for specific downstream tasks using specialized loss functions:

  • Bidirectional Contrastive Loss ($\mathcal{L}_{Bi}$): Optimizes retrieval tasks for both image-to-text and text-to-image directions.
  • Cosine Similarity Loss ($\mathcal{L}_{Cos}$): Applied to general tasks like classification and captioning.
  • Auxiliary Models: To enhance transferability to "black-box" commercial models, an ensemble of auxiliary surrogate models is incorporated during the fine-tuning phase.

Experimental Results

AnyAttack was evaluated across several benchmarks, including MSCOCO, Flickr30K, and SNLI-VE, using LAION-400M for pre-training and ImageNet-1K for source images.

Quantitative Performance

On the MSCOCO retrieval task, AnyAttack achieved a state-of-the-art Attack Success Rate (ASR), outperforming previous methods like AttackVLM by 15-18%. In multimodal classification on the SNLI-VE dataset, AnyAttack reached an ASR of 44.8%, nearly doubling the performance of traditional supervised baselines which struggled to exceed 25%.

Commercial Model Transferability

The framework demonstrated significant impact on closed-source commercial systems. AnyAttack achieved a 31% ASR on Google Gemini and a 38% ASR on OpenAI GPT-4o mini. Qualitative evaluations showed the model successfully forcing systems like Claude Sonnet and Microsoft Copilot to misidentify images using target-specific terms.

Qualitative results showing AnyAttack successfully misleading major commercial VLMs into describing a target image with specific adversarial terms.

Discussion and Conclusion

AnyAttack reveals a systemic vulnerability across the VLM landscape. The high transferability of attacks from open-source surrogates to commercial models suggests that these systems share similar underlying feature representations. By demonstrating that adversarial generators can be scaled into "foundation models," this research highlights an urgent need for the development of more resilient VLM architectures and robust defense mechanisms. Future work will focus on exploring mitigation strategies to defend against these large-scale, self-supervised adversarial threats.

Summary updated

BibTeX
@inproceedings{zhang2025anyattack,
  author = {Jiaming Zhang and Junhong Ye and Xingjun Ma and Yige Li and Yunfan Yang and Yunhao Chen and Jitao Sang and Dit-Yan Yeung},
  title = {{Anyattack: Towards Large-scale Self-supervised Adversarial Attacks on Vision-language Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01853},
}
Figure