WorksComputer Science
When Guidance Becomes a Guard: Early Interception of Unsafe Inputs in Text-to-Image Generation
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.
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.

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.
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.
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.
Related Work
Safety defenses and adversarial prompts. Safety mechanisms for text-to-image generation operate at different stages. Before sampling, text classifiers such as the NSFW Text Classifier [21] and Detoxify [11] can screen potentially unsafe requests. Latent Guard [18] detects harmful concepts in learned representations of text encoder embeddings, while GuardT2I [44] uses a language model to convert text guidance embeddings into natural language for adversarial prompt detection. Such screening can reject risky requests before synthesis, but does not observe how the generative state develops during sampling. Other defenses change how images are generated. ESD [7] removes target concepts by updating model weights, whereas SLD [24] and CRG [5] suppress unsafe concepts through inference-time guidance. Adversarial methods such as Ring-A-Bell [31] and MMA-Diffusion [43] demonstrate that crafted prompts can still elicit unsafe outputs despite existing safeguards. Together, these approaches motivate examining whether risk can be assessed during generation without changing accepted sampling. Table 1 compares representative defenses according to their observation and intervention mechanisms.
Table 1. Comparison of representative T2I safety defenses. In-generation interception denotes terminating an ongoing sampling process, while safe calibration refers to threshold selection using independent benign examples. ●/○ denote support/no support, and – denotes not applicable.
| Analysis | Defense | Generation signal | In-generation interception | No image reconstruction | Frozen generator | Safe calibration |
| Prompt | Text-classifier [21] | ○ | ○ | – | ● | ○ |
| Prompt | Detoxify [11] | ○ | ○ | – | ● | ○ |
| Prompt | Latent Guard [18] | ○ | ○ | – | ● | ○ |
| Generation control | ESD [7] | ○ | ○ | ● | ○ | ○ |
| Generation control | SLD [24] | ● | ○ | ● | ● | ○ |
| Generation control | CRG [5] | ● | ○ | ● | ● | ○ |
| Intermediate state | IGD [41] | ● | ● | ● | ● | ○ |
| Intermediate state | Wukong [17] | ● | ● | ● | ● | ○ |
| Intermediate state | FlowGuard [42] | ● | ● | ○ | ● | ○ |
| Conditional response | CSTI (Ours) | ● | ● | ● | ● | ● |
Table 1.
Safety detection during generation. Recent methods inspect intermediate model states to identify unsafe content before the final image is available. IGD [41] classifies intermediate predicted noise with a lightweight detector. Wukong [17] reads early U-Net features through a safety decoder that reuses pretrained cross-attention parameters. FlowGuard [42] uses linear latent decoding to map intermediate states into an approximate image space before applying a visual safety classifier. These approaches establish the feasibility of generation-time safety detection through different internal representations. Their observation signals and readout mechanisms vary, motivating a closer examination of whether native guidance responses contain directly readable safety information. DAG [14] identifies harmful concepts from noisy latents using cross-attention maps associated with optimized guideline tokens, and then applies adaptive safety guidance. InGuard [39] combines prompt embedding screening with a detector on an estimated clean latent during denoising.
CSTI examines a different source of safety information. It reads paired conditional and unconditional internal responses already computed by native classifier-free guidance. Compact channel statistics from a few early updates are used with a linear concept readout, without intermediate image reconstruction or an auxiliary attention-based safety decoder. Unlike methods that steer generation, CSTI terminates flagged requests and leaves accepted sampling trajectories unchanged.
Generative representations and safety calibration. Research on diffusion features shows that internal generative representations can support discriminative tasks beyond image synthesis. DIFT [29] extracts intermediate diffusion features for visual correspondence, while Diffusion Hyperfeatures [19] combines representations across layers and timesteps for semantic matching. These studies motivate the use of native model features, although our focus is on early safety decisions rather than visual correspondence. A risk score also requires a calibrated threshold before it can support an interception decision. Discriminative performance alone does not specify how often benign requests will be rejected at a chosen operating point. Conformal methods provide a principled framework for calibrating decisions using held-out data [1]. CSTI fits its concept head on canonical risk and safe examples, then determines the operating threshold from an independent safe calibration set. This separation avoids selecting thresholds on the adversarial collections used for evaluation.
Method
We introduce Conditional Semantic Trajectory Interception (CSTI) to detect unsafe inputs from native internal responses before image synthesis is complete. CSTI summarizes conditional responses at a few early sampling updates, uses a lightweight concept readout, and calibrates its interception decision on independent safe examples. The generator remains frozen throughout fitting and deployment. Figure 2 illustrates the framework.

