JANUS: A Lightweight Framework for Jailbreaking Text-to-Image Models via Distribution Optimization

Haolun Zheng, Yu He, Tailun Chen, Shuo Shao, Zhixuan Chu, Hongbin Zhou, Lan Tao, Zhan Qin, Kui Ren

TL;DR

JANUS is a lightweight, LLM-free framework that jailbreaks text-to-image (T2I) models by framing the attack as a distribution optimization problem. By dynamically mixing a harmful prompt distribution with a clean counterpart using a policy gradient, it efficiently bypasses both text and image safety filters while preserving the original semantic intent. JANUS significantly outperforms state-of-the-art methods on modern models like Stable Diffusion 3.5 and DALL-E 3 without the massive computational overhead of generative model-based attacks.

What Problem Does This Paper Address?

Commercial and open-source Text-to-Image (T2I) diffusion models deploy safety guardrails—such as prompt-level text filters and post-generation image checkers—to prevent the generation of Not-Safe-For-Work (NSFW) or harmful content. "Jailbreak" attacks attempt to circumvent these defenses by crafting adversarial prompts that trigger the prohibited content anyway.

Existing jailbreak methods fall into two deeply flawed paradigms:

  1. Prompt-level optimization: These methods iteratively tweak a single prompt to minimize a loss function. Because the full T2I pipeline is a non-differentiable black box, they must rely on hand-crafted proxy losses (like token similarity), which frequently fail to bypass actual safety filters in practice.
  2. Generator-level optimization: These methods train large generative models (like LLMs) using reinforcement learning (RL) to generate adversarial prompts. While effective at optimizing end-to-end objectives, they require massive computational resources and tens of billions of parameters.

The authors introduce JANUS to bridge this gap: an efficient, lightweight framework that directly optimizes the true end-to-end jailbreak objective without relying on expensive LLMs.

Methods

Instead of searching for a single discrete prompt or training a massive generator, JANUS reframes jailbreaking as optimizing a structured prompt distribution using principles from Energy-Based Models (EBMs). It operates via an elegant two-stage pipeline:

Stage 1: Semantically-Anchored Distribution Modeling

JANUS takes a target harmful prompt ($p_t$) and creates a "clean" version ($p_c$) by removing explicit NSFW words. It relaxes these discrete token sequences into continuous diagonal Gaussian distributions ($N_t$ and $N_c$) using a Dirac-inspired relaxation.

To combine them, JANUS uses a convex mixture: $$p_\alpha = \alpha N_t + (1-\alpha)N_c$$ where $\alpha \in [0, 1]$ is a scalar mixing policy. This acts as a probabilistic analogue to wave interference: the shared narrative structure of the two prompts constructively interferes, stabilizing the core semantics while allowing the framework to modulate the level of harmfulness.

Stage 2: Policy-Based Black-Box Optimization

JANUS treats the T2I system and its safety filters as a black box. It samples prompts from the mixed distribution $p_\alpha$ and feeds them to the target T2I model. It then evaluates the system's feedback using a custom energy function based on whether the text filter was bypassed and how explicit the resulting image is (measured by an external NSFW scorer). A lightweight policy gradient algorithm (REINFORCE) is then used to dynamically update the scalar $\alpha$ to maximize the jailbreak reward.

Figure 2. Overall pipeline of our JANUS. Stage 1 builds two se- mantically anchored base distributions from the target prompt pt and its clean counterpart pc, then mixes them into a parameterized prompt distribution pα. Stage 2 performs black-box policy opti- mization: samples from pα are evaluated by the T2I model, and the bypass/NSFW feedback updates the mixing policy α.

Datasets

To evaluate the framework under realistic conditions, the authors utilized a curated subset of 200 human-crafted NSFW prompts from the Civitai-8m-prompts dataset. This dataset provides a highly challenging benchmark due to its density of authentic, user-generated adversarial concepts.

Key Insights and Ideas

  • Decoupling Objectives: Rather than trying to simultaneously optimize for filter evasion, semantic preservation, and harmfulness in a vast discrete token space, JANUS bakes semantic preservation directly into the structure of the search space during Stage 1.
  • The Wave Interference Analogy: NSFW prompts often consist of a benign narrative structure embedded with a few explicit tokens. By mixing the clean and harmful distributions, the shared narrative context is reinforced, preventing the "semantic drift" (generating completely unrelated images) that plagues other soft-optimization attacks.
  • Extreme Dimensionality Reduction: By reducing the RL optimization space from thousands of LLM parameters down to a low-dimensional mixing parameter ($\alpha$), JANUS achieves highly efficient black-box exploration with negligible computational cost.

Key Results

JANUS was tested against state-of-the-art baselines (including MMA, QFA, and SneakyPrompt) across several leading T2I models:

  • Stable Diffusion 3.5 Large Turbo: JANUS achieved a Text Attack Success Rate (TASR) of 94.25% and an overall Attack Success Rate (ASR-8) of 43.15%, vastly outperforming the strongest baseline (QFA at 25.30%). It also maintained the highest semantic fidelity (CLIP score of 0.37).
  • DALL·E 3: Against commercial-grade, multi-layered defenses, JANUS achieved an ASR-8 of 3.39% and a TASR of 12.98%, outperforming all baselines.
Figure 1. Qualitative results of JANUS on Stable Diffusion 3.5 Large Turbo (left) and DALL·E3 (right). JANUS rewrites unsafe target prompts into distributionally optimized, ostensibly benign queries that bypass both text- and image-level safety filters, yet still induce model outputs aligned with the original prohibited intent.

The authors also demonstrated successful qualitative jailbreaks on Stable Diffusion XL and Midjourney, proving the framework's versatility across both open-source and proprietary commercial platforms.

Qualitative results of JANUS on Stable Diffusion XL and Midjourney.

Limitations and Future Work

  • Commercial Filter Resilience: Although JANUS outperforms existing baselines on DALL·E 3, the absolute attack success rate remains low (3.39%), indicating that commercial, multi-stage guardrails are still highly robust against distribution-based manipulation.
  • Dependency on Auxiliary Tools: The reward function relies on an open-source, third-party NSFW image scorer during the optimization phase, which may not perfectly align with the internal, proprietary safety filters of commercial T2I providers.
  • Future Defenses: The authors note that these findings expose structural vulnerabilities in current T2I safety pipelines, emphasizing that future defense mechanisms must become distribution-aware rather than relying purely on static prompt or image filtering.

Summary updated

BibTeX
@inproceedings{zheng2026janus,
  author = {Haolun Zheng and Yu He and Tailun Chen and Shuo Shao and Zhixuan Chu and Hongbin Zhou and Lan Tao and Zhan Qin and Kui Ren},
  title = {{JANUS: A Lightweight Framework for Jailbreaking Text-to-Image Models via Distribution Optimization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=Zmt7rvCXzZ},
}
Figure