AdvPaint: Protecting Images from Inpainting Manipulation via Adversarial Attention Disruption

Joonsung Jeon, Woo Jae Kim, Suhyeon Ha, Sooel Son, Sung-eui Yoon

TL;DR

AdvPaint is a novel defensive framework designed to protect images from unauthorized AI-powered inpainting (such as malicious deepfakes or copyright infringement). By injecting imperceptible adversarial perturbations that directly disrupt the diffusion model's self- and cross-attention mechanisms, AdvPaint ensures that unmasked regions of an image successfully sabotage the generation process inside the masked area.

What Problem Does This Paper Address?

While diffusion models excel at generating and modifying images, they also present severe risks for misuse. Malicious actors can use inpainting—replacing a specific region of an image based on a text prompt—to create deceptive deepfakes or alter copyrighted artwork.

Existing image protection frameworks (like PhotoGuard or Mist) inject subtle adversarial noise into images to break the generation process. However, these methods were designed for whole-image manipulations (like text-to-image or image-to-image tasks). When applied to inpainting, they fail catastrophically. Why? Because the adversary defines a mask over the region they want to change, which completely wipes away the protective perturbations in that area. The inpainting model can then seamlessly generate new content within the mask, completely ignoring the defense left in the unmasked background.

AdvPaint addresses this critical gap by ensuring that perturbations in the unmasked regions can actively disrupt the generation process inside the masked region.

Methods

AdvPaint shifts the defensive strategy from manipulating latent space representations to directly attacking the core components of the image generation process: the attention mechanisms.

Attention mechanism in the U-Net denoiser

As shown in Figure 2, the framework targets two specific blocks within the diffusion model's U-Net denoiser:

  1. Cross-Attention Disruption ($L_{cross}$): This objective perturbs the query ($q$) vectors to break the alignment between the latent image features and the external text prompt tokens. This prevents the model from correctly injecting the prompt's semantics into the masked region.
  2. Self-Attention Disruption ($L_{self}$): This objective perturbs all three key elements—query ($q$), key ($k$), and value ($v$)—to destroy the model's ability to learn spatial and semantic relationships within the input image.

Additionally, AdvPaint introduces a two-stage perturbation strategy. Using an object detection tool (Grounded SAM), it identifies the target object and creates an enlarged bounding box around it. It then optimizes distinct perturbations inside and outside this box, making the defense highly robust against variations in mask shapes and sizes chosen by an adversary.

Datasets

The authors evaluated their approach using:

  • Images: 100 high-resolution images collected from public, real-world sources (Pexels and Unsplash), cropped and resized to $512 \times 512$.
  • Masks: Diverse foreground and background masks (segmentation masks $m^{seg}$ and bounding box masks $m^{bb}$) generated automatically via Grounded SAM.
  • Prompts: 50 random text prompts generated using ChatGPT to simulate various adversarial editing intents (e.g., replacing objects or changing backgrounds).

Key Insights and Ideas

  • The Power of Attention Maps: The fundamental "aha moment" of this paper is realizing that attention maps dictate how information flows across an image during generation. By corrupting these maps, perturbations in the background can "distract" the model, redirecting its attention away from the masked area or forcing it to generate incoherent artifacts.
  • Visualizing the Distraction:
Figure 3: Visualization of cross- and self- attention maps for (a) foreground and (b) background inpainting manipulations. Our proposed method redirects the model’s attention to other regions of the image, as shown in (a), while focusing attention on the newly generated object in (b).

As visualized in Figure 3, when an unprotected image is edited to add a pineapple, the cross-attention map focuses cleanly on the target area. With AdvPaint, the attention is completely scattered across the unmasked background, resulting in a failed generation.

Key Results

AdvPaint significantly outperforms state-of-the-art image protection methods across multiple metrics, including Fréchet Inception Distance (FID), Precision, and LPIPS.

Quantitative comparison table

As detailed in Table 1 (Figure 4):

  • Massive FID Increases: In foreground inpainting tasks using a segmentation mask, AdvPaint achieves an FID of 347.88, compared to Mist (235.81) and PhotoGuard (230.49). Higher FID indicates a more severely degraded and unrealistic adversarial output.
  • Drop in Precision: AdvPaint drops the adversary's generation precision down to 0.0570, effectively ensuring that the generated objects do not harmonize with the real image distribution.
  • Qualitative Superiority:
Figure 1: Our proposed method effectively degrades the result images against various inpainting manipulations with huge spatial differences (e.g. removing objects or inserting new objects). The state-of-the-art adversarial examples show limitations in protecting input images, as the generated outputs still harmonize with the prompts. We apply (a) a segmentation mask mseg , (b) its inverse, (c) a bounding box mask mbb, (d) and its inverse, respectively.

As seen in Figure 1, while baseline defenses still allow the model to generate realistic squirrels, gorillas, or oranges, AdvPaint completely breaks the generation, leaving behind empty spaces or chaotic textures. It also proved robust against common image purification defenses like IMPRESS, JPEG compression, and upscaling.

Limitations and Future Work

  • The Diffusion Transformer (DiT) Challenge: AdvPaint is highly effective against standard Latent Diffusion Models (LDMs) but shows reduced efficacy against newer Diffusion Transformers (like Flux or Stable Diffusion 3). This is because DiTs process images as patchified tokens rather than continuous latent spaces. The authors note that future work must explore patch-level attention optimization to counter DiT-based models.
  • Multi-Object Scaling: When protecting images containing multiple distinct objects, the computational overhead increases because perturbations must be optimized per-object. Streamlining this process remains an open area for research.

Summary updated

BibTeX
@inproceedings{jeon2025advpaint,
  author = {Joonsung Jeon and Woo Jae Kim and Suhyeon Ha and Sooel Son and Sung-eui Yoon},
  title = {{AdvPaint: Protecting Images from Inpainting Manipulation via Adversarial Attention Disruption}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=m73tETvFkX},
}
Figure