Escape the Context Manifold: Preventing DiT In-Context Editing via Conditional Flow Hijacking

Yuhao He, Jinyu TianNeurIPS 2026

TL;DR

Modern AI image editors can take a single public photo of you and drop your likeness into almost any scenario—no model fine-tuning required. Rather than trying to make the AI "ignore" your photo (which often fails during complex scene changes), this paper introduces Conditional Flow Hijacking: adding imperceptible noise to your image that actively steers the AI toward generating a completely different person while still fulfilling the text prompt. It’s the difference between putting up a "Do Not Enter" sign and secretly rotating the highway exit signs to point somewhere else entirely.

What Problem Does This Paper Address?

Diffusion Transformers (DiTs)—the architecture powering state-of-the-art generators like FLUX—have unlocked in-context image editing. Give the model one reference photo and a text prompt ("Make this person run!"), and it seamlessly blends your identity with the new instructions. Naturally, this creates a massive privacy headache for anyone with photos online.

Most older "image-cloaking" defenses were built for U-Net architectures and break down on Transformers. The only prior defense tailored for DiTs, DeContext, tries to mute the cross-attention weights between the generated image and the reference image. However, the authors found a blind spot: in complex scene edits (like putting someone in a snowy forest or an operating room), the text prompt already dominates the generation, and reference attention is naturally weak. Trying to suppress that tiny bit of remaining attention barely registers—your face still leaks through.

The challenge: How do we cloak a reference image with invisible perturbations so that DiT editors completely fail to capture the subject's identity, even in complex scenes?

Methods

The authors view image generation through the lens of flow matching on manifolds. Imagine starting at pure random noise and riding a velocity vector field down to a finished image. Normal editing steers this trajectory toward the intersection of two regions: the Prompt Submanifold (images matching the text) and the Context Submanifold (images looking like the reference person).

Figure 1: Conditional flow hijacking in DiT-based in-context image editing.

Inside a DiT's self-attention layers, tokens are grouped into Text, Target (the image being generated), and Context (the reference image). Mathematically, the update to the target tokens breaks down into three additive "steering" vectors: text steering, target self-consistency, and context steering ($A_{\text{target}\rightarrow\text{context}} V_{\text{context}}$).

Instead of zeroing out attention ($A$), Conditional Flow Hijacking uses standard Projected Gradient Descent (PGD) to optimize an imperceptible pixel perturbation on the reference image using a novel three-part loss across early denoising steps:

  1. Attention Preservation ($\mathcal{L}_{\text{attn}}$): Counterintuitively keeps the target-to-context attention pathway open and active so the model listens to the poisoned signal.
  2. Escape Loss ($\mathcal{L}_{\text{escape}}$): Pushes the context-steering vector directly away from the clean reference image's steering direction.
  3. Hijack Loss ($\mathcal{L}_{\text{hijack}}$): Pulls the context-steering vector toward an unrelated "hijack anchor" (like random noise or a generic logo).
Figure 3: Optimization pipeline of Conditional Flow Hijacking.

Datasets

  • Evaluation Images: 50 diverse facial identities sampled each from CelebA-HQ and VGGFace2 (center-cropped and resized to $512 \times 512$).
  • Evaluation Prompts: Because the defender doesn't know what an attacker will type, the authors generated two test sets using ChatGPT (strictly disjoint from the prompts used during PGD optimization): 54 Attribute editing prompts (changing expressions, clothing, poses) and 30 Complex scene editing prompts (changing environments, lighting, and styles).

