Vulnerability of Text-to-Image Models to Prompt Template Stealing: A Differential Evolution Approach

Yurong Wu, Fangwen Mu, Qiuhong Zhang, Jinjing Zhao, Xinrun Xu, Lingrui Mei, Yang Wu, Lin Shi, Junjie Wang, Zhiming Ding, Yiwei Wang · DOI

Introduction

As text-to-image (T2I) models like Midjourney, DALL-E 3, and Stable Diffusion have become central to the generative AI landscape, a secondary economy has emerged: the prompt trading market. On platforms like PromptBase, creators sell "prompt templates"—carefully engineered strings containing fixed stylistic modifiers and variable subject placeholders. These templates represent significant intellectual property, as they allow users to generate consistent, high-quality art across diverse subjects.

However, this paper exposes a critical security vulnerability in this economy. We demonstrate that these proprietary templates can be reverse-engineered using only a few publicly visible sample images. We introduce EvoStealer, a novel framework that leverages differential evolution (DE) and Multimodal Large Language Models (MLLMs) to "steal" these templates with high accuracy and minimal cost, bypassing the need for model fine-tuning or internal access to the target generator.

The Problem: From Prompt Stealing to Template Extraction

Previous research into prompt security primarily focused on "prompt inversion," or extracting the specific prompt used to generate a single image. While effective for one-off replicas, these methods fail to capture the underlying generalizable template. A template is the stylistic "DNA" of a creator's work; if an attacker can extract this recipe, they can generate an infinite number of new images in that specific style without paying the original creator.

The challenge lies in distinguishing between the subject of a sample image (e.g., a cat) and the style dictated by the template (e.g., surreal watercolor with intricate floral textures). Simple captioning models often overfit to the subject, failing to produce a template that generalizes to new, "out-of-domain" subjects.

The EvoStealer Framework

EvoStealer treats prompt stealing as an evolutionary optimization problem. It is a "plug-and-play" attack framework consisting of three main phases:

1. Image Element Extraction

Instead of generating a single descriptive sentence, EvoStealer uses MLLMs (such as GPT-4o) to decompose sample images into a structured triple: <Subject, Modifiers, Supplements>.

  • Modifiers cover standard artistic categories like composition, lighting, and medium.
  • Supplements capture nuanced, abstract details that standard categories often miss, such as specific color palettes or symmetry, which are often the "secret sauce" of professional prompts.

2. Differential Evolution (DE)

This is the core of the framework. EvoStealer maintains a population of candidate prompt templates and iteratively refines them through:

  • Mutation: Combining elements from different successful candidates to explore new stylistic combinations.
  • Crossover: Identifying common features across the population to ensure the stolen template is generalizable rather than overfitted to a single sample image.

3. Fitness Evaluation

To determine which candidate templates are most successful, the system evaluates them based on a dual-metric fitness function:

  • Semantic Similarity: How well the text of the candidate matches the target description.
  • Style Similarity: How well a generated image using the candidate template matches the visual style of the original samples.

The PRISM Benchmark

To evaluate this threat, the authors introduced the PRISM benchmark, consisting of 50 high-quality prompt templates sourced from real-world marketplaces. These templates were used to generate 450 images, divided into "Easy" and "Hard" levels based on modifier complexity. The benchmark tests both "in-domain" reproduction (recreating the sample images) and "out-of-domain" generalization (applying the stolen style to entirely new subjects).

Key Insights and Results

EvoStealer was tested against established baselines like CLIP Interrogator and PromptStealer. The results highlight several critical findings:

  • Superior Performance: EvoStealer outperformed the best baseline by over 10% on average across all metrics. In human evaluations, it achieved scores of 4.2 to 4.5 out of 5, indicating that the stolen templates are nearly indistinguishable from the originals.
  • Economic Viability: The attack is highly cost-effective. Stealing a high-end template costs approximately $1.70 in API fees, significantly lower than the $3–$9 retail price on many marketplaces.
  • The Power of Iteration: Unlike one-shot captioning methods, the evolutionary approach allows the model to "learn" from the generative feedback loop, filtering out subject-specific noise to isolate the shared stylistic traits.

Limitations and Defense Strategies

While powerful, EvoStealer's effectiveness is tied to the descriptive capabilities of the underlying MLLM. It currently struggles with highly specific artist names or complex text-in-image rendering.

To defend against such attacks, the authors suggest that prompt marketplaces could limit the number of publicly visible sample images for a single template. Reducing the available samples to 2–4 makes it significantly harder for evolutionary algorithms to identify the common stylistic patterns required to reconstruct the template accurately. Future work will focus on expanding the benchmark to include multi-subject templates and testing across a wider variety of image generators.

Summary updated

BibTeX
@inproceedings{wu2025vulnerability,
  author = {Yurong Wu and Fangwen Mu and Qiuhong Zhang and Jinjing Zhao and Xinrun Xu and Lingrui Mei and Yang Wu and Lin Shi and Junjie Wang and Zhiming Ding and Yiwei Wang},
  title = {{Vulnerability of Text-to-Image Models to Prompt Template Stealing: A Differential Evolution Approach}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure