ASCII Art and Visual Jailbreaks
Jiang, Xu, Niu, Xiang, Ramasubramanian, Li, Poovendran, "ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs" (ACL 2024, arXiv:2402.11753). Mask the safety-relevant words in a harmful request, swap them for ASCII-art renderings of the same letters, and send the cloaked prompt. GPT-3.5, GPT-4, Gemini, Claude, and Llama-2 struggle to recognize the art reliably, so the attack slips past perplexity filters, paraphrase defenses, and retokenization. Related: the ViTC benchmark measures recognition of non-semantic visual prompts, and StructuralSleight generalizes the idea to Uncommon Text-Encoded Structures (trees, graphs, nested JSON).
Learning Objectives
- Describe the ArtPrompt attack: word-identification step, ASCII-art substitution, final cloaked prompt.
- Explain why standard defenses (PPL, Paraphrase, Retokenization) fail on ArtPrompt.
- Define ViTC and describe what it measures.
- Describe StructuralSleight as a generalization to arbitrary Uncommon Text-Encoded Structures.
The Problem
Paraphrase and roleplay attacks (Lesson 12) and long-context attacks (Lesson 13) work on text patterns. ArtPrompt works at the recognition level. The model never has to parse the forbidden token as text; it reads a picture drawn in characters. The safety filter sees punctuation and spaces. The model sees a word.
The Concept
ArtPrompt, two steps
Step 1, word identification. Given a harmful request, the attacker uses an LLM to pick out the safety-relevant words (e.g., "bomb" in "how to make a bomb").
Step 2, cloaked prompt generation. Replace each identified word with its ASCII-art rendering, a 7x5 or 7x7 block of characters shaped like the letters. The model receives a grid of punctuation and spaces that a capable model can read as the word. A safety filter sees only the grid.
Result: GPT-4, Gemini, Claude, Llama-2, and GPT-3.5 fell to it, with attack success rate above 75% on the paper's benchmark subset.
Why the standard defenses fail
- PPL (perplexity filter). ASCII art has high perplexity, but so does any novel legitimate input. A threshold tight enough to block ArtPrompt also blocks structured input people actually send.
- Paraphrase. Paraphrasing the prompt should destroy the ASCII art. In practice, paraphrase LLMs often preserve or reconstruct it.
- Retokenization. Splitting tokens differently changes nothing, because the model recognizes letter shapes visually, not by token.
The underlying issue is that safety filters work at the token or semantic level, and ArtPrompt works at the level of visual recognition.
ViTC benchmark
ViTC measures recognition of non-semantic visual prompts: can the model read ASCII art, wingdings, and similar encoded text. ArtPrompt's effectiveness correlates with ViTC accuracy. The better a model reads visual text, the better the attack works on it, which makes this a capability-safety tradeoff.
StructuralSleight
StructuralSleight generalizes ArtPrompt to Uncommon Text-Encoded Structures (UTES): trees, graphs, nested JSON, CSV-in-JSON, diff-style code blocks. If a structure is rare in safety training data but the model can parse it, it can hide harmful content.
The defense implication is that safety has to generalize across the structured representations the model can parse, a set that is large and still growing.
Image-modality analog
Visual LLMs (GPT-5.2, Gemini 3 Pro, Claude Opus 4.5, Grok 4.1) widen the attack surface. ArtPrompt-style attacks with actual images are stronger than the ASCII-art versions because image encoders produce a richer signal.
Where this fits in Phase 18
Lessons 12-14 cover three orthogonal attack vectors: iterative refinement (PAIR), context length (MSJ), and encoding (ArtPrompt/StructuralSleight). Lesson 15 moves from model-centric attacks to system-boundary attacks (indirect prompt injection). Lesson 16 covers the defensive tooling response.
Use It
main.py builds a toy ArtPrompt. It cloaks specific words in a harmful query with ASCII-art glyphs, checks that the cloaked string passes a keyword filter, and scores both versions with a crude perplexity heuristic. There is no decoder. The toy covers only the attack side.
Ship It
Save outputs/skill-encoding-audit.md. Given a jailbreak-defense report, the skill lists the encoding attack families the report covers (ASCII art, base64, leet-speak, UTF-8 homoglyph, UTES) and the defense layer that catches each.
I'd run main.py and read the two printouts side by side. The original prompt trips the keyword filter. The cloaked one does not, because the string "bomb" never appears in it, only a [word-0] placeholder and a grid of # characters. The filter is a plain substring match, so that is all it takes to get past it.
The toy is narrower than the paper. It has 5-row glyphs for ten letters (B, O, M, A, K, E, W, P, N, H), and any other letter renders as blank space with no warning. Of the forbidden words in the script, only "bomb" and "weapon" survive that. Swap in "hack" and the C silently vanishes from the art, so check the rendered block before you trust a run.
Look at the perplexity numbers too. The heuristic is only the fraction of characters that are neither alphanumeric nor whitespace. The cloaked prompt scores 0.343 against the 0.4 threshold, so the toy PPL filter lets it through. The script's comment hedges that it "may trip PPL"; in my run it does not. I'd read that as a property of a crude proxy, not as evidence about real perplexity filters.
Exercises
-
Run
main.py. Verify the cloaked string passes a simple keyword filter. Report the character-level change required. -
Implement a second encoding: base64 for the same target word. Compare the filter-bypass rate against ArtPrompt and the recovery difficulty.
-
Read Jiang et al. 2024 Section 4.3 (five-model results). Propose a reason why Claude's ArtPrompt-resistance is higher than Gemini's on the same benchmark.
-
Design a pre-generation defense that detects ASCII-art-shaped regions in the prompt. Measure the false-positive rate on legitimate code, tables, and mathematical notation.
-
StructuralSleight lists 10 encoding structures. Sketch a generalized defense that handles all 10 and estimate the compute cost per defended prompt.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| ArtPrompt | "the ASCII-art attack" | Two-step jailbreak that masks safety words with ASCII-art renderings |
| Cloaking | "hide the word" | Replace a forbidden token with a visual representation the model reads but the filter does not |
| UTES | "uncommon structure" | Uncommon Text-Encoded Structure: tree, graph, nested JSON, etc. used to smuggle content |
| ViTC | "visual-text capability" | Benchmark for model's ability to read non-semantic visual encoding |
| Perplexity filter | "PPL defense" | Reject prompts with high perplexity; fails because legitimate structured input also scores high |
| Retokenization | "tokenizer shift defense" | Pre-process the prompt with a different tokenizer; fails because recognition is visual |
| Homoglyph | "lookalike characters" | Unicode characters that look identical to Latin letters; bypass substring checks |
Further Reading
- Jiang et al. - ArtPrompt (ACL 2024, arXiv:2402.11753): the ASCII-art jailbreak paper
- Li et al. - StructuralSleight (arXiv:2406.08754): UTES generalization
- Chao et al. - PAIR (Lesson 12, arXiv:2310.08419): complementary iterative attack
- Anil et al. - Many-shot Jailbreaking (Lesson 13): complementary length attack
Code
- main.py (python, 112 lines)