PromptFlare: Prompt-Generalized Defense via Cross-Attention Decoy in Diffusion-Based Inpainting

Hohyun Na, Seunghoo Hong, Simon S. Woo · DOI

Introduction

The rapid advancement of diffusion-based inpainting models, such as Stable Diffusion, has revolutionized image editing. However, this accessibility has also introduced significant risks, including the unauthorized removal of watermarks, object swapping, and the creation of deceptive content. To counter these threats, researchers have proposed "image immunization"—the process of adding imperceptible adversarial noise to images to prevent AI models from successfully modifying them.

While initial attempts at immunization showed promise, they possess a critical vulnerability: they are often sensitive to the Classifier-Free Guidance (CFG) scale. When an attacker increases the CFG scale, the model prioritizes the text prompt over the underlying image pixels, effectively "overpowering" the defensive noise. This paper introduces PromptFlare, a novel defense mechanism that shifts the focus from pixel-level disruption to the disruption of the cross-attention mechanism, providing a robust, prompt-generalized defense.

The Vulnerability of Current Defenses

Existing adversarial defenses against inpainting typically focus on creating inconsistencies within the image space. These methods aim to make the model's reconstruction process fail by introducing noise that clashes with the expected latent representations. However, because diffusion models are guided heavily by text prompts, an attacker can simply instruct the model to ignore the image's finer details in favor of the prompt's instructions by raising the CFG scale. This "Achilles' heel" means that a determined attacker can bypass most current protections with a simple parameter adjustment.

The PromptFlare Mechanism: Cross-Attention Decoy

PromptFlare addresses the CFG vulnerability by targeting the very mechanism that integrates text prompts with image features: cross-attention. Instead of trying to break the image, PromptFlare "distracts" the model using a semantic decoy.

1. The <BOS> Token Decoy

In the CLIP text encoder used by Stable Diffusion, every prompt begins with a "Beginning-of-Sequence" (<BOS>) token. This token is universal across all prompts but contains no semantic information regarding the image content. PromptFlare generates adversarial noise specifically designed to cause the model’s attention maps to collapse onto this <BOS> token. By forcing the model to "look" at a meaningless token, the defense ensures the model loses the spatial and semantic guidance necessary to perform the requested edit.

2. Prompt-Generalized Protection

Because the <BOS> token is a constant in every prompt, the defense is inherently generalized. Unlike previous methods that might be optimized against specific keywords, PromptFlare remains effective regardless of the specific malicious prompt an attacker uses. The authors also investigated the "End-of-Sequence" (<EOS>) token but found it less effective as a decoy because it often aggregates semantic information from the preceding text, whereas the <BOS> token remains purely neutral.

3. Quality Tag Priors and Efficient Optimization

To enhance the effectiveness of the adversarial noise, PromptFlare utilizes "quality tags" (e.g., "masterpiece," "best quality") during the noise generation phase. These tags act as a generative prior, helping the defense identify the most vulnerable pathways in the diffusion process. Furthermore, PromptFlare employs a concise loss function that minimizes the difference between the masked (decoy-focused) attention and standard attention, eliminating the need for complex iterative mask shrinking or multiple model passes.

Experimental Evaluation

The authors evaluated PromptFlare using EditBench, a diverse dataset of 240 image pairs (120 real, 120 AI-generated) featuring a wide range of prompts and scene modifications. This provides a more rigorous testing ground than the smaller datasets used in earlier studies.

Key Results

  • Superior Suppression: PromptFlare significantly outperformed baselines like PhotoGuard and AdvPaint. It achieved a reduction in CLIP Score of over 0.88 points compared to the previous state-of-the-art (SOTA), indicating that the resulting images bore little to no resemblance to the attacker's prompt.
  • Robustness to Guidance: While baseline defenses collapsed as the CFG scale increased from 7.5 to 15.0, PromptFlare’s protection remained stable. The decoy effect actually becomes more pronounced as the model attempts to follow the prompt more strictly.
  • Efficiency: PromptFlare is approximately 3x faster than previous SOTA methods and requires significantly less GPU memory, making it a viable solution for real-world deployment on consumer hardware.
  • Generalization: The defense proved effective even when attackers switched to different models (e.g., Stable Diffusion 2.0) or modified the inpainting masks, demonstrating strong transferability.

Conclusion and Future Work

PromptFlare represents a paradigm shift in image immunization by moving the defensive battleground to the cross-attention mechanism. By leveraging the universal <BOS> token as a decoy, it provides a robust defense that is invariant to prompt changes and CFG scaling. While the method results in lower PSNR scores, the authors argue that pixel-wise similarity is a misleading metric for defense success; the goal is to prevent the edit, not to maintain similarity to the attacker's desired outcome. Future research will explore applying this cross-attention decoy strategy to other generative tasks, such as video editing and image-to-image translation.

Summary updated

BibTeX
@inproceedings{na2025promptflare,
  author = {Hohyun Na and Seunghoo Hong and Simon S. Woo},
  title = {{PromptFlare: Prompt-Generalized Defense via Cross-Attention Decoy in Diffusion-Based Inpainting}},
  booktitle = {ACM Multimedia},
  year = {2025},
  doi = {10.1145/3746027.3755763},
}
Figure