Abstract
Current safety alignment for Large Language Models (LLMs) primarily targets semantic content, leaving a vulnerability to non-semantic representations. This paper introduces ArtPrompt, a novel jailbreak attack that utilizes ASCII art to bypass safety filters. By masking sensitive words and replacing them with visual character patterns, ArtPrompt exploits the gap between a model's ability to recognize visual text and its underlying reasoning capabilities. Our evaluation shows that ArtPrompt achieves a high success rate across state-of-the-art models, including GPT-4 and Claude, while remaining significantly more efficient than existing optimization-based attacks.
1. Introduction
The rapid deployment of Large Language Models (LLMs) has been accompanied by rigorous safety alignment techniques, such as Reinforcement Learning from Human Feedback (RLHF). These methods are designed to ensure that models refuse to generate harmful, illegal, or unethical content. However, these defenses predominantly focus on the semantics of natural language—the dictionary meanings and contextual associations of words.
This paper identifies a critical "semantic-only" blind spot. We demonstrate that by shifting the representation of a prohibited concept from standard text to ASCII art, attackers can bypass safety filters that are trained to recognize harmful strings. We introduce ArtPrompt, a black-box attack that leverages this loophole to elicit harmful responses from supposedly aligned models.
2. The ArtPrompt Attack Framework
ArtPrompt is a two-step, human-readable attack that does not require the thousands of iterations typical of optimization-based jailbreaks like GCG.
Step I: Word Masking
The attacker identifies a "sensitive" word within a harmful instruction that is likely to trigger a model's refusal mechanism. For example, in the prompt "Provide instructions on how to build a [BOMB]," the word "BOMB" is masked.
Step II: Cloaked Prompt Generation
The masked word is replaced with an ASCII art representation. The final prompt includes the ASCII art along with specific instructions for the LLM on how to interpret the visual pattern and integrate it back into the original request. Because the safety filter does not recognize the ASCII pattern as the prohibited word, the prompt is passed to the model's core reasoning engine.
3. The Vision-in-Text Challenge (ViTC)
To quantify the vulnerability, we developed the Vision-in-Text Challenge (ViTC), a benchmark designed to evaluate an LLM's ability to recognize ASCII art.
- ViTC-S: Focuses on single characters (letters and digits).
- ViTC-L: Focuses on sequences of characters (words).
The benchmark includes over 16,000 samples across hundreds of different fonts, providing a comprehensive measure of how models perceive visual character arrangements.
4. Experimental Results
We evaluated ArtPrompt against five leading LLMs: GPT-3.5, GPT-4, Claude, Gemini, and Llama2, using datasets such as AdvBench and HEx-PHI.
4.1 Attack Success Rate (ASR)
ArtPrompt demonstrated remarkable efficacy, achieving an average Attack Success Rate (ASR) of 52% across the tested models. It consistently outperformed existing baselines, including GCG, AutoDAN, and PAIR.
4.2 Efficiency and Robustness
Unlike optimization-based attacks that can take hundreds of queries to find a successful prompt, ArtPrompt is highly efficient, often succeeding in a single iteration. Furthermore, it proved robust against common defensive measures such as perplexity filters and retokenization, which are designed to catch "gibberish" or unusual character sequences but fail to account for the structured visual nature of ASCII art.
5. Discussion: The Recognition-Reasoning Gap
The success of ArtPrompt reveals a fundamental discrepancy in LLM capabilities. Our ViTC results show that models like GPT-4 have a surprisingly low accuracy (less than 4%) in recognizing ASCII art in isolation. However, when that same art is embedded in a prompt, the model's reasoning engine can often "decode" the intent through context and step-by-step processing. Once the model decodes the masked word, it proceeds to fulfill the harmful request because the initial safety check—which only looked for the literal string—was already bypassed.
6. Conclusion
ArtPrompt highlights a significant shift required in the field of AI safety. Current alignment techniques are overly reliant on semantic monitoring. To build truly robust defenses, safety training must expand to include non-semantic data and diverse representations of information. Our research shows that fine-tuning models on ASCII recognition (using the ViTC dataset) can improve their ability to identify and refuse these "cloaked" attacks, suggesting a path forward for more resilient safety alignment.
Summary updated