Jailbreaking Prompt Attack: A Controllable Adversarial Attack against Diffusion Models

Jiachen Ma, Yijiang Li, Zhiqing Xiao, Anda Cao, Jie Zhang, Chao Ye, Junbo Zhao

Introduction

Text-to-Image (T2I) diffusion models, such as DALL-E 2 and Midjourney, have revolutionized content creation but pose significant risks regarding the generation of harmful or sexually explicit content. To mitigate these risks, developers employ safety checkers that filter sensitive keywords in prompts or block unsafe output images. However, existing "jailbreaking" attacks often suffer from high computational costs, requirements for white-box model access, or poor semantic fidelity—where the resulting image fails to match the user's original intent.

This paper introduces the Jailbreaking Prompt Attack (JPA), an automated and efficient framework designed to bypass safety filters by exploiting the high-dimensional text embedding space. JPA generates adversarial prompts that are mathematically aligned with harmful concepts while appearing as "gibberish" to standard text filters, achieving high success rates with minimal optimization time.

Methodology

The JPA framework operates by identifying and injecting malicious concept vectors into a prompt's embedding without triggering keyword-based detection. The process is divided into three primary stages:

  1. Concept Vector Extraction: Using an LLM (e.g., ChatGPT), the system generates antonym pairs for a target harmful concept (e.g., "nude" vs. "clothed"). By calculating the difference between their embeddings, a concept vector is isolated that represents the essence of the prohibited content.
  2. Prefix Optimization: A short sequence of learnable tokens (a prefix) is prepended to the user's original prompt. These tokens are optimized in the soft embedding space to align the overall prompt embedding with the malicious concept vector.
  3. Gradient Masking and Discrete Mapping: To maintain stealth, gradient masking ensures the optimization does not converge on known sensitive keywords. The resulting soft embeddings are then mapped back to a discrete vocabulary, producing a seemingly nonsensical prefix that carries the intended malicious weight.
Overview of the JPA methodology, illustrating the optimization in soft embedding space and the conceptual mapping from sensitive to insensitive prompts.

The intensity of the attack can be controlled via a scalar parameter $\lambda$, allowing for precise adjustment of the "NSFW" content's prominence in the final output.

Experimental Evaluation

The researchers evaluated JPA using the Inappropriate Image Prompt (I2P) dataset, focusing on subsets for nudity (NSFW-142) and violence (NSFW-90). The attack was tested against both open-source models (Stable Diffusion, SDXL) and commercial black-box services (DALL-E 2, Midjourney).

Key Results

  • Efficiency: JPA is remarkably fast, generating successful adversarial prompts in approximately 6.72 minutes. This is a 4-9x speedup over previous state-of-the-art methods like Ring-A-Bell or SneakyPrompt, which often require 30–60 minutes.
  • Attack Success Rate (ASR): JPA achieved an ASR exceeding 90% against multiple defended models for nudity-related concepts.
  • Semantic Fidelity: A critical advantage of JPA is its ability to preserve the original prompt's meaning. While other attacks often produce distorted or irrelevant images to bypass filters, JPA's results remain visually consistent with the user's intent, only adding the requested NSFW elements.
Comparison of JPA against other attack methods. JPA maintains superior semantic alignment and visual quality while successfully bypassing safety checkers.

Discussion and Conclusion

The success of JPA highlights a fundamental vulnerability in T2I models: safety is not merely a matter of blocking words. The underlying mathematical embedding space is inherently "un-robust," allowing harmful concepts to be summoned through vector manipulation.

While JPA currently relies on LLMs for initial concept search and faces potential detection as safety checkers evolve to recognize "gibberish" patterns, it underscores the need for more robust defense mechanisms. The authors suggest that future research should pivot from input/output filtering toward "concept removal" techniques that erase harmful data directly from the model's weights.

Summary updated

BibTeX
@inproceedings{ma2025jailbreaking,
  author = {Jiachen Ma and Yijiang Li and Zhiqing Xiao and Anda Cao and Jie Zhang and Chao Ye and Junbo Zhao},
  title = {{Jailbreaking Prompt Attack: A Controllable Adversarial Attack against Diffusion Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.172},
}
Figure