Figure 2. Overview of CSTI. (a) Native CFG provides paired conditional and unconditional activations at the same generation state. Their difference forms a conditional contrast. (b) Compact channel statistics at early checkpoints form a multi-checkpoint representation, illustrated here using updates 5, 10, and 15. (c) A lightweight concept head is fitted from canonical risk and safe examples, while an independent safe set calibrates the interception threshold. In this example, CSTI decides once at update 15.
Consider a text-to-image generator , a prompt , a random seed , and a defender-specified risk concept . Let be the initial generation state and the state after sampling update , with updates in total. At update , the generator evaluates its model using the preceding state . CSTI makes one interception decision after an early update . We use and throughout the main evaluation.
Early Safety Signals in Native Conditional Responses
Classifier-free guidance (CFG) evaluates conditional and unconditional responses from the same generation state at each sampling update. CSTI reads activations from a fixed intermediate block in these two native branches rather than reconstructing intermediate images. Let and denote the activations conditioned on and on the generator’s native unconditional input, respectively. Both are computed from at the same scheduler timestep.
We define their conditional contrast as
This contrast describes the change in internal response associated with the prompt condition. Since both branches are already evaluated by CFG, extracting requires no additional risk-specific generation branch.
For U-Net generators, consists of spatial features, whereas Transformer generators provide image-token features. Let denote the channel dimension and the set of spatial positions or image tokens. We summarize each channel by its mean and root mean square (RMS),
The mean captures the signed average response, while RMS captures its magnitude; ensures numerical stability. We form a compact representation at each checkpoint,
We collect these features at early checkpoints and concatenate them in sampling order,
In our experiments, we use . We call this ordered representation a conditional semantic trajectory. It retains information from several early conditional responses. The observation block and channel dimension vary across generators, but the same statistical representation applies to both U-Net and Transformer backbones.
Concept Adaptation without Attack Examples
CSTI fits a risk readout for each generator and defender-specified concept using canonical concept examples and safe examples. The positive examples represent the target concept and are not selected according to the success of an adversarial attack. No attack prompts, attack-generated images, or attack-success labels are used for detector fitting.
Given the early representation , we standardize its features and apply a whitened PCA projection with 128 components,
A linear head then produces a concept-specific risk score,
We use class-balanced logistic regression and take its linear decision value as the risk score, with larger values indicating greater risk. The standardizer, PCA projection, and classifier are fitted sequentially using only the designated fitting split. This simple readout allows us to examine how directly the early representation exposes safety information, without introducing a complex detection network.
Each generator and risk concept uses its own fitted preprocessing and readout parameters. CSTI uses the same feature construction and fitting procedure across architectures, while detector weights are learned separately for each generator and risk concept instead of being shared.
Safe-Calibrated Early Interception
A risk score must be converted into an interception decision. We determine its operating threshold using an independent set of safe examples that is not used for concept fitting. After fitting the readout, let denote the risk scores of these calibration examples. For a test risk score , we compute its upper-tail rank relative to the safe calibration scores,
A small value indicates that the test score is unusually high relative to the safe reference distribution. Given an operating level , the interception decision is
The fitted readout and calibration rule remain fixed across attack collections for each generator and concept. The quantity is a ranking score, not the probability that the input is benign. When calibration and test safe examples are exchangeable, this rank rule bounds the marginal false-positive rate at the chosen level [1]. Calibration relies only on benign examples to control false positives. CSTI aims to intercept risky inputs regardless of attack success, as even unsuccessful attacks may degrade output quality.
During sampling, CSTI records summaries at updates 5, 10, and 15 and makes a single decision after update . Flagged generations stop before final image decoding, while accepted generations proceed from the current state with their guidance and scheduler unchanged. No intermediate image decoding or external visual encoder is required. Under our 50-update protocol, an intercepted generation avoids the remaining 35 sampling updates. The corresponding runtime reduction is measured separately in § 4.
Experiments
We evaluate early interception, the readability of internal safety signals, and the cost of using those signals during generation. The main evaluation covers five generators and eight risk-prompt settings, including six for nudity and two for violence, yielding 40 evaluation settings. We further evaluate over-refusal on OVERT-mini using two generators and challenging benign prompts.
Experimental Setup
Datasets. We evaluate six nudity prompt collections: Ring-A-Bell (RAB) [31], MMA-Diffusion [43], Custom, P4D [4], I2P [24], and UnLearn source [55]. For violence, we use RAB and I2P. For each collection, we include an equal number of benign prompts to evaluate false positives on legitimate requests. For over-refusal, we use OVERT-mini [3].
Models. We evaluate five unmodified text-to-image generators: SD1.4, SD1.5, SDXL, SD3.5 Medium, and full Z-Image. All use 50 sampling updates. SD1.4/1.5 and SDXL use DDIM [25] with CFG 7.5 at and resolution, respectively. SD3.5 Medium and Z-Image use FlowMatch Euler [16] at , with CFG 7.5 and 5, respectively. Experiments run on an NVIDIA RTX 4090.
Implementation. CSTI observes updates and makes a single decision at update 15. We extract features from the U-Net middle block, SD3.5 Transformer block 11, or Z-Image layer 14, respectively. Each generator–concept pair uses a separate detector fitted on 144 canonical concept examples and 256 benign examples, without attack samples. Features undergo standardization and 128-component whitened PCA, followed by balanced logistic regression. Independent benign sets are used for safety calibration (200 prompts, ) and evaluation (300 prompts).
Metrics. We use TPR at a matched empirical 5% FPR as the primary metric, with AUROC as a complementary measure. TPR measures the proportion of unsafe inputs correctly detected. These automated assessments were further supplemented by manual review. The 5% FPR threshold is determined from the 300 benign evaluation prompts (at most 15 false positives), separately from the safety calibration rule. We average collections within each concept, then concepts and generators equally.
Baselines. We compare against three prompt-level detectors: NSFW Text Classifier [21], Latent Guard [18], and GuardT2I [44]; and three generation-time detectors: IGD [41], Wukong [17], and DAG [14] (detection component only). We follow released implementations where applicable, with architecture-specific adaptations identified in the comparison.
Early Interception Effectiveness
Table 2 compares CSTI with six representative baselines at a matched 5% FPR. CSTI achieves the highest TPR in 37 of 40 evaluation settings, with macro TPRs ranging
| Generator | Method | RAB | MMA | Custom | P4D | I2P | UnLearn | RAB | I2P | Macro ↑ |
| SD1.4 | Text Classifier | 26.28 | 45.67 | 23.50 | 12.21 | 10.87 | 13.90 | 35.13 | 20.54 | 24.95 |
| Latent Guard | 52.35 | 56.42 | 55.18 | 55.83 | 20.15 | 20.74 | 54.86 | 19.32 | 40.27 | |
| GuardT2I | 84.62 | 56.18 | 66.24 | 48.35 | 50.27 | 47.62 | 24.86 | 17.32 | 39.99 | |
| IGD | 96.96 | 93.79 | 85.27 | 96.49 | 96.83 | 96.97 | 97.18 | 77.28 | 90.80 | |
| Wukong | 80.00 | 84.70 | 80.89 | 89.52 | 86.71 | 76.75 | 93.77 | 76.78 | 84.18 | |
| DAG† | 84.31 | 78.80 | 55.11 | 63.30 | 87.09 | 36.72 | 38.90 | 23.27 | 49.31 | |
| CSTI (Ours) | 100.00 | 95.64 | 100.00 | 95.69 | 98.51 | 99.30 | 100.00 | 83.07 | 94.86 | |
| SD1.5 | Text Classifier | 26.28 | 45.67 | 23.50 | 12.21 | 10.87 | 13.90 | 35.13 | 20.54 | 24.95 |
| Latent Guard | 51.82 | 56.30 | 55.42 | 55.61 | 20.43 | 20.36 | 54.72 | 19.87 | 40.31 | |
| GuardT2I | 83.74 | 55.42 | 65.83 | 46.91 | 50.08 | 48.15 | 25.13 | 17.65 | 39.87 | |
| IGD | 91.63 | 87.85 | 86.41 | 93.59 | 95.45 | 97.22 | 91.27 | 72.87 | 87.05 | |
| Wukong | 87.00 | 77.92 | 89.75 | 95.22 | 90.08 | 89.32 | 86.78 | 84.32 | 86.88 | |
| DAG† | 88.94 | 82.67 | 77.28 | 65.57 | 91.43 | 42.13 | 36.93 | 29.89 | 54.04 | |
| CSTI (Ours) | 100.00 | 90.26 | 100.00 | 95.69 | 99.25 | 97.89 | 100.00 | 84.66 | 94.76 | |
| SDXL | Text Classifier | 26.28 | 45.67 | 23.50 | 12.21 | 10.87 | 13.90 | 35.13 | 20.54 | 24.95 |
| Latent Guard | 53.14 | 64.87 | 55.06 | 56.04 | 22.86 | 24.15 | 54.94 | 21.03 | 42.00 | |
| GuardT2I | 84.35 | 60.87 | 66.52 | 47.20 | 48.36 | 51.34 | 25.87 | 17.43 | 40.71 | |
| IGD | 93.51 | 72.57 | 77.94 | 84.26 | 89.36 | 86.46 | 91.06 | 76.82 | 83.81 | |
| Wukong | 80.41 | 81.94 | 64.80 | 93.36 | 92.99 | 90.88 | 77.10 | 74.92 | 80.03 | |
| DAG† | 43.32 | 32.90 | 57.55 | 71.43 | 65.88 | 58.93 | 29.21 | 31.65 | 42.71 | |
| CSTI (Ours) | 100.00 | 92.18 | 100.00 | 95.69 | 100.00 | 97.89 | 99.47 | 84.27 | 94.75 | |
| SD3.5 Medium | Text Classifier | 26.28 | 45.67 | 23.50 | 12.21 | 10.87 | 13.90 | 35.13 | 20.54 | 24.95 |
| Latent Guard | 60.28 | 66.31 | 54.91 | 55.74 | 24.72 | 24.98 | 54.88 | 20.76 | 42.82 | |
| GuardT2I | 85.16 | 62.43 | 67.91 | 51.28 | 54.72 | 52.86 | 25.42 | 16.84 | 41.76 | |
| IGD | 89.53 | 59.32 | 36.49 | 70.37 | 84.13 | 86.21 | 89.86 | 71.83 | 75.92 | |
| Wukong | 85.80 | 70.53 | 62.60 | 79.20 | 82.70 | 78.41 | 81.52 | 75.67 | 77.56 | |
| DAG† | 85.58 | 72.28 | 44.68 | 52.63 | 79.17 | 84.21 | 68.63 | 31.90 | 60.01 | |
| CSTI (Ours) | 98.60 | 78.35 | 98.06 | 90.91 | 95.07 | 100.00 | 96.93 | 85.65 | 92.39 | |
| Z-Image | Text Classifier | 26.28 | 45.67 | 23.50 | 12.21 | 10.87 | 13.90 | 35.13 | 20.54 | 24.95 |
| Latent Guard | 54.73 | 60.45 | 55.21 | 55.42 | 21.87 | 21.65 | 54.79 | 20.18 | 41.19 | |
| GuardT2I | 84.27 | 55.84 | 69.35 | 47.61 | 50.15 | 48.92 | 24.78 | 17.86 | 40.34 | |
| IGD | 77.26 | 36.85 | 71.43 | 81.90 | 92.25 | 90.48 | 86.13 | 82.87 | 79.76 | |
| Wukong | 91.92 | 96.30 | 48.29 | 85.97 | 79.22 | 88.11 | 70.50 | 70.98 | 76.19 | |
| DAG† | 94.72 | 65.07 | 77.10 | 75.86 | 94.87 | 96.88 | 24.56 | 28.92 | 55.41 | |
| CSTI (Ours) | 98.95 | 92.90 | 100.00 | 92.82 | 96.27 | 95.07 | 99.33 | 91.67 | 95.75 |
Table 2. Main comparison of unsafe-input detection at a matched 5% FPR. We report TPR (%, ↑) on unsafe inputs across five text-to-image generators, six nudity collections, and two violence collections. Macro averages collections within each concept and then weights the two concepts equally. Bold and underlined values indicate the best and second-best results, respectively.
from 92.39% on SD3.5 Medium to 95.75% on Z-Image. It outperforms the strongest competing baseline on each generator by 4.06 to 15.99 percentage points. These improvements hold across both U-Net and Transformer architectures, demonstrating that early conditional responses provide effective safety signals across different generation backbones. Performance remains dependent on the prompt collection, with relatively lower TPRs on MMA for SD3.5 Medium (78.35%) and I2P violence for SDXL (84.27%).
Characterizing Early Safety Readability
We investigate where safety information is accessible, how early it can be detected, and how complex a readout is required. Figure 3 summarizes these analyses across five generators and two risk concepts.

