Eyes Closed, Safety On: Protecting Multimodal LLMs via Image-to-Text Transformation

Yunhao Gou, Kai Chen, Zhili Liu, Lanqing Hong, Hang Xu, Zhenguo Li, Dit-Yan Yeung, James T. Kwok, Yu Zhang

TL;DR

ECSO (Eyes Closed, Safety On) is a novel, training-free defense strategy that protects Multimodal Large Language Models (MLLMs) from visual jailbreak attacks. By detecting unsafe initial responses and adaptively transforming input images into query-aware text captions, ECSO strips away the disruptive visual features and reactivates the underlying LLM's intrinsic safety guardrails. This approach drastically improves safety across multiple state-of-the-art models without sacrificing their general performance or utility.

What Problem Does This Paper Address?

Large Language Models (LLMs) undergo extensive safety alignment (like RLHF) to ensure they refuse harmful requests. However, when these models are expanded into Multimodal LLMs (MLLMs) by attaching a visual encoder, their safety mechanisms become shockingly fragile.

Malicious actors can easily bypass these guardrails using "visual jailbreaks"—such as embedding harmful text inside an image via typography or using gradient-based adversarial images. The core challenge is that integrating visual features alters the pre-aligned embedding space of the LLM, effectively "suppressing" its ability to recognize and refuse harmful prompts when an image is present.

Methods

The authors introduce ECSO (Eyes Closed, Safety On), a completely training-free, inference-time protection framework. Instead of trying to patch the complex multimodal embedding space, ECSO strategically reduces the problem back to the text-only domain where safety is already well-established.

The pipeline operates in four distinct steps:

  1. Initial Response Generation: The MLLM processes the user query and image normally to generate a response.
  2. Harmful Content Detection: The MLLM is prompted to evaluate its own initial response in a post-hoc manner ("Is the response harmful, unsafe, or unethical?"). If it deems the response safe, it is delivered to the user.
  3. Query-Aware Image-to-Text (I2T) Transformation: If the response is flagged as unsafe, ECSO "closes the model's eyes." It prompts the MLLM to describe the image, but crucially, conditions this description on the original user query. This ensures that task-relevant details are preserved while malicious visual noise or adversarial perturbations are filtered out.
  4. Safe Response Generation Without Images: The original text query and the newly generated text caption are fed back into the model without the image features. Stripped of visual embeddings, the model reverts to a text-only LLM, reactivating its original safety alignment to refuse or safely answer the prompt.
Fig. 3: Overview of ECSO. Step 1: User queries are full-filled as usual. Step 2: The MLLM is prompted to judge whether its initial response is safe or not. Safe answers are returned, while unsafe ones proceed Step 3 and 4. Step 3: Images of unsafe queries are converted into texts via query-aware text-to-image transformation. Step 4: Malicious content in either images or user queries are now both represented by plain text, which can be deal with by the pre-aligned LLMs in MLLMs to generate safe responses.

Datasets

The authors evaluated ECSO across several diverse benchmarks to test both safety and general utility:

  • Safety Benchmarks:
  • MM-SafetyBench: Evaluated across Stable Diffusion (SD), OCR, and combined (SD+OCR) splits spanning 8 critical harm scenarios (e.g., illegal activities, malware generation).
  • VLSafe: A dataset where malicious text queries are paired with benign, auxiliary images.
  • FigStep & Adversarial Images: Used to test robustness against typographic attacks and gradient-optimized adversarial images.
  • Utility Benchmarks: MME (Perception and Cognition splits), MMBench, and MM-Vet were used to ensure the defense mechanism does not degrade the model's standard capabilities on benign tasks.
  • Alignment Dataset: VLGuard was utilized to demonstrate how ECSO can act as an automated data engine to generate clean supervised fine-tuning (SFT) data.

Key Insights and Ideas

  • The "Suppression" Effect: The underlying safety alignment of an LLM isn't erased when it becomes multimodal; it is merely suppressed by the distribution shift introduced by visual features. As shown in the paper's preliminary findings, simply removing the image from a jailbreak attempt restores the harmless rate to nearly 100%.
  • High Self-Awareness of Harm: MLLMs are surprisingly excellent judges of their own outputs. Even when a model fails to block a jailbreak during generation, it can accurately identify that its own response is harmful over 95% of the time.
  • Query-Awareness is Mandatory: Standard image captioning fails because it misses context. If a user asks "Is the gray elephant in front of the brown elephant?", a generic caption might just say "two elephants in a ring." Query-aware captioning forces the model to extract the exact spatial or contextual details needed to answer the specific question safely.

Key Results

ECSO was validated across five state-of-the-art MLLMs (including LLaVA-1.5, ShareGPT4V, and Qwen-VL-Chat):

  • Massive Safety Boosts: For LLaVA-1.5-7B, ECSO improved the harmless rate on MM-SafetyBench (SD+OCR split) from 32.1% to 86.4%, and on VLSafe from 20.5% to 91.8%.
  • Preserved Utility: Across MME, MMBench, and MM-Vet, ECSO caused virtually zero performance degradation. In fact, it slightly improved performance on certain cognition tasks, likely because explicit text captions provide a cleaner reasoning chain than raw visual tokens.
  • Autonomous Data Engine: The authors used ECSO to automatically generate safe responses to unsupervised data, creating a clean dataset for Supervised Fine-Tuning (SFT). Models fine-tuned on ECSO-generated data achieved a better safety-utility trade-off than those trained on data curated by GPT-4.

Limitations and Future Work

While highly effective, ECSO's performance is fundamentally bounded by the safety capabilities of its underlying text-only LLM. If the base LLM itself has safety vulnerabilities or lacks alignment on a specific topic, converting images to text will not solve the issue.

Additionally, the current framework treats multimodality as a liability for safety. The authors note that an exciting future direction is learning how to leverage multiple modalities cooperatively to enhance safety, turning rich visual context into a defensive asset rather than a vulnerability.

Summary updated

Abstract

Multimodal large language models (MLLMs) have shown impressive reasoning abilities. However, they are also more vulnerable to jailbreak attacks than their LLM predecessors. Although still capable of detecting the unsafe responses, we observe that safety mechanisms of the pre-aligned LLMs in MLLMs can be easily bypassed with the introduction of image features. To construct robust MLLMs, we propose ECSO (Eyes Closed, Safety On), a novel training-free protecting approach that exploits the inherent safety awareness of MLLMs, and generates safer responses via adaptively transforming unsafe images into texts to activate the intrinsic safety mechanism of pre-aligned LLMs in MLLMs. Experiments on five state-of-the-art (SoTA) MLLMs demonstrate that ECSO enhances model safety significantly (e.g.,, 37.6% improvement on the MM-SafetyBench (SD+OCR) and 71.3% on VLSafe with LLaVA-1.5-7B), while consistently maintaining utility results on common MLLM benchmarks. Furthermore, we show that ECSO can be used as a data engine to generate supervised-finetuning (SFT) data for MLLM alignment without extra human intervention.
BibTeX
@inproceedings{gou2024eyes,
  author = {Yunhao Gou and Kai Chen and Zhili Liu and Lanqing Hong and Hang Xu and Zhenguo Li and Dit-Yan Yeung and James T. Kwok and Yu Zhang},
  title = {{Eyes Closed, Safety On: Protecting Multimodal LLMs via Image-to-Text Transformation}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72643-9\_23},
}
Figure