TL;DR
This paper introduces PROMPTMINER, a novel black-box framework for "prompt stealing" – recovering the text prompt used to generate an image. It achieves state-of-the-art results by combining reinforcement learning for subject reconstruction and fuzz testing for stylistic modifier recovery, outperforming existing methods and demonstrating robustness against defenses.
What Problem Does This Paper Address?
Text-to-image (T2I) models like Stable Diffusion can create stunning visuals from text prompts. However, crafting these prompts is an art, requiring significant expertise and iterative refinement, making them valuable digital assets. This value creates a security risk: "prompt stealing attacks" aim to recover these valuable prompts from generated images. Existing methods often fail because they require white-box access to the model, need large labeled datasets, or only perform basic image captioning without true prompt optimization. This limits their practicality and effectiveness in real-world scenarios.
Methods
PROMPTMINER tackles prompt stealing with a two-phase approach:
- Reinforcement Learning (RL)-Based Prompt Inversion: This phase focuses on reconstructing the core subject of the prompt. It frames prompt generation as a Markov Decision Process (MDP) and uses RL to optimize a lightweight adapter on top of a frozen captioner. A key innovation here is the use of potential-based reward shaping, which provides denser feedback signals to the RL agent, accelerating convergence and improving stability compared to sparse, end-of-episode rewards. This phase is warm-started with imitation learning from expert trajectories.
- Fuzz Testing-Powered Prompt Optimization: After the RL phase has established a semantically sound subject, this phase refines and enriches the prompt with stylistic and compositional modifiers. It treats modifier discovery as a controlled exploration process. A quality-driven seed pool of promising prompts is maintained, and a set of VLM-based mutators (e.g., subject paraphrasing, modifier generation, style adjustment) iteratively generate new prompt variants. These variants are evaluated based on their generated image's similarity to the target, and high-scoring ones are retained for further mutation. This approach is designed to be structure-aware, handling subjects and modifiers separately to avoid drifting from the original content.
Datasets
The authors evaluated PROMPTMINER on four widely used datasets:
- MS COCO: Contains everyday scenes with natural photographs and human-written captions.
- Flickr: A dataset of real-world photos with multiple human-written sentences per image.
- Lexica: A collection of keyword-focused prompts from an online service, often including stylistic and technical modifiers.
- DiffusionDB: A large-scale dataset of prompts and generated images, treated as an "in-the-wild" benchmark where the underlying generative models are unknown.
For training and evaluation, they used four state-of-the-art T2I models: Stable Diffusion v1.5, SDXL-Turbo, Stable Diffusion 3.5 Medium, and FLUX.1 dev.
Key Insights and Ideas
- Decoupling is Key: The core innovation is decoupling the prompt stealing problem into subject reconstruction (RL) and modifier refinement (fuzzing). This allows for specialized optimization for each aspect, leading to more comprehensive and accurate prompts.
- RL with Reward Shaping for Prompt Generation: Using RL for prompt generation is not entirely new, but the application of potential-based reward shaping significantly improves efficiency and stability by providing denser feedback during the learning process.
- Fuzzing for Creative Refinement: Applying fuzz testing, typically used for software security, to prompt engineering is a novel idea. By using VLM-based mutators and a structured approach, it effectively explores the prompt space to discover nuanced stylistic elements.
- Robustness to Defenses: PROMPTMINER shows remarkable resilience against common image-based defenses like random noise injection and textual watermarking, suggesting its semantic-driven optimization is less susceptible to low-level perturbations.
- Generalization to Unknown Models: The framework's ability to perform well on "in-the-wild" images with unknown generators highlights its practical applicability beyond controlled environments.
Key Results
- State-of-the-Art Performance: PROMPTMINER consistently outperforms existing baselines in both image similarity (CLIP up to 0.958) and textual alignment (SBERT up to 0.751) across multiple datasets and T2I models.
- Superior Generalization: On in-the-wild images with unknown generators, PROMPTMINER achieved 7.5% higher CLIP similarity than the strongest baseline.
- Robustness: Post-processing defenses had only a minor impact on PROMPTMINER's performance.
- Qualitative Improvements: Visualizations show that images generated using PROMPTMINER's recovered prompts are visibly closer to the target images than those from baselines.
- User Study Validation: Human evaluators consistently preferred images generated by PROMPTMINER's prompts, indicating better perceptual alignment.
Limitations and Future Work
- Query Budget Trade-off: The paper notes a trade-off between allocating queries to the RL phase (Phase I) and the fuzzing phase (Phase II). While balanced allocations are efficient, further research could explore optimal strategies for different prompt complexities.
- VLM Mutator Dependency: The effectiveness of the fuzzing phase relies on the capabilities of the VLM mutators. While open-source models like Qwen2-VL showed strong performance, the use of proprietary models like GPT-4o might raise accessibility concerns.
- Future Work: The authors suggest that their work highlights the growing need for prompt protection in generative systems and provides a foundation for future research on secure and interpretable prompt recovery.
Summary updated