Abstract
Despite rapid advancements in text-to-image (T2I) models, their safety mechanisms are vulnerable to adversarial prompts, which maliciously generate unsafe images. Current red-teaming methods for proactively assessing such vulnerabilities usually require white-box access to T2I models, and rely on inefficient per-prompt optimization, as well as inevitably generate semantically meaningless prompts easily blocked by filters. In this paper, we propose APT (AutoPrompT), a black-box framework that leverages large language models (LLMs) to automatically generate human-readable adversarial suffixes for benign prompts. We first introduce an alternating optimization-finetuning pipeline between adversarial suffix optimization and fine-tuning the LLM utilizing the optimized suffix. Furthermore, we integrates a dual-evasion strategy in optimization phase, enabling the bypass of both perplexity-based filter and blacklist word filter: (1) we constrain the LLM generating human-readable prompts through an auxiliary LLM perplexity scoring, which starkly contrasts with prior token-level gibberish, and (2) we also introduce banned-token penalties to suppress the explicit generation of banned-tokens in blacklist. Extensive experiments demonstrate the excellent red-teaming performance of our human-readable, filter-resistant adversarial prompts, as well as superior zero-shot transferability which enables instant adaptation to unseen prompts and exposes critical vulnerabilities even in commercial APIs (e.g., Leonardo.Ai.).
Introduction
As text-to-image (T2I) models like Stable Diffusion and Midjourney become more powerful, their safety mechanisms—designed to prevent the generation of "Not-Safe-For-Work" (NSFW) content—have become a critical area of research. "Red-teaming" is the process of proactively stress-testing these models to find vulnerabilities.
However, existing red-teaming methods face three major hurdles:
- Access Constraints: Many require "white-box" access (knowledge of the model's internal gradients), which isn't possible for commercial APIs.
- Efficiency: Current methods often rely on per-prompt optimization, which is computationally expensive and slow.
- Stealth: Many adversarial prompts result in "token-level gibberish"—strings of random characters that are easily caught by simple perplexity filters or blacklist filters.
Methodology: The AutoPrompt (APT) Framework
The core of the paper is AutoPrompt (APT), which uses an LLM as a "suffix generator." The process follows an alternating pipeline:
- Adversarial Suffix Optimization: The researchers use a frozen LLM to generate candidate suffixes for benign prompts using stochastic beam search. They optimize these suffixes based on a "jailbreak constraint" that balances inducing the T2I model to generate unsafe images with keeping the text natural (low perplexity).
- LLM Fine-tuning: Successful adversarial suffixes are stored in a "replay buffer" used to fine-tune the LLM. This allows the LLM to learn the patterns of successful attacks, enabling it to generate effective suffixes for new, unseen prompts in a single inference step.
- Dual-Evasion Strategy: To bypass defenses, APT employs a Perplexity Constraint (using an auxiliary LLM to ensure naturalness) and Banned-Token Penalties (explicitly penalizing words found in safety blacklists).
Key Insights and Results
The study primarily utilizes the I2P (Image-to-Prompt) dataset, focusing on nudity and violence categories.
Performance and Efficiency
APT achieves significantly higher success rates than previous methods while remaining nearly three orders of magnitude faster. On the SLD-MAX safety mechanism, APT achieved a 70.50% Red-teaming Success Rate (RSR) for nudity, significantly outperforming baselines like Ring-A-Bell and P4D.
Human-Readability and Stealth
Unlike previous attacks that used "noise" or gibberish, APT proves that semantically meaningful text is actually harder to defend against because it mimics legitimate user behavior. APT's prompts achieved the lowest (best) Perplexity (PPL) scores; for example, its average PPL was nearly 1/70th that of the Ring-A-Bell method.
Zero-Shot Transferability
Adversarial prompts optimized for one model (like Stable Diffusion) often work on entirely different, closed-source commercial models like Leonardo.Ai and Midjourney without any additional tuning. The authors successfully bypassed safety filters on cutting-edge models including SDXL, FLUX.1-dev, and Midjourney.
Conclusion
The authors acknowledge a fundamental trade-off between attack strength and stealth. Extremely strict banned-token penalties can sometimes prevent the model from generating the specific tokens necessary to trigger a "jailbreak." Future work may involve dynamic penalty scheduling and developing more universal adversarial generators across different unsafe concepts. Ultimately, this work advocates for "controlled release" protocols and more robust defensive innovation in the T2I space.
Summary updated