Manuscript Offprint

arXiv:2610.26452

When Guidance Becomes a Guard: Early Interception of Unsafe Inputs in Text-to-Image Generation

Yanchun Li, Yujin Wu, Gangkai Shen, Ming Yang, Li Zeng, Xianlong Wang, Hangtao Zhang, Shujuan Tian

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Text-to-image diffusion models can produce unsafe content, while output filtering intervenes only after synthesis. We investigate whether native generation signals enable early detection of unsafe and adversarial inputs. We find that classifier-free guidance exposes strong safety signals in conditional responses, accessible through compact statistics and linear readouts. Based on this finding, we propose Conditional Semantic Trajectory Interception (CSTI), which aggregates activation contrasts between conditional and unconditional responses at early checkpoints for calibrated risk detection. CSTI fits concept-specific detectors using canonical concept and safe examples, without attack samples, intermediate image decoding, or generator modification. Across five generators, four adversarial attack collections, and two general NSFW datasets, CSTI achieves the strongest overall performance among six baselines at a matched 5% FPR. Early interception reduces generation latency by over 60% on intercepted paths. These results demonstrate the effectiveness of native conditional responses for early safety interception.

1. Introduction

Text-to-image models can generate compelling visual content from natural language prompts [23], but can also be exploited to produce unsafe images. Crafted prompts may bypass safeguards and induce explicit nudity, violence, or other harmful content [31, 43]. Final image moderation can block such outputs only after the full generation cost is incurred. This motivates early interception before synthesis is complete while allowing benign requests to proceed normally, as illustrated in Figure 1.

Recent work has shown that safety can be assessed during generation. IGD classifies predicted noise [41], Wukong detects from intermediate features while reusing cross-attention parameters [17], and FlowGuard projects intermediate latents into an approximate image space for visual detection [42]. These methods demonstrate the feasibility of in-generation detection, but leave room to examine the safety information already present in the generator's native conditional computation. Effective interception requires high sensitivity to unsafe and adversarial inputs while minimizing false rejections of benign requests, further motivating the study of early diffusion representations. This motivates a question.

How early does a text-to-image generator become safety-readable, and how little machinery is needed to read that signal?

We investigate this question through the native computation of classifier-free guidance (CFG) [12]. CFG evaluates conditional and unconditional branches from the same latent state at each sampling update. We find that differences between their internal activations already contain strong safety information at early sampling stages. Compact channel statistics preserve much of this information, which can be effectively recovered using simple linear readouts. These observations suggest that the computation used to guide image formation also provides accessible safety signals before synthesis is complete.

Based on this finding, we introduce Conditional Semantic Trajectory Interception (CSTI). CSTI summarizes conditional activation contrasts at a few early checkpoints into a compact representation and applies a lightweight linear risk readout. Under our 50-update protocol, CSTI observes updates 5, 10, and 15 and makes a single decision after update 15. Flagged generations terminate early, while accepted generations continue along the original sampling trajectory. CSTI requires no intermediate image decoding, external visual encoder, or modification of the generator.

(a) Risky generation request

Figure

(b) Late safety checking

Diffusion sampling process (e.g., 50 steps)

Step 0

Step 10

Step 30

Step 50

Potentially unsafe image

Safety Checker

(after generation)

Blocked!

Too late: full generation cost already spent.

The unsafe image has been fully generated before it can be detected and blocked.

(c) CSTI: early interception

Read internal CFG activations, not decoded images.

When guidance becomes a guard.

Diffusion sampling process (e.g., 50 steps)

Step 0

Step 5

Step 10

Step 15

Step 50

Figure

Activation readout

35 remaining updates avoided

Intercept

at h = 15

Conditional Semantic Trajectory (from CFG responses)

Risk Head

Accepted requests continue unchanged.

Figure

Unsafe intent can emerge during generation: CSTI intercepts risky trajectories before the final image is formed.

Figure 1. From late checking to early interception. (a) Crafted prompts can induce unsafe generations. (b) Post-generation safety checks incur the full generation cost. (c) In this example, CSTI reads early CFG activations at steps 5, 10, and 15, intercepting risky inputs while allowing accepted requests to continue unchanged. Intermediate images are shown only for illustration.

For each generator and risk concept, the detector is fitted using canonical concept examples and safe examples without attack samples. An independent safe set is used to calibrate the interception threshold, separating concept fitting from threshold selection. Neither process relies on the adversarial prompt collections used for evaluation.

We evaluate CSTI on five generators: SD1.4 and SD1.5 [23], SDXL [22], SD3.5 Medium [6, 28], and Z-Image [30, 47], spanning U-Net and Transformer backbones. CSTI achieves the strongest overall performance among representative baselines on nudity and violence collections at a matched 5% FPR. Layer, checkpoint, and classifier analyses confirm that simple linear readouts can exploit early safety signals. CSTI reduces generation latency by over 60% on intercepted paths across all five generators. Our contributions are threefold:

• We reveal that native conditional responses of text-to-image generators contain strong safety signals at early sampling stages, which can be effectively extracted using compact statistics and simple linear readouts.

• We propose CSTI, a lightweight interception framework that requires no attack examples for detector fitting, no intermediate image decoding, and no modification of the generator or accepted sampling process.

• We systematically evaluate CSTI, demonstrating the effectiveness of early safety signals and the computational efficiency of interception.

References (52)