Key Insights and Ideas

  • Don't block the pipe; poison the water: Suppressing attention weights fails when attention magnitudes are already small. Keeping the attention channel wide open while redirecting the value vectors being transmitted actively drives the denoising trajectory out of the reference identity's gravity well.
  • Prompt and identity live on orthogonal axes: Using PCA on final latent representations, the authors empirically proved that changing the prompt moves latents along an axis largely decoupled from changing the reference identity. Because they don't fight each other, you can hijack identity without ruining prompt alignment or image realism.
  • Context steering is strictly causal: In a clever "brain-transplant" experiment, the authors swapped intermediate context-steering vectors between clean and protected runs. Injecting adversarial steering into a clean run erased the person's identity; injecting clean steering into a protected run restored it—proving these specific vectors carry the identity payload.

Key Results

Evaluated primarily on FLUX.1-Kontext, the method measures identity leakage via Identity Score Matching (ISM, ArcFace similarity—lower means better protection).

  • Crushing Identity Leakage: On CelebA-HQ ("a photo of this person"), clean editing yields an ISM of 0.89. U-Net defenses (AdvDM, FaceLock, EditShield) barely scratch it (0.85–0.92), and DeContext drops it to 0.39. Conditional Flow Hijacking plunges ISM down to 0.11, while keeping perceptual quality (CLIP-IQA: 0.72) and text alignment (CLIP-Score: 26.58) high.
  • Dominating Complex Scenes: On complex scene edits in CelebA-HQ, DeContext struggles at 0.59 ISM, whereas the proposed method achieves 0.16—generating realistic, prompt-accurate photos of total strangers.
  • Resilience & Transferability: Perturbations survive JPEG compression (ISM 0.19) and diffusion-based purification like DiffPure (0.42 vs. 0.89 clean). Furthermore, protections optimized solely on FLUX.1-Kontext transfer zero-shot to unseen DiT editors, dropping ISM from 0.83 to 0.53 on Step1X-Edit and 0.92 to 0.52 on ICEdit.

Limitations and Future Work

While the main text does not feature a dedicated limitations section, two practical trade-offs emerge from the experiments:

  • Protection vs. Image Fidelity: Stronger perturbation budgets ($\epsilon$) yield better identity protection but introduce visible noise to the user's photo (pushing $\epsilon$ from $0.06$ to $0.14$ drops PSNR from $33.37\text{ dB}$ to $27.59\text{ dB}$).
  • Zero-Shot Transfer Degradation: While perturbations transfer to unseen DiT architectures without re-optimization, the authors note that this comes with "some degradation in image quality" and weaker protection compared to white-box targeting.

Summary updated

Abstract

Diffusion Transformers enable powerful in-context image editing from a reference image and a text prompt, but also make it easier to maliciously edit public images while preserving the private identity of the reference. Existing DiT-oriented protection methods, such as DeContext, mainly suppress target-to-context attention to weaken reference utilization. However, this strategy can be insufficient for complex edits where prompt semantics already dominate generation. Instead, we study proactive protection for DiT-based editors from a conditional-flow perspective, and use a local geometric interpretation of in-context editing, where the denoising trajectory is empirically characterized as being steered by prompt-consistent and reference-consistent directions. Thus, effective protection should not simply corrupt the output, but should drive it away from the original context manifold. To this end, we propose Conditional Flow Hijacking, which adds perturbations to the reference image. Instead of suppressing context attention, our method preserves the context pathway, but redirects the context-induced steering signals in the intermediate transformer layers, causing the final trajectory to drift away from the reference consistent solution region. Experiments on FLUX.1-Kontext with different datasets and prompts including attribute and complex scene editing show that our method significantly suppresses reference identity leakage while maintaining image quality and prompt alignment, outperforming prior protection baselines, especially under complex scene editing prompts. We further verify the robustness of the proposed protection method as well as its transferability across other models, highlighting the need for proactive defenses for in-context generative models. Code is available at https://github.com/Anson-He/Escape-the-Context-Manifold.
BibTeX
@inproceedings{he2026escape,
  author = {Yuhao He and Jinyu Tian},
  title = {{Escape the Context Manifold: Preventing DiT In-Context Editing via Conditional Flow Hijacking}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=06nMkjyRaB},
}
Figure