A Classifier-Agnostic Zero-Shot Adversarial Attack Detection via CLIP

Hodaya Krakover, Meir Yossef Levi, Eyal Gofer, Guy GilboaarXiv 2026

TL;DR

The authors introduce $A^4D$ (Attack- and Architecture-Agnostic Adversarial Detector), a completely black-box, zero-shot framework that leverages CLIP to detect adversarial attacks without needing access to the underlying classifier or prior knowledge of the attack type. By projecting image embeddings onto a small dictionary of text prompts describing visual artifacts, $A^4D$ accurately flags manipulated images with minimal computational overhead.

What Problem Does This Paper Address?

Deep learning models are notoriously vulnerable to adversarial attacks—tiny, human-imperceptible tweaks to an image that completely throw off a model's predictions. While many detection methods exist, they usually come with heavy strings attached: they might require "white-box" access to the internal layers of the classifier, need to be trained on specific types of adversarial examples, or fail to generalize to new, unseen attack architectures.

As new vision encoders and novel attack strategies continuously emerge, we need defenses that are truly generalizable. The authors tackle this challenge by proposing a defense mechanism that requires zero knowledge of the target classifier or the specific attack mechanism being deployed.

Methods

The proposed framework exploits a fascinating quirk of Vision-Language Models (VLMs) like CLIP. Even though adversarial perturbations are optimized to fool specific image classifiers while remaining invisible to humans, they cause a significant, non-arbitrary shift in CLIP's latent embedding space.

Instead of trying to model this shift directly in the high-dimensional image space, $A^4D$ projects the image embedding onto a semantic "similarity space" defined by a dictionary of 10 text prompts describing image corruptions (e.g., "An image with noise", "An image with corrupted pixels", or "An image with strange visual artifacts").

Fig. 1: CLIP sensitivity to adversarial perturbations. (a) Cosine similarity histogram between Tiny-ImageNet images and their FGSM adversarial counterparts, showing a clear embedding shift even for small budgets. (b) Thin-shell structure. Histogram of embedding norms with respect to the dataset mean reveals that samples lie on a thin shell [17] (much larger bias than variance). (c) Gradual latent shift. As the attack budget increases, the ℓ2 distance between distribution centers grows consis- tently. (d) Embedding evolution under attack. Increasing perturbation strength progressively shifts samples in the latent space.

The test-time pipeline works as follows:

  1. Embedding Generation: The input image is passed through CLIP's image encoder.
  2. Similarity Mapping: The cosine similarity is computed between the image embedding and the 10 pre-computed text prompt embeddings, forming a 10-dimensional similarity vector.
  3. Standardization & Projection: This vector is standardized using parameters derived from a tiny validation set of just 200 clean images (no adversarial training samples required). It is then projected onto the first principal component (PC1) of the clean data distribution.
  4. Score Aggregation: The final projection yields a single detection score. Higher scores indicate a higher likelihood that the image has been adversarially manipulated.

Datasets

The method was evaluated on two distinct image datasets:

  • Tiny-ImageNet: A standard benchmark containing 200 classes, used to evaluate general performance across a wide variety of subjects.
  • StreetSurfaceVis: A specialized dataset consisting of 5 classes of road materials. Crucially, this dataset was published after CLIP was released. Testing on it ensures that CLIP had zero prior exposure to these images during its original pre-training phase, ruling out any unfair advantages from data leakage.

Key Insights and Ideas

  • CLIP's Hidden Sensitivity: Even when an adversarial attack perfectly tricks a vision model without changing the human-perceived semantics, CLIP's image encoder remains highly sensitive to these low-level, non-semantic pixel perturbations.
  • The Shift is Structured, Not Random: When an image is attacked, its embedding doesn't just wander randomly; it shifts consistently toward specific regions of the latent space that correlate with textual descriptions of noise and artifacts.
  • Edge-based Attacks vs. Noise-based Attacks: The authors discovered why some attacks are harder to detect than others. Attacks like FGSM and PGD introduce noise-like patterns that CLIP easily flags. However, attacks like Carlini-Wagner (CW) and DeepFool concentrate their perturbations along the structural edges of the image. Because these perturbations align with the natural geometry of the image, they cause a smaller shift in CLIP space and are harder to distinguish from clean data.

Key Results

  • Robust Across Architectures: $A^4D$ achieves state-of-the-art (SOTA) or second-best detection performance across four completely different classifier architectures (DeiT-Small, Wide-ResNet, ResNet34, and ConvNext-Tiny) and seven different attack types (including FGSM, PGD, AutoAttack, and Square).
  • High Detection Accuracy: On Wide-ResNet, $A^4D$ achieved an average AU-ROC of 92.53% across all attacks, vastly outperforming traditional agnostic baselines like Wavelet-based noise estimation (78.36%) and Median Absolute Deviation (70.23%).
  • Incredibly Efficient: Because it only requires a single forward pass through CLIP and a lightweight vector projection, the average inference time is just 0.0091 seconds per image on an NVIDIA RTX 3090, making it highly practical for real-time deployment.

Limitations and Future Work

  • Prompt Dependency: The performance relies heavily on the manual selection of descriptive text prompts. A poorly chosen prompt (like the generic "A noisy image") can fail to separate clean and adversarial distributions cleanly. Developing an automated, systematic method to learn or select optimal prompts without overfitting remains an open challenge.
  • Clean Data Assumption: The method assumes access to a small, clean validation set that accurately represents the test distribution. Performance under severe distribution shifts (e.g., out-of-distribution natural images) was not fully explored.

Summary updated

BibTeX
@misc{krakover2026classifier,
  author = {Hodaya Krakover and Meir Yossef Levi and Eyal Gofer and Guy Gilboa},
  title = {{A Classifier-Agnostic Zero-Shot Adversarial Attack Detection via CLIP}},
  year = {2026},
  eprint = {2606.30342},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.30342},
}
Figure