Figure 3. Early safety readability across layers, sampling stages, and classifiers. (a) Layer-wise TPR at a matched 5% FPR across five generators and two risk concepts. (b) TPR of individual checkpoints and their joint representation at a matched 5% FPR. (c) Mean empirical FPR under the standard safe calibration protocol, with each variant fitted and calibrated independently rather than matched to 5% FPR. (d) TPR comparison of classifier families using the same early representation at a matched 5% FPR. Results are aggregated across generators and prompt collections as appropriate.
Layer selection. Figure 3(a) shows that safety information is accessible across multiple network layers, with in termediate layers generally providing stronger readability. On SDXL, nudity TPR increases from 73.57% at the earliest examined layer to 97.62% at the middle block. Similarly, violence TPR on Z-Image rises from 42.41% at layer 0 to 95.50% at layer 14. Although the strongest observation site varies across generators and concepts, these results show that internal representations contain substantial safety information.
Sampling stages. Figure 3(b) shows that safety information is already strongly readable at update 5, achieving 88.4% TPR for nudity and 85.2% for violence at a matched 5% FPR. Combining updates 5, 10, and 15 increases the overall macro TPR from 92.2% at update 15 alone to 94.5%.
Figure 3(c) reports mean empirical FPR under the standard calibration protocol. Each variant uses its own fitted classifier and calibrated threshold, without independently adjusting its empirical FPR to 5%. The joint representation achieves a mean empirical FPR of 4.2%, compared with 15.9%, 13.5%, and 10.4% for updates 5, 10, and 15, respectively. These results demonstrate that strong safety information is available at very early stages, while combining checkpoints provides complementary information and reduces false positives under the evaluated operating setting.
Readout complexity. Figure 3(d) compares linear and nonlinear classifiers on the same representation. Logistic regression achieves 96.5% and 92.5% TPR for nudity and violence, respectively, outperforming SVM, MLP, and random forest in the overall averages. This confirms that compact conditional features support effective safety detection with a simple linear readout.
Feature statistics. Table 3 evaluates the channel statistics used to construct the early representation. Combining mean and RMS achieves 94.50% macro TPR and 0.9802 AUROC, compared with 85.93% and 82.56% TPR using mean or RMS alone. These results further support the effectiveness of simple statistical summaries for extracting safety information from native conditional responses.
Table 3. Feature-statistics ablation. Hierarchical macro over five generators, two risk concepts, and their prompt collections. Each variant independently fits the same standardization, PCA, and logistic regression pipeline.
| Statistics | TPR@5 ↑ | AUROC ↑ |
| Mean only | 85.93 | 0.9170 |
| RMS only | 82.56 | 0.8846 |
| Mean + RMS (default) | 94.50 | 0.9802 |
Table 3. Feature-statistics ablation.
Over-Refusal Evaluation
The matched FPR evaluation on standard benign prompts does not fully characterize false interceptions when safe requests resemble protected concepts. Legitimate requests should proceed without unnecessary rejection. To examine this boundary, we evaluate CSTI on OVERT-mini [3], a challenging benchmark of benign prompts that closely resemble unsafe concepts. We select SD1.4 and SD3.5 to cover both U-Net and Transformer architectures. All trainable methods are adapted using the same 200 OVERT samples and evaluated on 1,600 samples, while other baselines retain their best released configurations.
Table 4 reports the resulting FPR. CSTI achieves the lowest FPR of 5.27% on SD1.4, outperforming all six baselines. On SD3.5, CSTI reaches 8.25% FPR, ranking second and trailing DAG by only 0.14 percentage points. It also substantially outperforms the remaining five baselines, whose FPRs range from 14.20% to 38.43%. These results suggest that CSTI can avoid false rejections of challenging benign inputs with limited additional adaptation. This capability is particularly important for early interception, where incorrect decisions terminate otherwise legitimate generation processes. Nevertheless, false positives on semantically similar benign prompts remain a limitation, particularly on SD3.5, indicating the need for further improvements in distinguishing benign and unsafe inputs.
Table 4. False-positive comparison on OVERT. We report FPR (%, ↓) on 1,600 near-concept samples. Trainable methods use the same 200 OVERT samples for adaptation; others use their best released configurations. The text-only classifier is evaluated once on shared prompts, with identical FPR across generators.
| Method | SD1.4 | SD3.5 Medium |
| Text Classifier | 38.43 | 38.43 |
| Latent Guard | 16.38 | 14.20 |
| GuardT2I | 32.50 | 26.13 |
| IGD | 15.78 | 16.24 |
| Wukong | 20.38 | 18.21 |
| DAG† | 7.78 | 8.11 |
| CSTI (Ours) | 5.27 | <u>8.25</u> |
Table 4. False-positive comparison on OVERT.
Computational Efficiency
We evaluate the computational efficiency of CSTI across five generators under the 50-update sampling protocol. Table 5 shows that early termination at update 15 reduces execution latency by 61.41% to 71.72% across U-Net and Transformer architectures. Early termination also reduces peak GPU memory on SD1.4, SD1.5, and SDXL, while memory usage remains unchanged on SD3.5 Medium and Z-Image.
Table 5. Computational efficiency across five text-to-image generators. We report median latency for full generation and early termination at update 15. Savings are median paired reductions. Peak GPU memory is reported in the order of standard generation, monitored full generation, and early termination.
| Generator | Full (s) | Early Stop (s) | Saving (%) ↑ | Peak GPU (GiB) |
| SD1.4 | 2.674 | 0.789 | 70.56 | 3.49/3.49/2.12 |
| SD1.5 | 2.378 | 0.709 | 70.22 | 3.49/3.49/2.11 |
| SDXL | 6.600 | 1.867 | 71.72 | 18.49/18.50/7.09 |
| SD3.5 Medium | 21.247 | 8.213 | 61.11 | 12.06/12.06/12.06 |
| Z-Image | 62.360 | 23.488 | 62.21 | 12.52/12.52/12.52 |
Table 5. Computational efficiency across five text-to-image generators.
Conclusion
We investigated early safety signals in text-to-image diffusion models and found that native conditional responses enable effective detection of unsafe and adversarial inputs through compact statistics and simple linear readouts. Building on this finding, we introduced CSTI for calibrated early interception without attack samples, intermediate image decoding, or modification of accepted sampling. Experiments across five generators spanning U-Net and Transformer architectures demonstrate strong overall detection performance against representative baselines. Further analyses show that safety signals are accessible at early sampling stages and across multiple layers, while simple linear readouts remain effective. These findings demonstrate that native guidance computation provides an effective and efficient foundation for early safety interception.
Broader Context and Related Work
Adversarial robustness and AI security. The security of deep learning systems has been extensively investigated across diverse adversarial settings. Existing research has explored adversarial perturbations and robustness [2, 8, 13, 20], as well as transferable attacks against visual and multimodal representations [26, 27, 37]. Related studies have also investigated adversarial manipulation of training data and learned representations, including unlearnable examples [33, 36]. Beyond inference-time attacks, training-time threats such as data poisoning and model poisoning [15, 50], as well as backdoor attacks [10, 51, 56], can compromise learned representations and induce unintended model behaviors. Corresponding detection mechanisms have also been investigated across different learning architectures and tasks [45, 52]. These efforts highlight the broader importance of identifying adversarially induced behavior and developing reliable safeguards for increasingly capable AI systems.
Safety of foundation and generative models. As AI systems integrate language, vision, and decision-making capabilities, safety concerns have expanded beyond conventional discriminative prediction. Recent research has examined jailbreak attacks against large language models [54, 57], adversarial prompting and prompt injection in multimodal and agentic systems [9, 32, 49], and adversarial behavioral manipulation of embodied agents [34, 38, 53]. Related security challenges also arise in visual generative models, where adversarial manipulation can affect image editing [48], visual synthesis [35], and the generation of unsafe or misleading content [40, 46]. While these settings differ in their threat models and attack objectives, they underscore the need for safety mechanisms that extend beyond conventional input screening. In particular, generative models progressively construct their outputs through multiple computational stages, raising the question of whether emerging risks can be identified before synthesis is complete.
Safety defenses for text-to-image generation. Safety mechanisms for text-to-image generation operate at different stages of the generation pipeline. Before sampling, text classifiers such as the NSFW Text Classifier [21] and Detoxify [11] can screen potentially unsafe requests. Latent Guard [18] detects harmful concepts in text encoder representations, while GuardT2I [44] examines textual interpretations of guidance embeddings for adversarial prompt detection. Such screening can reject risky requests before synthesis, but does not observe how the generative state evolves during sampling. Other defenses directly modify the generation process. ESD [7] removes target concepts by updating model weights, whereas SLD [24] and CRG [5] suppress unsafe concepts through inference-time guidance. Nevertheless, adversarial prompting approaches such as Ring-A-Bell [31] and MMA-Diffusion [43] demonstrate that unsafe content can still be elicited despite existing safeguards. These limitations motivate safety assessment during generation, without modifying accepted sampling trajectories.
Intermediate representations and early safety detection. Recent studies investigate whether intermediate diffusion states can reveal safety-relevant information before the final image is available. IGD [41] classifies intermediate predicted noise, while Wukong [17] detects unsafe content from early U-Net features using an auxiliary safety decoder. FlowGuard [42] projects intermediate latents into an approximate image space for visual safety assessment. DAG [14] exploits cross-attention signals for harmful concept identification and adaptive guidance, whereas InGuard [39] combines prompt screening with detection on estimated clean latents. These approaches demonstrate the feasibility of assessing generation risk from intermediate computations, although their observation signals and intervention mechanisms differ.
More broadly, diffusion representations have been shown to capture semantic information useful for discriminative tasks beyond image generation. DIFT [29] and Diffusion Hyperfeatures [19] demonstrate the utility of intermediate features across sampling stages and network layers. Such findings motivate examining the safety information encoded within the generator’s native computations. Moreover, reliable interception requires not only a discriminative risk score but also a calibrated decision threshold, for which held-out calibration provides a principled foundation [1].
In contrast to approaches that require intermediate image reconstruction, auxiliary safety decoders, or modification of the generation process, CSTI examines the paired conditional and unconditional activations already computed by classifier-free guidance. By aggregating compact channel statistics across early sampling checkpoints, CSTI extracts safety-relevant signals using a lightweight linear readout. An independent safe calibration set determines the interception threshold, while flagged generations terminate early and accepted trajectories remain unchanged. This design exploits native conditional computation to support efficient safety assessment before image synthesis is complete.
References
- [1]Anastasios N. Angelopoulos and Stephen Bates. A gentle introduction to conformal prediction and distribution-free uncertainty quantification. arXiv preprint arXiv:2107.07511, 2021. 3, 5, 12arxiv.org/abs/2107.07511
- [2]Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In 2017 ieee symposium on security and privacy (sp), pages 39–57. IEEE, 2017. 11arxiv.org/abs/1608.04644
- [3]Ziheng Cheng, Yixiao Huang, Hui Xu, Somayeh Sojoudi, Xuandong Zhao, Dawn Song, and Song Mei. OVERT: A benchmark for over-refusal evaluation on text-to-image models. In Advances in Neural Information Processing Systems, 2025. 5, 8arxiv.org/abs/2505.21347
- [4]Zhi-Yi Chin, Chieh Ming Jiang, Ching-Chun Huang, Pin-Yu Chen, and Wei-Chen Chiu. Prompting4Debbuging: Red-teaming text-to-image diffusion models by finding problematic prompts. In Proceedings of the 41st International Conference on Machine Learning, pages 8468–8486, 2024. 5arxiv.org/abs/2309.06135
- [5]Yoonseok Choi, Chaeyoung Oh, Hyunjun Choi, Seokin Seo, and Kee-Eung Kim. Concept removal guidance: Evidence-calibrated negative guidance for safe diffusion sampling. In Proceedings of the 43rd International Conference on Machine Learning, pages 20250–20278, 2026. 2, 3, 11
- [6]Patrick Esser, Smith K u lal, Andreas Blattmann, Rahim Entezari, Jonas Müller, Harry Saini, Yam Levi, Dominik Lorenz, Axel Sauer, Frederic Boesel, Dustin Podell, Tim Dockhorn, Zion English, and Robin Rombach. Scaling rectified flow transformers for high-resolution image synthesis. In Proceedings of the 41st International Conference on Machine Learning, pages 12606–12633, 2024. 2arxiv.org/abs/2403.03206
- [7]Rohit Gandikota, Joanna Materzynska, Jaden Fiotto-Kaufman, and David Bau. Erasing concepts from diffusion models. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2426–2436, 2023. 2, 3, 11arxiv.org/abs/2303.07345
- [8]Ian J Goodfellow, Jonathan Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014. 11DOI
- [9]Kai Greshake, Sahar Abdelnabi, Shailesh Mishra, Christoph Endres, Thorsten Holz, and Mario Fritz. Not what you’ve signed up for: Compromising real-world llm-integrated applications with indirect prompt injection. In Proceedings of the 16th ACM workshop on artificial intelligence and security, pages 79–90, 2023. 11arxiv.org/abs/2302.12173
- [10]Tianyu Gu, Brendan Dolan-Gavitt, and Siddharth Garg. Badnets: Identifying vulnerabilities in the machine learning model supply chain. arXiv preprint arXiv:1708.06733, 2017. 11arxiv.org/abs/1708.06733
- [11]Laura Hanu and Unitary team. Detoxify. GitHub repository, 2020. Accessed September 29, 2026. 2, 3, 11
- [12]Jonathan Ho and Tim Salimans. Classifier-free diffusion guidance. arXiv preprint arXiv:2207.12598, 2022. 1arxiv.org/abs/2207.12598
- [13]Jianyi Hu, Hangtao Zhang, Yi Liu, Yeqi Zeng, Li Zeng, Xianlong Wang, Rui Wang, and Leo Yu Zhang. Jevad-bench: A benchmark and black-box attacks for reinforcement learning for calibrated decisions models. arXiv preprint arXiv:2609.31142, 2026. 11arxiv.org/abs/2609.31142
- [14]Feifei Li, Mi Zhang, Yiming Sun, and Min Yang. Detect-and-Guide: Self-regulation of diffusion models for safe text-to-image generation via guideline token optimization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2025. 3, 6, 11arxiv.org/abs/2503.15197
- [15]Minghui Li, Hongtao Zhang, Yanjun Zhang, Li Zeng, Chao Chen, Qiyun Shao, Wei Wan, Shengshan Hu, and Leo Yu Zhang. Fine-grained poisoning framework against federated learning. IEEE Transactions on Dependable and Secure Computing, 2025. 11
- [16]Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, and Matthew Le. Flow matching for generative modeling. In International Conference on Learning Representations, 2025. 5
- [17]Mingrui Liu, Sixiao Zhang, and Cheng Long. Wukong framework for not safe for work detection in text-to-image systems. In Proceedings of the 32nd ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pages 891–902, 2026. 1, 3, 6, 11arxiv.org/abs/2508.00591
- [18]Runtao Liu, Ashkan Khakzar, Jindong Gu, Qifeng Chen, Philip Torr, and Fabio Zizzi. Latent Guard: A safety framework for text-to-image generation. In Computer Vision – ECCV 2024, pages 93–109. Springer, 2024. 2, 3, 6, 11arxiv.org/abs/2404.08031
- [19]Grace Luo, Lisa Dunlap, Dong Huk Park, Aleksander Holynski, and Trevor Darrell. Diffusion hyperfeatures: Searching through time and space for semantic correspondence. In Advances in Neural Information Processing Systems, 2023. 3, 12arxiv.org/abs/2305.14334
- [20]Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017. 11arxiv.org/abs/1706.06083
- [21]michellejieli. NSFW text classifier. Hugging Face model repository, 2022. Accessed September 29, 2026. 2, 3, 6, 11
- [22]Dustin Podell, Zion English, Kyle Lacey, Andreas Blattmann, Tim Dockhorn, Jonas Müller, Joe Penna, and Robin Rombach. SDXL: Improving latent diffusion models for high-resolution image synthesis. In International Conference on Learning Representations, 2024. 2arxiv.org/abs/2307.01952
- [23]Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 10684–10695, 2022. 1, 2
- [24]Patrick Schramowski, Manuel Brack, Björn Deiseroth, and Kristian Kersting. Safe latent diffusion: Mitigating inappropriate degeneration in diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 22522–22531, 2023. 2, 3, 5, 11arxiv.org/abs/2211.05105
- [25]Jiaming Song, Chenlin Meng, and Stefano Ermon. Denoising diffusion implicit models. In International Conference on Learning Representations, 2021. 5arxiv.org/abs/2010.02502
- [26]Yufei Song, Ziqi Zhou, Minghui Li, Xianlong Wang, Hangtao Zhang, Menghao Deng, Wei Wan, Shengshan Hu, and Leo Yu Zhang. Pb-uap: Hybrid universal adversarial attack for image segmentation. In ICASSP 2025-2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 1–5. IEEE, 2025. 11arxiv.org/abs/2412.16651
- [27]Yufei Song, Ziqi Zhou, Qi Lu, Hangtao Zhang, Yifan Hu, Lulu Xue, Shengshan Hu, Minghui Li, and Leo Yu Zhang. SegTrans: Transferable adversarial examples for segmentation models. IEEE Transactions on Multimedia, 2026. 11arxiv.org/abs/2510.08922
- [28]Stability AI. Stable Diffusion 3.5 Medium: Model card. Hugging Face model repository, 2024. Accessed October 11, 2026. 2
- [29]Luming Tang, Menglin Jia, Qianqian Wang, Cheng Perng Phoo, and Bharath Hariharan. Emergent correspondence from image diffusion. In Advances in Neural Information Processing Systems, 2023. 3, 12arxiv.org/abs/2306.03881
- [30]Tongyi-MAI. Z-Image: Full foundation model. Hugging Face model repository, 2025. Accessed October 11, 2026. 2
- [31]Yu-Lin Tsai, Chia-Yi Hsu, Chulin Xie, Chih-Hsun Lin, Jia You Chen, Bo Li, Pin-Yu Chen, Chia-Mu Yu, and Chun-Ying Huang. Ring-A-Bell: how reliable are concept removal methods for diffusion models? In International Conference on Learning Representations, 2024. 1, 2, 5, 11arxiv.org/abs/2310.10012
- [32]Junhui Wang, Hangtao Zhang, Zhirun Zheng, Li Zeng, Jiejun Xiao, Xi Luo, Lihua Yin, and Saiqin Long. Pvdtector: Detecting prompt injection attacks on purpose-specific llm agents through policy-violation concept analysis. In Proceedings of the 34th ACM International Conference on Multimedia, 2026. 11
- [33]Xianglong Wang, Minghui Li, Wei Liu, Hangtao Zhang, Shengshan Hu, Yechao Zhang, Ziqi Zhou, and Hai Jin. Unlearnable 3d point clouds: Class-wise transformation is all you need. Advances in Neural Information Processing Systems, 37:99404–99432, 2024. 11arxiv.org/abs/2410.03644
- [34]Xianlong Wang, Hewen Pan, Hangtao Zhang, Minghui Li, Shengshan Hu, Ziqi Zhou, Lulu Xue, Aishan Liu, Yunpeng Jiang, Leo Yu Zhang, et al. Trojanrobot: Physical-world backdoor attacks against vlm-based robotic manipulation. arXiv preprint arXiv:2411.11683, 2024. 11
- [35]Xianlong Wang, Wenbo Pan, Shijia Zhou, Ke Li, Yuqi Wang, Zeyu Ye, Hangtao Zhang, Leo Yu Zhang, and Xiaohua Jia. Image-to-video diffusion: From foundations to open frontiers. arXiv preprint arXiv:2605.17248, 2026. 11arxiv.org/abs/2605.17248
- [36]Xianlong Wang, Hangtao Zhang, Wenbo Pan, Ziqi Zhou, Changsong Jiang, Li Zeng, and Xiaohua Jia. Dual-branch robust unlearnable examples. arXiv preprint arXiv:2605.01718, 2026. 11arxiv.org/abs/2605.01718
- [37]Yichen Wang, Yixuan Chou, Ziqi Zhou, Hangtao Zhang, Wei Wan, Shengshan Hu, and Minghui Li. Breaking barriers in physical-world adversarial examples: Improving robustness and transferability via robust feature. In Proceedings of the AAAI Conference on Artificial Intelligence, pages 8069–8077, 2025. 11arxiv.org/abs/2412.16958
- [38]Yichen Wang, Hangtao Zhang, Hewen Pan, Ziqi Zhou, Xianlong Wang, Peijin Guo, Lulu Xue, Shengshan Hu, Minghui Li, and Leo Yu Zhang. Advmedm: Fine-grained adversarial attack against vlm-based embodied agents. Advances in Neural Information Processing Systems, 38:136551–136575, 2026. 11arxiv.org/abs/2509.16645
- [39]Zeyu Wang, Xiaodan Li, Zhiwen Li, Yuefeng Chen, and Hui Xue. InGuard: Towards generalized inner guardrail for safe text-to-image generation. arXiv preprint arXiv:2609.27620, 2026. 3, 11arxiv.org/abs/2609.27620
- [40]Meng Xie, Li Zeng, Hangtao Zhang, Xianlong Wang, Ziqi Zhou, Pengpeng Qiao, and Zhetao Li. Typo: Instruction-dense visual jailbreaks against commercial closed-source image-generation models. arXiv preprint arXiv:2607.24897, 2026. 11arxiv.org/abs/2607.24897
- [41]Fan Yang, Yihao Huang, Jiayi Zhu, Ling Shi, Gequang Pu, Jin Song Dong, and Kailong Wang. Seeing it before it happens: In-generation NSFW detection for diffusion-based text-to-image models. arXiv preprint arXiv:2508.03006, 2025. 1, 3, 6, 11arxiv.org/abs/2508.03006
- [42]Jinghan Yang, Yihe Fan, Xudong Pan, and Min Yang. Flow-Guard: Towards lightweight in-generation safety detection for diffusion models via linear latent decoding. arXiv preprint arXiv:2604.07879, 2026. 1, 3, 11arxiv.org/abs/2604.07879
- [43]Yijun Yang, Ruiyuan Gao, Xiaosen Wang, Tsung-Yi Ho, Nan Xu, and Qiang Xu. MMA-Diffusion: MultiModal attack on diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 7737–7746, 2024. 1, 2, 5, 11arxiv.org/abs/2311.17516
- [44]Yijun Yang, Ruiyuan Gao, Xiao Yang, Jianyuan Zhong, and Qiang Xu. GuardT2I: Defending text-to-image models from adversarial prompts. In Advances in Neural Information Processing Systems, 2024. 2, 6, 11
- [45]Zeming Yao, Hangtao Zhang, Yicheng Guo, Xin Tian, Wei Peng, Yi Zou, Leo Yu Zhang, and Chao Chen. Reverse backdoor distillation: Towards online backdoor attack detection for deep neural network models. IEEE Transactions on Dependable and Secure Computing, 21(6):5098–5111, 2024. 11DOI
- [46]Zeyu Ye, Yanchun Li, Sibei He, Meng Xie, Hangtao Zhang, Xianlong Wang, Li Zeng, Jiahao Chen, Yichen Wang, Junhui Wang, et al. False claims, credible images: A red-teaming benchmark for commercial image generators. arXiv preprint arXiv:2610.11112, 2026. 11arxiv.org/abs/2610.11112
- [47]Z-Image Team. Z-Image: An efficient image generation foundation model with single-stream diffusion transformer. arXiv preprint arXiv:2511.22699, 2025. 2
- [48]Li Zeng, Xiaojun Mo, Meng Xie, Hangtao Zhang, Yixiang Liu, Yezhuo Peng, and Yanchun Li. Psfd: Proactive spatial-frequency defense against malicious exemplar-guided image editing. In 2025 IEEE International Conference on Multimedia and Expo (ICME), pages 1–6. IEEE, 2025. 11
- [49]Li Zeng, Zeyu Ye, Meng Xie, Hangtao Zhang, Xianlong Wang, Yanchun Li, and Zhetao Li. Ghostprompt: Cross-image adversarial prompt for vision-language models. In Proceedings of the 34th ACM International Conference on Multimedia, 2026. 11
- [50]Hangtao Zhang, Zeming Yao, Leo Yu Zhang, Shengshan Hu, Chao Chen, Alan Liew, and Zhetao Li. Denial-of-service or fine-grained control: Towards flexible model poisoning attacks on federated learning. In Proceedings of the Thirty-Second International Joint Conference on Artificial Intelligence, pages 4567–4575, 2023. 11arxiv.org/abs/2304.10783
- [51]Hangtao Zhang, Shengshan Hu, Yichen Wang, Leo Yu Zhang, Ziqi Zhou, Xianlong Wang, Yanjun Zhang, and Chao Chen. Detector collapse: Backdooring object detection to catastrophic overload or blindness in the physical world. In Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence, pages 1670–1678, 2024. 11
- [52]Hangtao Zhang, Yichen Wang, Shihui Yan, Chenyu Zhu, Ziqi Zhou, Linshan Hou, Shengshan Hu, Minghui Li, Yanjun Zhang, and Leo Yu Zhang. Test-time backdoor detection for object detection models. In Proceedings of the Computer Vision and Pattern Recognition Conference, pages 24377–24386, 2025. 11arxiv.org/abs/2503.15293
- [53]Hangtao Zhang, Chenyu Zhu, Xiaolong Wang, Ziqi Zhou, Changgong Yin, Minghui Li, Lulu Xu, Yichen Wang, Shengshan Hu, Aishan Liu, et al. Badrobot: Jailbreaking embodied llm agents in the physical world. In Proceedings of the Thirteenth International Conference on Learning Representations, 2025. 11arxiv.org/abs/2407.20242
- [54]Hangtao Zhang, Yucheng Zhao, Sishun Liu, Ziqi Zhou, Zeyu Ye, Wei Wan, Minghui Li, Shengshan Hu, Yanjun Zhang, Yi Liu, and Leo Yu Zhang. Defending jailbreak attacks on large language models via manifold trajectory kinetics. In 35th USENIX Security Symposium (USENIX Security 26), pages 2147–2166, 2026. 11
- [55]Yimeng Zhang, Jinghan Jia, Xin Chen, Aochuan Chen, Yihua Zhang, Jiancheng Liu, Ke Ding, and Sijia Liu. To generate or not? safety-driven unlearned diffusion models are still easy to generate unsafe images ... for now. In European Conference on Computer Vision, 2024. 5arxiv.org/abs/2310.11868
- [56]Ziqi Zhou, Menghao Deng, Yufei Song, Hangtao Zhang, Wei Wan, Shengshan Hu, Minghui Li, Leo Yu Zhang, and Dezhong Yao. Darkhash: A data-free backdoor attack against deep hashing. IEEE Transactions on Information Forensics and Security, 2025. 11arxiv.org/abs/2510.08094
- [57]Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J Zico Kolter, and Matt Fredrikson. Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043, 2023. 11arxiv.org/abs/2307.15043