TLDR: A new research paper introduces “PromptPirate” and “SeedSnitch,” tools that exploit a 32-bit seed vulnerability (CWE-339) in popular diffusion models like Stable Diffusion. They demonstrate that recovering the initial random seed is critical for effective prompt stealing. SeedSnitch can brute-force 95% of real-world seeds from platforms like CivitAI in about 140 minutes, and PromptPirate then uses this seed to steal prompts with significantly higher accuracy than previous methods. The paper also proposes countermeasures to enhance seed security.
In the rapidly evolving world of artificial intelligence, diffusion models have revolutionized text-to-image generation, creating stunningly realistic images from simple text descriptions, known as prompts. These prompts, often crafted with significant expertise, hold considerable intellectual and economic value, leading to a growing concern: prompt stealing.
A recent research paper, Prompt Pirates Need a Map: Stealing Seeds helps Stealing Prompts, delves into this critical security and privacy issue. Authored by Felix M ¨achtle, Ashwath Shetty, Jonas Sander, Nils Loose, S ¨oren Pirk, and Thomas Eisenbarth, the paper reveals a fundamental limitation in existing prompt recovery methods and introduces novel tools to exploit and mitigate these vulnerabilities.
The Overlooked Key: Initial Random Seeds
The core finding of the research is that current numerical optimization-based prompt recovery methods are significantly limited because they fail to account for the initial random noise, or ‘seed,’ used during image generation. This seed is not just a minor detail; it fundamentally influences the structure and characteristics of the final image. Images generated with different seeds, even from the same prompt, can appear entirely distinct to human observers.
A Critical Vulnerability: CWE-339 in Action
The researchers identified and exploited a widespread noise-generation vulnerability, categorized as CWE-339 (Small Seed Space in PRNG), present in major image-generation frameworks. This vulnerability stems from PyTorch’s restriction of seed values to a range of 2^32 when generating initial random noise on CPUs. This means that even if a larger seed is provided, only its lower 32 bits are used, drastically reducing the possible unique seeds and making them susceptible to brute-force attacks.
This critical flaw was found in several popular PyTorch-based image generation products, including AUTOMATIC1111 (macOS version), ComfyUI, Hugging Face’s Diffusers library (in certain configurations), Easy Diffusion, InvokeAI, and the Stable Diffusion 3.5 reference implementation.
SeedSnitch: Unlocking the Seed
To overcome this, the paper introduces SeedSnitch, a lightweight and powerful tool designed to recover the initial seed. Unlike previous approaches that relied on training classifiers, SeedSnitch directly exploits the latent structure of the generated image. By systematically enumerating possible 32-bit seed values and comparing the resulting latent representations using Mean Squared Error (MSE) loss, SeedSnitch can reliably identify the correct seed.
A large-scale empirical analysis on images from CivitAI, a popular platform for AI-generated content, demonstrated SeedSnitch’s effectiveness. Approximately 95% of these images’ seed values could be brute-forced in about 140 minutes per seed using their seed-recovery tool. In controlled experiments, SeedSnitch achieved 100% accuracy in recovering seeds within the 0-100,000 range of Stable Diffusion 3.5.
PromptPirate: Stealing Prompts with Precision
Leveraging the recovered seed, the researchers propose PromptPirate, a genetic algorithm-based optimization method specifically designed for prompt stealing. PromptPirate addresses the challenge of reconstructing stylistic prompt modifiers, a non-differentiable problem that traditional gradient-based methods struggle with.
PromptPirate iteratively refines candidate modifier sets, evaluating their fitness by generating images with the recovered seed and measuring the MSE loss against the target image’s latent representation. This approach significantly outperforms state-of-the-art methods like PromptStealer, P2HP, and CLIP-Interrogator, achieving an 8–11% improvement in LPIPS similarity, a metric that correlates strongly with human visual perception.
Also Read:
- Uncovering Security Flaws in AI Agent Tool Communication
- Securing AI: Understanding and Defending Against Prompt Injection Attacks
Real-World Impact and Mitigation
The CivitAI case study confirmed the practical feasibility and real-world impact of these attacks. The analysis of seed distribution showed a dominant reliance on CPU-generated seeds within the vulnerable 32-bit range, highlighting a widespread security risk for content creators.
To counter these vulnerabilities, the paper proposes straightforward and effective countermeasures. The primary recommendation is to adopt cryptographically secure random number generators (CSPRNGs) with significantly expanded seed ranges, such as 256 bits (e.g., ChaCha20). This would robustly prevent brute-force and cryptographic attacks with minimal computational overhead, ensuring reproducibility while safeguarding intellectual property.
This research underscores the critical importance of robust seed security practices in diffusion models, revealing a previously overlooked vulnerability that enables practical prompt-stealing attacks and offering clear pathways for mitigation.


