PNRG: Black-Box Backdoor Detection for Text-to-Image Diffusion Models Based on Prompt–Null-Condition Reconstruction GapPNRG: Black-Box Backdoor Detection for Text-to-Image Diffusion Models via Prompt-Null Reconstruction Gap
The author proposes a black-box detector, PNRG, with an average detection accuracy of 93.2% across six attack settings on SD v1.4, higher than BlackMirror's 74.8%.
The defender has only black-box access to the T2I service, and the model may have been implanted with a backdoor before deployment; there is no access to the training process or internal state, and the trigger, attack type and target behavior are unknown, so only the final output can be observed. Assume the same model supports text-to-image generation and image-to-image reconstruction with adjustable strength, and the goal is to screen candidate prompts one by one.
- Hosted T2I services only return images, so the internal states required by white-box and gray-box detection are unavailable; existing black-box methods also tend to mix sampling randomness and normal semantic variation with local or concept-level backdoor responses.
- PNRG first generates a reference image from the candidate prompt and builds a mosaic anchor, then reconstructs with the candidate prompt and the null condition separately under the same settings, uses the pixel MSE of the two images as the score, and calibrates the threshold offline with 50 benign prompts.
- Across six attack settings on SD v1.4, PNRG achieves an average Acc. of 0.932 and AUROC of 0.977; on BadT2IST and DreamBooth for SDXL and SD3, both Acc. and FPR are better than BlackMirror. In mechanism analysis, BadT2IST's score has a Pearson r of 0.942 with internal residuals.
- The author notes that the method targets prompt-activated backdoors that produce a measurable prompt-null response during reconstruction; when the response is weak or overlaps with ordinary semantics, the detection margin may be smaller; differences in operations across services may require recalibration, and extending to more restricted interfaces is future work.
- Evaluated models
- Stable Diffusion v1.4 (SD v1.4)SDXL Base 1.0SD3 MediumPNRG
- Metrics
- Acc.AUROCTPRFPRASRFIDTime (s/prompt)
PNRG is a black-box backdoor detection method for text-to-image diffusion models, achieving an average detection accuracy of 93.2% across multiple attack settings, 18.4 percentage points higher than the strongest black-box baseline (74.8%). The method compares noise-prediction differences between candidate prompts and the empty condition under classifier-free guidance, and applies mosaic degradation to reference images generated from candidate prompts, reducing reconstruction fluctuations for benign prompts to highlight trigger responses.
Related events and news
1 events · 0 news mentions
- This event's paper
PNRG:文本到图像扩散模型黑盒后门检测
Paper analysis
What problem does this paper attempt to solve?
The authors study how to distinguish T2I backdoor responses from normal generation variation when only the final image can be observed.
The core question is: under black-box conditions with no access to the model's internal state, how can candidate prompts that would activate a T2I diffusion model backdoor be detected?
- Application background: The authors note that users of third-party checkpoints, custom adapters, and hosted generation services typically cannot verify training data, fine-tuning processes, or parameter modifications; a backdoor can maintain benign behavior and produce attacker-specified content under a hidden trigger.
- Difficulties of existing output-level methods: Methods such as UFID rely on output consistency under prompt perturbation, and BlackMirror relies on semantic deviation; the authors argue that sampling randomness, normal content variation, and backdoor effects mix together, and local or concept-level attacks are especially easy to mask.
- Core observation: In classifier-free guidance, the difference between the prompt-conditioned and null-conditioned predictions carries both ordinary semantics and a possible trigger response. The authors therefore hypothesize that if a shared visual reference is used to constrain ordinary variation, the final reconstruction difference can serve as an observable proxy for the internal prompt-null response.
- Proposed method: The authors propose Prompt-Null Reconstruction Gap (PNRG), combining a mosaic anchor, matched prompt-null dual-branch reconstruction, and benign score calibration; each candidate prompt uses one reference generation and two reconstructions, three queries in total.
- Threat model:
- Attacker goal: The model behaves normally on benign prompts and activates attacker-specified behavior on prompts containing the trigger.
- Defender knowledge: Does not know the trigger, attack type, or target behavior, and cannot access the training process, model parameters, or intermediate denoising states.
- Defender capability: Observes only the final output, but can call the same model's text-to-image generation and image-to-image reconstruction, and specify the reference image, text condition, and reconstruction strength.
- Victim system and task: A T2I service that may have been implanted with a backdoor; the defender screens candidate prompts one by one with limited queries.
What related research exists?
Related work falls into three lines: T2I backdoor attacks, internal signal detection, and output-level black-box detection.
Backdoor attacks on T2I diffusion models
- BadT2I, VillanDiffusion and Rickrolling: BadT2I binds text triggers to pixel patterns, object replacement and global style; VillanDiffusion supports multi-target, multi-condition behaviors; Rickrolling manipulates text representations.
- Personalization and adapter attacks: Textual Inversion or DreamBooth are used to implant malicious concepts, identities or styles, and malicious LoRA adapters extend this channel to model customization.
- Parameter editing and broader activation methods: Direct parameter or block editing lowers the implantation cost; subsequent work also studies copyright leakage, imperceptible or trigger-free conditions, hidden bias, natural prompts, semantic regions and encoder-induced semantic drift.
Detection requiring internal access
- Attention signals: T2IShield and Fine-Grained Prompt Screening use token assimilation or cross-attention patterns, and DAA-I tracks changes in the cross-attention map during denoising.
- Neuron, trajectory and temporal signals: NaviT2I uses early neuron activation changes, and DADet and Backdoor Sentinel use generation diversity, trajectory anomalies or temporal noise consistency.
- Weights and intermediate states: STEDF combines model weights at selected timesteps with features of intermediate denoising states. The authors argue that such methods' dependence on parameters or intermediate states limits their use in services that only return the final image.
Black-box output-level detection and this paper's baselines
- UFID (2025): measures output consistency under prompt perturbation; BlackMirror (2026): captures stable instruction-response deviation. The authors note that both still rely on output similarity, semantic deviation or cross-sample stability, that prompt perturbation and random sampling may mask backdoor effects, and that repeated queries and auxiliary model inference also add cost.
- Experimental baselines and data: white-box baselines are T2IShield (FTT, CDA), NaviT2I, DAA-I and STEDF, and black-box baselines are UFID and BlackMirror; CLIP image–text similarity is also compared. The main evaluation uses six settings constructed with BadT2I, VillanDiffusion, DreamBooth and STEBA, with benign prompts from COCO-val.
The authors position PNRG as a prompt-level detection that does not read internal states: it replaces output similarity or semantic deviation with controlled prompt-null reconstruction, and uses a shared mosaic anchor to constrain benign variation.
How does the paper address this problem?
PNRG uses a shared mosaic reference for prompt-null paired reconstruction, then judges by pixel MSE and a benign threshold.
The overall idea is to convert the invisible conditional response into a final-image difference: PNRG starts the candidate prompt and the null condition from the same mosaic anchor, the same reconstruction settings and the same random realization, then compares the two reconstructions.
Problem setting and detection principle
- Prompt-null increment: Definition 1 defines Δt(xt,cp)=ϵθ(xt,t,cp)−ϵθ(xt,t,c∅), i.e., the change in noise prediction introduced by the candidate prompt relative to the empty-text condition at the same latent state and timestep.
- Response decomposition: The authors conceptually split the increment into an ordinary semantic response and an extra trigger response; for benign prompts the latter is approximately zero, but the ordinary semantic response may still be large, so the increment norm alone cannot isolate the backdoor.
- Cumulative reconstruction gap: Proposition 1, under conditions such as a shared initial sampler state and random realization, gives a first-order decomposition of the final image difference with respect to the per-step conditional increments; on this basis the authors treat paired reconstruction as an image-space proxy for the cumulative prompt-null response, while noting that ordinary semantics also contribute to the gap.
Mosaic anchor and paired reconstruction
- Reference image and anchor: A reference image is first generated from the candidate prompt, then downsampled to a low-resolution grid with side length s and nearest-neighbor upsampled to obtain the mosaic anchor. It preserves color, approximate object positions and global layout while reducing high-frequency details that the two branches might recover in different ways.
- Two reconstructions: The candidate branch and the null branch use the same query model, anchor, reconstruction schedule and random seed, yielding two outputs; the null branch provides the control with the candidate text condition omitted.
- Design values: 512×512 images use a 24×24 mosaic, and 1024×1024 images use 48×48; reconstruction strength d=0.4, candidate-branch guidance scale w=7.5, and the null branch uses unconditional prediction. The authors state that moderate degradation and low-strength reconstruction are used to balance the shared scene constraint with the influence of the text condition.
Score, calibration and query procedure
- Detection score: S(p)=‖ Ip−I∅‖22/(HWC), i.e., the MSE of the two reconstructions over all pixels and channels; the shared anchor makes corresponding pixels more comparable and requires no auxiliary scoring model.
- Offline calibration: The score mean and standard deviation are estimated using 50 benign prompts that do not overlap with the test set, and the threshold is the mean plus λ times the standard deviation, with λ=2 fixed for all models and attacks; S(p) above the threshold is judged suspicious, otherwise normal.
- Online overhead: Each candidate prompt performs one reference generation and two partial reconstructions. Calibration is performed offline separately for the query model, reconstruction settings and prompt distribution, and adds no online screening queries.
Adaptive attacks and mechanism-check design
- Internal residual control: The gray-box analysis compares the stepwise noise predictions of the two conditions on fixed candidate-trajectory inputs and accumulates the mean squared difference to obtain R(p), then tests its correlation with S(p) and its own ability to distinguish benign from triggered prompts; this internal access is used only for analysis.
- Two adaptive variants: residual suppression adds a penalty on the prompt-null prediction difference to the backdoor training objective, with β tested from 0 to 10; the timestep-shifted attack is trained only on [400,1000), only on [0,400), or on the full [0,1000). Detection keeps the default PNRG configuration, while ASR and FID are used to check attack utility and image quality.
What experiments did the paper conduct?
The experiments cover three backbones, six main attack settings, mechanism and anchor analyses, adaptive attacks and runtime cost.
Experimental setup
- Backbones tested: Stable Diffusion v1.4, SDXL Base 1.0 and SD3 Medium. The main table uses 512×512 images and 50-step sampling on SD v1.4; SDXL and SD3 use 1024×1024 images with 20 and 25 sampling steps, respectively.
- Attack settings: The main evaluation uses BadT2IST, BadT2IMT, VillanST, VillanMT, DreamBooth and STEBA; the cross-backbone evaluation uses only BadT2IST and DreamBooth. Attack configurations are in Table 4.
- Samples and calibration: Each attack setting contains 500 benign and 500 trigger-bearing test prompts; benign prompts come from COCO-val. PNRG additionally uses 50 benign prompts that do not overlap with the test set, calibrated separately per query model.
- Baselines: White-box: T2IShield FTT, T2IShield CDA, NaviT2I, DAA-I, STEDF; black-box: UFID and BlackMirror. BlackMirror uses Qwen3-8B and Qwen2.5-VL-7B-Instruct, and UFID uses OpenAI CLIP ViT-B/32.
- Metrics and decision rule: The main metrics are Acc. and AUROC, with trigger-bearing prompts as the positive class; TPR and FPR are also reported. Adaptive experiments use the ResNet-18 classifier provided by BadT2I to determine ASR, and FID to measure image quality.
- Repetition and statistics: Runtime is measured on 10 prompts after one warm-up per setting, 60 prompts in total. The anchor comparison uses 1,000 bootstrap iterations; the calibration composition analysis uses 2,000 bootstrap iterations, and the paper does not report the number of repeated runs for the main detection table.
Main results
According to Table 1, the Acc. on the six attack settings on SD v1.4 is as follows; BlackMirror returns only binary predictions, and the paper does not report its AUROC.
Swipe horizontally to read the table
Method Access BadT2IST BadT2IMT VillanST VillanMT DreamBooth STEBA Average T2IShield FTT white-box 0.529 0.488 0.857 0.721 0.479 0.687 0.627 T2IShield CDA white-box 0.521 0.516 0.929 0.814 0.613 0.652 0.674 NaviT2I white-box 0.920 0.678 0.930 0.925 0.480 0.528 0.744 DAA-I white-box 0.616 0.469 0.538 0.570 0.631 0.644 0.578 STEDF white-box 0.967 0.993 0.640 0.645 0.927 0.741 0.819 UFID black-box 0.473 0.472 0.851 0.853 0.699 0.492 0.640 BlackMirror black-box 0.851 0.851 0.839 0.775 0.432 0.737 0.748 PNRG black-box 0.956 0.930 0.962 0.898 0.891 0.956 0.932 - Overall comparison: PNRG's average AUROC is 0.977, STEDF's is 0.918, and UFID's is 0.698; the authors report that PNRG's average Acc. is 18.4 percentage points higher than BlackMirror's. STEDF remains the white-box baseline with the highest average Acc.
- Differences across settings: The authors note that PNRG is relatively harder on VillanMT and DreamBooth, and suggest this may be because the trigger response in reconstruction is weaker and the prompt-null gap increases less; this is the authors' explanation.
- Baseline exceptions: UFID performs well on the two VillanDiffusion settings but lower on BadT2I and STEBA; BlackMirror is 0.432 on DreamBooth. The authors take this to mean that a single output consistency or semantic deviation cannot cover these attack behaviors.
Cross-backbone and additional comparisons
- SDXL and SD3: According to Table 2, PNRG's Acc. on SDXL BadT2IST and DreamBooth is 0.933 and 0.906, respectively, and BlackMirror's is 0.799 and 0.562; on SD3 they are 0.969 and 0.907, respectively, and BlackMirror's are 0.880 and 0.416. PNRG's FPR is also lower in all four settings.
- Specific error rates: On SDXL BadT2IST, PNRG's TPR/FPR is 0.956/0.090, and BlackMirror's is 0.982/0.384; that is, BlackMirror's TPR is higher, but its FPR is also higher.
- CLIP comparison: According to Table 5, CLIP image–text similarity has an average Acc./AUROC of 0.732/0.784, and PNRG has 0.932/0.977; however, CLIP's Acc. and AUROC on VillanST and STEBA are both higher than PNRG's, which the authors relate to the image–text mismatch caused by fixed target replacement.
Mechanism, anchor and target-realization analysis
- Internal response correlation: Figure 3 reports, on 1,000 pooled samples from BadT2IST, a Pearson r=0.942 and Spearman ρ=0.908 between log10 R(p) and log10 S(p), and an AUROC=0.996 for R(p) distinguishing the two groups of prompts. Figure 7 reports r=0.989 and 0.933 on VillanMT and DreamBooth, respectively.
- Anchor comparison: In Figure 5, with the same reference image, Mosaic's AUROC on BadT2IST, VillanST and DreamBooth is 0.986, 0.945 and 0.885, respectively, Clear's is 0.837, 0.018 and 0.661, and Blur's is 0.989, 0.984 and 0.825. Appendix D reports that Mosaic's gain over Blur on BadT2IST and DreamBooth has 95% intervals of [0.129,0.177] and [0.040,0.081], respectively, neither containing zero; on VillanST, Mosaic and Blur are similar.
- Missed detections where the target is not realized: In Appendix D, 388/392 target-hit prompts in VillanMT are flagged, and 61 of the 65 missed detections occur on prompts whose reference image did not meet the target criterion; the authors also report a small number of flags on target-miss samples for VillanST, VillanMT and STEBA, namely 5/16, 47/108 and 15/30.
Adaptive attacks and runtime cost
- Residual suppression: Figure 6(a) shows that as β increases, the decline in detection performance is accompanied by a decrease in ASR and an increase in FID; the authors state that in the low-weight region where ASR is still high, Acc. and AUROC remain high. The translated text does not provide the exact values of each curve.
- Timestep shift: Appendix C.4 reports that training only within the detection window [0,400) gives ASR≈0; training on [400,1000) maintains high ASR and remains detectable, and full training also retains high ASR and high detection performance. The authors argue that both variants exhibit a trade-off between evasion and attack utility.
- Runtime: According to Table 3, on a single NVIDIA H100 80GB GPU with serial execution, PNRG averages 2.629 s/prompt, UFID 10.450, and BlackMirror 10.729; NaviT2I, DAA-I and STEDF are 0.600, 0.330 and 0.626, respectively, but require internal signals.
Other ablations and analyses
- Threshold multiplier: In Figure 10, λ only changes the decision threshold and does not change AUROC; the default λ=2 for the six settings.
- Mosaic size: Figure 11 shows that the preferred s varies with the attack, and a larger grid lowers VillanST AUROC; the default is s=24.
- Reconstruction strength: Appendix E.3 reports that for d=0.2 to 0.4, AUROC is above 0.93 on all six settings, and at higher strengths VillanDiffusion AUROC decreases; the default is d=0.4.
- Guidance scale: Appendix E.4 reports that as w increases from 7.5 to 12.5, BadT2IST accuracy decreases, while accuracy on the two VillanDiffusion settings increases; the default is w=7.5.
- Calibration size: Figure 14 uses n=5 to 200; for n<30, results are averaged over 200 subsets, and for n≥30, the first n scores are taken in a fixed order and evaluated once.
- Difference metrics: Figure 15 compares MSE, MAE, RMSE, PSNR, LPIPS, CLIP and DINO; the authors report that LPIPS shows no consistent gain over MSE, and MSE is ultimately used.
What are some points that can be further explored?
The authors list response strength, interface assumptions and recalibration issues; the experiments also have explicit model and protocol boundaries.
Limitations and future directions noted by the authors
- Applicable backdoor types: Section 6 explains that PNRG targets prompt-activated backdoors whose effects can produce a measurable prompt-null response during reconstruction.
- Detection margin: Section 6 notes that when the induced response is weak or overlaps semantically with ordinary prompts, the detection margin may be smaller.
- Interface assumptions: Section 6 explains that the implementation assumes the service supports image-to-image reconstruction with configurable strength and an available null condition.
- Cross-service calibration: Section 6 notes that when these operations differ across services, recalibration may be needed.
- Future directions: Section 6 explicitly lists extension to more restricted interfaces and broader deployment settings as future work.
Experimental coverage
- Backbones and attacks: The tested backbones are SD v1.4, SDXL Base 1.0, and SD3 Medium, three in total; all six main attack settings are evaluated on SD v1.4, and SDXL and SD3 each evaluate two settings, BadT2IST and DreamBooth (Section 5.1, Table 1, and Table 2).
- Test and calibration scale: Each attack setting uses 500 benign and 500 trigger-bearing test prompts, and PNRG by default uses 50 independent benign prompts for calibration; the main detection table does not report the number of repeated runs (Section 5.1, Appendix C.1).
- Adaptive evaluation: Both adaptive variants use BadT2IST on SD v1.4, with detection kept at the default configuration; each adaptive setting evaluates ASR and FID with 1,500 generated images (Appendix C.4).
- Mechanism evidence: R(p) requires reading noise predictions and is used only for gray-box mechanism analysis; the correlation analysis covers BadT2IST, VillanMT, and DreamBooth, each with n=1000 (Section 5.3, Figure 3, and Figure 7).
- Runtime cost: Timing was performed serially on a single NVIDIA H100 PCIe 80GB GPU, with 10 prompts timed per setting; it does not include model loading, training, offline calibration, or final metric aggregation (Appendix C.5).
Summarize the main content of the paper
PNRG constructs a prompt-null reconstruction difference with three queries and achieves an average Acc. of 0.932 in black-box T2I backdoor screening.
PNRG is a black-box prompt-level backdoor detector for T2I diffusion models, addressing prompt screening scenarios where only the final image can be observed and the training process or internal states cannot be read.
- Problem and approach: The authors argue that output similarity and semantic deviation mix backdoor effects with sampling randomness and normal semantic variation. PNRG instead generates a reference image from the candidate prompt and builds a mosaic anchor, then performs matched reconstruction with the candidate condition and the null condition, scores by pixel MSE, and calibrates the threshold offline with 50 benign prompts.
- Main detection results: On the six attack settings on SD v1.4, PNRG achieves an average Acc. of 0.932 and an average AUROC of 0.977; BlackMirror achieves an average Acc. of 0.748, and white-box STEDF achieves 0.819 (Table 1). PNRG's Acc. across settings ranges from 0.891 to 0.962.
- Cross-backbone results: On the four combinations of BadT2IST and DreamBooth on SDXL and SD3, PNRG's Acc. is higher than BlackMirror's in all cases and its FPR is lower in all cases; on SD3 BadT2IST, the two achieve Acc. of 0.969 and 0.880, respectively (Table 2).
- Mechanism and control evidence: On BadT2IST, the log Pearson r between the internal stepwise residual and the PNRG score is 0.942 (Figure 3). With the same reference image, Mosaic achieves higher AUROC than Clear and Blur on BadT2IST and DreamBooth, but on VillanST Mosaic and Blur are similar (Figure 5).
- Adaptive attacks and cost: The authors report that when residual suppression degrades detection performance, it is accompanied by a decrease in ASR and an increase in FID; attacks trained only within the detection window have ASR≈0, while training outside the window still maintains high ASR and remains detectable. PNRG takes an average of 2.629 s/prompt, lower than UFID and BlackMirror, but higher than several white-box methods that require internal access (Table 3).
- Authors' conclusion: The authors argue that controlled prompt-null reconstruction can serve as a basis for black-box detection when internal states are inaccessible; they also explicitly state that it depends on a measurable reconstruction response, an adjustable reconstruction interface and a null condition, and that more restricted interfaces and broader deployment remain to be studied.
Research lineage
1 foundations · 0 follow-ups in libraryNo later in-library follow-ups recorded yet.
Hover or focus a connected paper to inspect the citation context.