Introduction
Text-to-image (T2I) generative models, such as Stable Diffusion and DALL·E 2, have revolutionized digital content creation. However, their ability to generate high-fidelity images from arbitrary text prompts introduces significant ethical risks, particularly the potential for generating Not-Safe-For-Work (NSFW) or harmful content. To mitigate these risks, developers have implemented various safety filters designed to block prohibited prompts or suppress unsafe outputs.
Despite these guardrails, the robustness of these filters against automated, adversarial attacks has remained largely unexplored. Researchers have now introduced SneakyPrompt, the first automated framework designed to "jailbreak" T2I models. By leveraging reinforcement learning, SneakyPrompt iteratively replaces sensitive keywords with "sneaky" alternatives that bypass filters while preserving the original semantic intent of the user.
The Landscape of Safety Filters
Safety filters in T2I systems typically operate at different stages of the generation pipeline. As shown in Figure 1, these filters can be text-based (blocking input prompts), image-based (filtering generated pixels), or a hybrid of both.
Most existing filters rely on keyword blacklists or text-embedding classifiers. While effective against naive users, these "shallow" filters often have decision boundaries that can be circumvented. Previous attempts to bypass these filters were manual and slow, or relied on standard text-based adversarial attacks that often destroyed the prompt's meaning, resulting in images that failed to match the user's original goal. SneakyPrompt addresses this by finding prompts that are "invisible" to filters but "visible" to the image generator.
Methodology: The SneakyPrompt Framework
SneakyPrompt treats safety filters as a closed box and employs Reinforcement Learning (RL) to navigate the vast search space of potential word replacements. The framework operates through a continuous loop:
- The RL Agent: Using an LSTM-based policy network, the agent identifies sensitive words in a prohibited prompt and selects replacement tokens from a broad vocabulary.
- The Reward Function: The agent is rewarded based on two primary criteria: Bypass Success (did the prompt pass the filter?) and Semantic Similarity (does the generated image still reflect the original intent?). To measure semantic similarity without internal model access, the authors use a "shadow" text encoder (like CLIP) to ensure the adversarial prompt remains close to the original target in the embedding space.
- Optimization: To minimize query costs—crucial for paid APIs like DALL·E 2—the system utilizes search space expansion and early stopping once a high-quality bypass is identified.
Experimental Evaluation
The researchers evaluated SneakyPrompt against seven different safety filters using two main datasets: NSFW-200 (200 prompts generated by GPT-3.5 to simulate prohibited requests) and Dog/Cat-100 (100 harmless prompts used as a control group to test semantic preservation).
Key Results
- High Bypass Rates: SneakyPrompt achieved a 57.15% bypass rate on DALL·E 2’s proprietary filter, whereas baseline adversarial attacks failed entirely. Against Stable Diffusion's open-source filters, the framework achieved a near 100% bypass rate in multiple scenarios.
- Efficiency: The attack is highly efficient, requiring an average of only 14.7 queries for Stable Diffusion and 24.5 queries for DALL·E 2.
- Semantic Integrity: Unlike previous methods, SneakyPrompt maintains high image quality and semantic relevance. Images generated via SneakyPrompt showed significantly lower FID scores compared to other adversarial methods, proving that the "sneaky" tokens successfully convey the prohibited meaning to the diffusion model.
Insights and Future Directions
The success of SneakyPrompt reveals that many safety filters operate on a fragile decision boundary. Because many T2I models and filters share similar training data (e.g., CLIP embeddings), adversarial prompts often transfer successfully from open-source "shadow" models to closed-box targets like DALL·E 2.
As automation makes manual jailbreaking obsolete, developers must move beyond static keyword lists. The authors suggest that long-term solutions may require adversarial training—incorporating "sneaky" prompts into filter training sets—or concept erasure, where sensitive concepts are intrinsically removed from the diffusion model's weights so they cannot be generated regardless of the prompt.
Summary updated