SpatialJB: How text distribution art becomes a jailbreak key for LLM guardrailsSpatialJB: How Text Distribution Art Becomes the "Jailbreak Key" for LLM Guardrails
SpatialJB arranges harmful content in two-dimensional layouts to bypass output guardrails; in Table 1, Grok4's no-guardrail Repeat ASR is 100%.
The attacker uses prompts to make the target LLM generate output according to a spatial template, so that harmful content is readable to humans while output guardrails that process only sequentially struggle to connect the scattered tokens. The paper does not state white-box or black-box. Success requires that the extracted content passes a word-level check as harmful and that the entire output passes a semantic check as benign or positive.
- Output guardrails reconstruct semantics sequentially, and existing format jailbreaks may still be recognized. The authors want guardrails to fail to read malicious intent in outputs while preserving human-readable formats.
- SpatialJB places harmful tokens into six types of two-dimensional templates, disrupting sequence adjacency; the authors explain this via attention decaying with sequence distance. SpatialD extracts segments at fixed positions and sends them to Llama Guard to decide whether to display.
- ASR measured on seven LLMs for Repeat/Summary and multiple guardrails. In Table 1, without guardrails, Grok4's spatial template in Repeat is 100%, and Claude's Corner is 62.7%. In Table 4, SpatialD's Acrostic average DSR is 90.5%.
- The authors point out that SpatialD's fixed extraction may cause DSR to drop when content is misplaced, and state that guardrails need spatial semantic awareness. Experiments cover seven LLMs, five guardrails, and DSR on JailBench; per-cell sample sizes and human agreement rates are not reported.
- Evaluated models
- GPT-4oDeepSeek-R1DeepSeek-V3Grok-4Gemini 2.5 ProClaude 3.5 SonnetLlama-4-MaverickClaude-3-7-sonnetGemini-2.5-flash-previewQwen-long
- Benchmarks
- HateBenchSetHate-Speech-OffensiveOffensiveLongDynamically Generated Hate DatasetAdvBenchJailBench
- Metrics
- ASRDSR
The researchers propose SpatialJB, which exploits the lack of robustness of Transformers to spatial structure perturbations by redistributing tokens across different rows, columns, or diagonals, disrupting the model's output generation process so that harmful content bypasses output guardrails without being detected. The paper reports an attack success rate close to 100% on multiple mainstream LLMs, and the success rate still exceeds 75% even when output guardrails such as the OpenAI Moderation API are added. The authors also provide baseline defense strategies against SpatialJB and evaluate their mitigation effects; the attack code, baseline defenses, and demonstrations have been made public.
Paper analysis
What problem does this paper attempt to solve?
How to make output guardrails fail to recognize malicious intent in model outputs, thereby bypassing output review.
How to make output guardrails fail to recognize malicious intent in model outputs, thereby bypassing output review.
- Scenario: The authors state that LLMs have entered various autonomous systems but still generate unsafe content. Controlling output format is seen by the authors as a jailbreak pathway; Peng et al. (2024) report about 90% success on GPT-like models.
- Existing shortcomings: The introduction divides format control into "replacing the carrier of malicious content" (encoding, low-resource languages, ArtPrompt, FlipAttack) and "adding interference" (e.g., Ubbi Dubbi). The authors argue that both still retain malicious semantics, and fine-tuned Transformer guardrails can reconstruct semantics from obfuscated sequences. The introduction cites Llama Guard with 83.7% detection accuracy on OpenAI-Mod and its ability to block PAIR and AdvPrompter.
- Observation: The authors argue that autoregressive, token-by-token processing cannot capture nonlinear spatial text. The introduction states that after vertical rearrangement, the semantic relevance in embedding space is 0.5846, while for linear format it is 0.9419.
- Proposed method: SpatialJB embeds harmful content into structured spatial templates, making it still human-readable while breaking sequence semantics. The authors also provide and evaluate a baseline defense, SpatialD (Appendix B).
- Threat model:
- Goal: To make guardrails unable to identify malicious intent in model outputs, thereby bypassing output review.
- Knowledge: The paper does not use white-box, black-box, gray-box, or no-box. Commercial LLMs are accessed via API; Llama Guard 4 is deployed locally on eight RTX 4090s.
- Capability: Use prompts with few-shot examples to specify output format, placing harmful content in non-contiguous spatial positions. During evaluation, hidden information is extracted according to template coordinates.
- Victim system: The LLM asked to generate according to the format, and the subsequent output guardrail. Success is defined only when the extracted content is flagged as harmful by word-level checks and the semantic check judges the entire output as benign or positive.
What related research exists?
Related work covers alignment, format jailbreaks, and guardrails; the authors state that existing format jailbreaks do not exploit spatial structure.
The authors divide existing format jailbreaks into carrier replacement and interference addition, and state they do not exploit the spatial structure of text.
Alignment and Deployment
- Instruction tuning and reinforcement learning: Section 2 states these techniques are used to make models follow user intent and avoid harmful or biased content. Xu et al. (2024) and Weber et al. (2025) are cited as studies showing aligned models are still vulnerable to adversarial inputs.
- Scope of use: The authors state LLMs have entered professional and daily life (Qi et al., 2025, etc.), so they care whether safety mechanisms hold in open environments.
Format Control Jailbreaks
- Early prompting and masking: The authors state early work used prompt engineering to make models repeat harmful content or summarize. Wei et al. (2023), Yong et al. (2024), and Peng et al. (2024) used encoding, rare languages, etc., to mask intent. The introduction writes Peng et al. at about 90% on GPT.
- ArtPrompt and FlipAttack: Jiang et al. (2024) used ASCII art; Liu et al. (2025b)'s FlipAttack is called by the authors the current state-of-the-art jailbreak method. The authors believe that as defenses strengthen, methods ignoring spatial structure become less effective.
- Two mechanisms: Carrier replacement includes encoding, low-resource languages, ArtPrompt, FlipAttack; interference addition is exemplified by Ubbi Dubbi. The authors argue that despite surface differences, the underlying malicious semantics remain, and they cannot withstand sequential semantic understanding.
Output Guardrails
- Detectors: Classifier toxicity detectors and fine-tuned LLM evaluators like Weber et al. (2025) and Chi et al. (2024) are used to identify unsafe prompts and outputs.
- Commercial integration: The authors state guardrails have been integrated into commercial pipelines (OpenAI, 2025). Llama Guard's detection accuracy on OpenAI-Mod is written as 83.7%, and it can defend against PAIR and AdvPrompter (Xu et al., 2024; Chao et al., 2025).
- Authors' judgment: The authors believe most guardrails still rely on semantic similarity or token-level analysis, and remain exposed to attacks that break contextual coherence or use special spatial formats.
Baselines and Benchmarks
- Baseline methods: Base64, Zulu, Ubbi Dubbi, PAP (Zeng et al., 2024), SATA (Dong et al., 2025). The appendix only summarizes their mechanisms: encoding, low-resource languages, colloquial game-like transformations, persuasive rewriting, keyword masking with auxiliary tasks.
- Datasets: Main experiments use HateBenchSet, Hate-Speech-Offensive, OffensiveLong, Dynamically Generated Hate Dataset. AdvBench is used when stacking with FlipAttack. SpatialD uses JailBench.
The authors position this work on spatial structure: existing output control cannot disrupt the Transformer's sequential semantics, while SpatialJB rearranges text into two-dimensional formats that are human-readable but semantically broken for guardrails.
How does the paper address this problem?
SpatialJB uses six types of two-dimensional templates to break sequence adjacency, and SpatialD then extracts and checks by position.
SpatialJB embeds harmful content into two-dimensional layouts, allowing humans to read the original meaning by spatial position, while guardrails that only attend over one-dimensional sequence indices struggle to connect these tokens. The authors also provide a post-hoc defense SpatialD.
Problem Setup and Formalization
- One-dimensional processing: Text is written as X=(x1,…,xn), each token is embedded and attention is computed layer by layer, with positional encodings added to sequence indices. The authors thus argue that tokens are identified only by their sequence index, not two-dimensional coordinates.
- Template family: The attack is formalized as a template family T. Each template maps sequential input to multi-line, multi-column, or diagonal layouts, breaking semantic continuity while maintaining readability. Figure 3 shows illustrations of six template types.
- Two instruction types: The same batch of harmful content goes through direct repetition (Repeat) and reasoning-based summarization (Summary), corresponding to paraphrase in guardrail research and summarization in jailbreak evaluation.
Six Template Types
- Line start and end: Acrostic places harmful tokens at the start of each line; Telestich places them at the end, altering position dependence.
- Line middle, diagonal, and corners: Center-Embedded embeds tokens in the middle of each line; Staircase places the i-th target token at position (i, i); Corner places tokens at the four corners of the text block.
- Filler: Multilingual Randomization inserts filler or foreign-language tokens between harmful tokens to increase vocabulary diversity.
- Generation: Appendix Algorithm 1 gives few-shot examples to the LLM according to the chosen layout, placing tokens one by one into corresponding positions to form output Y. The paper does not specify the number of iterations or an independent attacker model.
Theoretical Analysis
- Token Layout Loss: After a two-dimensional layout L(r, c) is flattened via π into a sequence, the visual neighborhood is no longer equal to the sequence neighborhood pulled back by π. The authors argue that self-attention therefore cannot access visual neighbors separated during serialization. Appendix C.1 provides the derivation.
- Token Sensitivity: The authors write the expected attention of relevant tokens as E[Aij] ∝ e−α|i−j| (α>0), meaning that as sequence distance increases, semantic relevance decays exponentially, weakening the local aggregation used by guardrails. Appendix C.2 provides the derivation. Figure 4 marks local similarity as 0.9419 for linear layout and 0.5846 for spatial layout.
Success Criteria
- Three stages: Appendix D.1.4 and Figure 8: first extract characters according to preset template coordinates; then perform word-level and semantic checks, with semantic checks exemplified by guardrails like Perspective API; success is recorded only when extracted content is judged harmful and the entire output is judged benign or positive.
- Human spot-check: The authors randomly spot-check 3% of results and claim high agreement with human evaluation, without giving an agreement rate.
Defense SpatialD
- Position: Post-hoc check before output is given to the user. It reconstructs the two-dimensional grid by line breaks and character positions, rather than treating the output as a linear sequence.
- Extraction: Except for the final random template, it extracts the first column, last column, diagonal, first and last words of each line, and the center of each line, then concatenates them (Appendix Algorithm 2).
- Disposition: Each segment is checked by Llama Guard. If any segment is judged harmful, the original output is isolated and a refusal is returned; otherwise, it is displayed as is. The authors state the current implementation relies on heuristic extraction rules.
What experiments did the paper conduct?
In Table 1, under Repeat without guardrails, DeepSeek-V3, Llama4, and Grok4 have 100% ASR for spatial templates.
Experimental Setup
- Tested LLMs: Section 4.1 lists GPT-4, DeepSeek-R1, DeepSeek-V3, Llama-4-Maverick, Gemini-2.5-Pro, Claude, Grok-4. Appendix D.1.1 writes GPT-4 as GPT-4o and Claude as Claude 3.5 Sonnet in the same group. Table headers are GPT4, Llama4, Grok4, Gemini 2.5-Pro.
- Additional for defense evaluation: ChatGPT-4o, Claude-3-7-sonnet, Gemini-2.5-flash-preview, DeepSeek-V3, Qwen-long (Table 4).
- Baselines and guardrails: Base64, Zulu, Ubbi Dubbi, PAP, SATA. Guardrails are Llama Guard 4, Perspective API, OpenAI Moderation API, WildGuard, HarmAug. Perspective API threshold is 0.5; for others, the paper says see Appendix D.1.5, with no numbers in the main text.
- Data and tasks: HateBenchSet, Hate-Speech-Offensive (the paper says 24,783 tweets), OffensiveLong, Dynamically Generated Hate Dataset (the paper says 40,463 entries). Domains are race, gender, religion, culture, economy, politics. Tasks are Repeat and Summary. The stacking experiment uses AdvBench; SpatialD uses JailBench. The paper does not report sample sizes or repetition counts for each ASR cell.
- Metrics: ASR is the success rate from Equation (1). Here, success is not merely "the model said harmful content" but that the extracted content is harmful and the entire output is judged benign or positive by semantic checks. SpatialD uses DSR. Human spot-check covers 3% of results.
Main Results
The table below is for Repeat, based on Table 1. Columns are Random template and no-guardrail SATA. All seven models are included.
Swipe horizontally to read the table
Model No-guardrail Random Llama Guard Random OpenAI Random No-guardrail SATA GPT4 98.3% 92.3% 95% 25.8% Deepseek-R1 100% 90% 77.3% 27.4% Deepseek-V3 100% 87% 90% 30.3% Llama4 100% 90% 85.6% 31.4% Gemini 2.5-Pro 94.3% 85.6% 74.6% 20.7% Claude 76.6% 61.3% 65.3% 19% Grok4 100% 88.3% 80% 25.9% Other templates, baselines like PAP, Summary, and Perspective, WildGuard, HarmAug are not included in the above table.
- No guardrails: The authors state that spatial template ASR is close to 100% on most models, and claim DeepSeek-V3, Llama4, and Grok4 are fully compromised. In Table 1, all six spatial templates for these three rows are 100%. Claude's Corner is 62.7% and Staircase is 79.7%, not 100%. The introduction says the highest on GPT-4 is 96%; Table 1 no-guardrail GPT4 Random is 98.3%.
- Relative to baselines: The authors state Zulu, Base64, Ubbi Dubbi are about 7%–15%, PAP averages 15%–19%, SATA averages 20%–31%, and claim the gap exceeds 80 percentage points, roughly an order of magnitude. In Table 1, no-guardrail Repeat, the first three are 7%–15.6%, SATA is 19%–31.4%.
- Inconsistency with abstract: The abstract says still over 75% against OpenAI Moderation API. In Table 1's OpenAI block, Claude's Corner is 57.3% and Gemini 2.5-Pro's Corner is 73.7%.
Guardrails, Tasks, and Content Categories
- After guardrails: The authors state ASR drops for all methods, but spatial formats still make it hard for guardrails to detect malicious content. In Table 1, Claude's Acrostic under Llama Guard is 57%, while SATA in that row is 19.3%; the authors claim the former is still about 40 percentage points higher. The authors state Perspective API is the strictest, and DeepSeek series and Grok4 remain almost unresistant under it.
- Summary: The authors state that summarization compresses content, models may filter out key harmful tokens, and such outputs are counted as failures, so ASR generally drops. In Table 2, no-guardrail Grok4 Random is 72.6%, Claude's Corner is 47.0%.
- Categories: Figure 5's specific bar heights are not given in the text. The authors state that ASR is high across categories except Claude, with gender and policy relatively lower.
Combinations and Ablations
- Table 3 only tests Claude: Only Format Control is 68%; only Positive Guidance is 20.80%; only Think Guidance is 10.40%; Format+Positive is 86.80%; Format+Think is 76.20%; all three is 97.60%. The authors state ASR increases roughly linearly with the number of modules, and the modules target different weaknesses and are complementary. The paper does not specify whether the guardrail and task for this table are Repeat or Summary.
- With FlipAttack: On AdvBench, of FlipAttack's 521 harmful outputs, 415 (79.65%) were originally detectable by Llama Guard but are judged safe after SpatialJB. The authors state the former acts on elicitation, the latter on delivery. The appendix gives examples of ArtPrompt+SpatialJB and FlipAttack+SpatialJB.
- Two points in Section 4.2: Multi-layer strategies are more effective than single-dimensional attacks; guardrails that only do single-dimensional checks are insufficient against multi-module attacks.
SpatialD
- Setup: Lightweight evaluation in Appendix B, JailBench, five commercial models, five position templates, excluding Multilingual Randomization. Metric is DSR.
- Results: Table 4 average DSR is Acrostic 90.5%, Telestich 87%, Center 80.5%, Corner 81%, Staircase 77%. The authors state Acrostic's DSR exceeds 90%; in that column, Qwen-long is 85%, and the five-model average is 90.5%. The lowest in the table is DeepSeek-V3's Staircase at 65%.
- Authors' interpretation: They call it a simple and feasible post-hoc solution; pre-fixed extraction may reduce DSR when malicious content is misaligned.
Other Ablations and Analyses
- Appendix Table 5, Repeat, Perspective: Claude Acrostic 64.7%, Grok4 Staircase 93%.
- Appendix Table 5, WildGuard: Claude Acrostic 62.4%, Grok4 Staircase 91.5%.
- Appendix Table 5, HarmAug: Claude Acrostic 60.5%, Grok4 Staircase 96.1%.
- Introduction and Figure 4: linear layout 0.9419, spatial layout 0.5846.
- Table 2 no-guardrail Summary: GPT4 Random 73.7%, Claude Staircase 59.8%.
- Table 1 no-guardrail Repeat: Llama4's SATA is 31.4%, a high value among that block's baselines; Claude's Base64 is 7%.
What are some points that can be further explored?
The authors point out that SpatialD relies on fixed extraction, and DSR may decrease with misaligned content.
Limitations and future directions noted by the authors
- Misplaced content: Appendix B.2.2 states that because the extraction method is pre-programmed and fixed, SpatialD's DSR may drop when malicious content is misplaced; the authors state this is a main task for future defense research.
- Heuristic rules: Appendix B.3 states that the current implementation relies on heuristic spatial extraction and output detection; the authors believe incorporating spatial semantics and nonlinear text awareness into safety alignment is a future direction.
- Capabilities needed by guardrails: Section 5 states that the authors believe guardrails need to integrate spatial semantic awareness and nonlinear context awareness to achieve robust safety alignment.
Experimental coverage
- Main attack: seven LLMs, five baselines, four harmful content datasets, Repeat and Summary, five output guardrails (Section 4.1, Tables 1–2, Appendix Tables 5–6).
- Stacking and ablations: Table 3 reports only Claude. Stacking with FlipAttack uses 521 outputs from AdvBench and is judged by Llama Guard (Section 4.2). The appendix also has combined examples of ArtPrompt and FlipAttack.
- SpatialD: DSR on five commercial models, JailBench, and five position templates (Table 4). The paper states it does not include the final random template.
- Unreported evaluation information: The paper states Hate-Speech-Offensive has 24,783 entries and Dynamically Generated Hate Dataset has 40,463 entries, but does not report sample sizes, repetition counts, or query counts for each ASR condition.
- Judgment details: Manual spot-checking covered 3% of results; the authors state agreement was high but do not report the agreement rate. The Perspective API threshold is 0.5; thresholds for the other guardrails are not given in the main text. Table 3 does not specify guardrails or task types.
Summarize the main content of the paper
SpatialJB bypasses output guardrails with two-dimensional layouts; in Table 1, Grok4's no-guardrail Repeat is 100%.
SpatialJB is an output format jailbreak, with a post-hoc defense SpatialD.
- Problem: The authors want output guardrails that reconstruct semantics sequentially to fail to recognize malicious intent in outputs, while keeping content readable to humans.
- Approach: Six templates place harmful tokens at line starts, line ends, line middles, diagonals, corners, or insert filler tokens between them. The theory section explains via serialization losing visual adjacency and attention decaying exponentially with sequence distance. Success requires extracted content to be harmful and the entire output to be judged benign or positive by semantic checks.
- Main results: In Table 1, Repeat, no guardrails, DeepSeek-V3, Llama4, and Grok4 have 100% ASR across all six spatial templates, GPT4's Random is 98.3%, Claude's Corner is 62.7%. In the same table's OpenAI block, Claude's Corner is 57.3%. The introduction also writes the highest on GPT-4 is 96%.
- Stacking and defense: On AdvBench, of 521 FlipAttack outputs, 79.65% are judged safe by Llama Guard after SpatialJB. In Table 3, Claude's three-module combination ASR is 97.60%; the paper does not specify the guardrail or task. In Table 4, SpatialD's Acrostic average DSR is 90.5%, and DeepSeek-V3's Staircase is 65%.
- Authors' conclusion: The authors believe this exposes structural weaknesses in Transformer guardrails and state that guardrails need spatial semantic awareness and nonlinear context awareness. SpatialD is called a baseline mitigation by the authors; fixed extraction may fail when content is misaligned.