VLMGuard: Defending VLMs against Malicious Prompts via Unlabeled Data

Xuefeng Du, Reshmi Ghosh, Robert Sim, Ahmed Salem, Vitor R. Carvalho, Emily Lawton, Yixuan Li, Jack W Stokes · Submission to ICLR 2025 · Withdrawn

TL;DR

VLMGuard is an unsupervised defense framework that detects malicious multimodal prompts without requiring human-labeled training data. By extracting principal components from internal vision-language model (VLM) representations, it automatically identifies an anomalous "malicious subspace" in raw, unlabeled user traffic and trains a lightweight safeguarding classifier that outperforms existing defenses by over 13% AUROC.

What Problem Does This Paper Address?

Vision-Language Models (VLMs) like LLaVA and GPT-4V can process image-text inputs, opening new attack surfaces where adversaries manipulate visual pixels, textual instructions, or both (e.g., via jailbreaks or imperceptible adversarial perturbations).

Building a safeguarding classifier to detect these threats typically requires large, curated datasets of benign and malicious pairs. However, manually labeling prompts is expensive, difficult to scale, and struggles to keep up with evolving attacks. The authors ask: Can we train an effective malicious prompt detector directly from the mixture of unlabeled user queries collected during real-world VLM deployment?

Methods

VLMGuard treats the unlabeled user prompt stream as a mixture distribution: $P_{\text{unlabeled}} = (1 - \pi)P_{\text{benign}} + \pi P_{\text{malicious}}$, where the attack fraction $\pi$ is small. The defense proceeds in two main stages:

  1. Latent Subspace Maliciousness Estimation:
  2. The authors extract last-token representations ($f_i \in \mathbb{R}^d$) from a specific intermediate or late layer of the VLM for all unlabeled samples and center them.
  3. Performing Singular Value Decomposition (SVD) on this representation matrix reveals the primary axes of variation. Because malicious inputs cause out-of-distribution internal activations, their projections onto the top singular vectors ($v_j$) exhibit disproportionately large magnitudes compared to benign queries.
  4. Each sample is assigned an automated maliciousness score: $$\kappa_i = \frac{1}{k} \sum_{j=1}^k \lambda_j \cdot \langle f_i, v_j \rangle^2$$ where $\lambda_j$ is the singular value weighting the $j$-th principal direction.

  5. Training a Safeguarding Binary Classifier:

  6. Using a threshold on $\kappa_i$, the unlabeled pool is automatically split into pseudo-benign and pseudo-malicious sets.
  7. A lightweight two-layer MLP ($h_\theta$) is trained on these pseudo-labels using a smooth binary sigmoid loss.
  8. At test time, this classifier evaluates incoming prompts in a single forward pass without requiring expensive input mutations or external referee models.

Datasets

The authors evaluated their defense across two threat models:

  • Adversarial Meta-Instructions: Based on Zhang et al. (2024), where PGD-optimized visual perturbations force VLMs to alter outputs according to five biases (Language, Politics, Formality, Spam, Sentiment). Uses 25 benign and 300 malicious ImageNet images paired with 60 questions.
  • Multimodal Jailbreak Prompts: Combines 250 safe and 200 unsafe prompts from the XSTest benchmark with benign and adversarial images from Qi et al. (2023).
  • Target Models: Evaluated zero-shot using LLaVA-1.6 (7B & 13B) and Phi-3-Vision.

Key Insights and Ideas

  • Maliciousness Naturally Separates in Latent Space: Even without supervision, adversarial and jailbreak prompts introduce distinct structural shifts in the VLM's activation space. SVD reliably isolates this anomalous variance into a small top-$k$ subspace.
  • Classifier Generalization Beats Direct Projection: Training an MLP on pseudo-labeled data significantly outperforms directly scoring test points with the raw subspace projection (e.g., boosting AUROC by ~5–10%), as the neural classifier learns smoother decision boundaries that generalize better to novel prompts.
  • Cross-Threat Transferability: A classifier trained solely on one meta-objective (e.g., French/Spanish language steering) achieves over 91.7% AUROC when tested on jailbreak attacks (e.g., harmful bomb-making/fraud instructions), proving that VLMs develop generalizable latent indicators of malicious manipulation.
  • Location Matters: Representation extraction is sensitive to architecture. For LLaVA, the output of the full transformer block encodes maliciousness best; for Phi-3, the feedforward layer output yields better separation.

Key Results

  • Meta-Instruction Detection: On LLaVA-1.6-7B with only 1% malicious data ($\pi = 0.01$), VLMGuard achieves 92.87% average AUROC, outperforming Perplexity (79.66%), GradSafe (65.17%), JailGuard (66.56%), and MirrorCheck (71.79%). On Phi-3-Vision, it reaches 92.11% AUROC.
  • Jailbreak Detection: Achieves 94.27% AUROC on LLaVA-7B and 95.74% AUROC on Phi-3, demonstrating that multimodal jailbreaks (which attack both vision and text) are even more distinct in activation space than vision-only meta-instructions.
  • Robustness to Extreme Contamination Ratios: Even when the unlabeled dataset contains just a single malicious example ($\pi = 0.001$), VLMGuard maintains 89.01% AUROC.
  • Model Scalability: Performance improves as model scale increases: LLaVA-1.6-13B reaches 95.27% on meta-instructions and 96.01% on jailbreaks.

Limitations and Future Work

  • Threat Model Scope: Experiments focus primarily on continuous optimization-based attacks (e.g., PGD-generated perturbations). The authors note that it remains an open question whether the method applies equally well to discrete typographic attacks (e.g., text overlayed on images).
  • Benign Data Dilution: If the number of benign queries grows overwhelmingly large relative to malicious queries without periodic pruning, detection accuracy drops moderately (from 98.7% down to 88.2%), indicating the need for dataset filtering mechanisms in long-running deployments.

Summary updated

BibTeX
@misc{du2024vlmguard,
  author = {Xuefeng Du and Reshmi Ghosh and Robert Sim and Ahmed Salem and Vitor R. Carvalho and Emily Lawton and Yixuan Li and Jack W Stokes},
  title = {{VLMGuard: Defending VLMs against Malicious Prompts via Unlabeled Data}},
  year = {2024},
  eprint = {2410.00296},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.00296},
}

Loading related content...

Figure