DetectViT: Test-time Backdoor Detection for Vision Transformers via Inter-Head Attention Discrepancy
Siquan Huang, Yijiang Li, Xingfu Yan, Ningzhi Gao, Leyu Shi, Ying Gao
NeurIPS 2026
TL;DR. DetectViT, a test-time backdoor detection method that operates directly on the attention weights of ViTs.
Abstract. Vision Transformers (ViTs) now underpin the visual encoders of most multimodal models, but this success comes at a cost: relying on third-party pretrained checkpoints leaves these systems open to backdoor attacks. Existing test-time detection methods rely on either the predicted label or intermediate embeddings, limiting their applicability across diverse tasks and incurring substantial computational overhead. In this work, we study how backdoor triggers affect the multi-head attention mechanism of ViTs and identify two distinct anomalous patterns: , causing the attention to exhibit abnormally high inter-head spatial overlap, and , causing an abnormally large variance in the concentration of the attention distribution. Motivated by these findings, we propose , a test-time backdoor detection method that requires neither training data, model outputs, nor any prior knowledge of the trigger. DetectViT quantifies the two hijacking phenomena via an inter-head consistency score and an inter-head entropy variance score, with thresholds estimated from a small out-of-distribution (OOD) calibration set drawn from an arbitrary source. Across four representative attacks, diverse architectures (DeiT, CLIP, and LLaVA), and downstream tasks (image classification and captioning), DetectViT substantially outperforms all baselines with as few as 64--128 OOD calibration samples, achieving a true positive rate of and a false positive rate of on BadCLIP. Notably, it introduces negligible additional overhead by relying solely on attention weights already computed during inference. Code is available at: https://github.com/siquanhuang/DetectViT.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:46 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
The paper proposes DetectViT, a training-free test-time detector for backdoored ViT inputs. It uses abnormal agreement and entropy variation across attention heads, with thresholds calibrated from a small clean OOD set. The method is simple, efficient, and performs strongly across four attacks, several ViT architectures, and classification and captioning tasks. Reviewers Hbcr and TWph view the attention-based design as intuitive, practical, and reasonably novel. However, all three reviewers raise concerns about limited attack diversity. Most tests use patch triggers, with only one blended attack. Semantic, frequency-domain, clean-label, distributed, and self-supervised encoder attacks are missing. Reviewer DN52 also questions some claims about embedding-based defenses and missing related work. The three-sigma calibration is weakly justified, appears sensitive to the OOD source, and assumes near-Gaussian scores without evidence. Overall, this is a paper of decent quality, so I would recommend a borderline accept.
Final justification
The paper proposes DetectViT, a training-free test-time backdoor detector for Vision Transformers based on discrepancies across attention heads. The reviewers generally found the approach simple, efficient, and practically useful. The rebuttal partly strengthened the paper. In particular, the authors added evaluations on five additional attacks covering self-supervised, clean-label, frequency-domain, and optimized global triggers. They also provided further evidence supporting the calibration strategy, tested an alternative thresholding rule, and evaluated a stronger adaptive attacker. These additions address most of the original concerns regarding attack diversity and calibration robustness. Two reviewers now support acceptance. One reviewer remains at borderline reject, mainly because the methodological novelty is considered incremental and the comparison with closely related approaches could be more substantive. The method also remains limited for semantic triggers, and accessing attention weights may introduce overhead in some optimized inference settings. Overall, I find that the rebuttal addresses the main technical and empirical concerns. I therefore recommend acceptance.
Read meta-review
Meta-review
The paper proposes DetectViT, a training-free test-time detector for backdoored ViT inputs. It uses abnormal agreement and entropy variation across attention heads, with thresholds calibrated from a small clean OOD set. The method is simple, efficient, and performs strongly across four attacks, several ViT architectures, and classification and captioning tasks. Reviewers Hbcr and TWph view the attention-based design as intuitive, practical, and reasonably novel. However, all three reviewers raise concerns about limited attack diversity. Most tests use patch triggers, with only one blended attack. Semantic, frequency-domain, clean-label, distributed, and self-supervised encoder attacks are missing. Reviewer DN52 also questions some claims about embedding-based defenses and missing related work. The three-sigma calibration is weakly justified, appears sensitive to the OOD source, and assumes near-Gaussian scores without evidence. Overall, this is a paper of decent quality, so I would recommend a borderline accept.
Final justification
The paper proposes DetectViT, a training-free test-time backdoor detector for Vision Transformers based on discrepancies across attention heads. The reviewers generally found the approach simple, efficient, and practically useful. The rebuttal partly strengthened the paper. In particular, the authors added evaluations on five additional attacks covering self-supervised, clean-label, frequency-domain, and optimized global triggers. They also provided further evidence supporting the calibration strategy, tested an alternative thresholding rule, and evaluated a stronger adaptive attacker. These additions address most of the original concerns regarding attack diversity and calibration robustness. Two reviewers now support acceptance. One reviewer remains at borderline reject, mainly because the methodological novelty is considered incremental and the comparison with closely related approaches could be more substantive. The method also remains limited for semantic triggers, and accessing attention weights may introduce overhead in some optimized inference settings. Overall, I find that the rebuttal addresses the main technical and empirical concerns. I therefore recommend acceptance.
1 comment
- Rating
- 3/6
- Confidence
- 5/5
- Quality
- 2/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 2/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes DetectViT, a test-time backdoor sample detection method for Vision Transformers (ViT). Its objective is to determine, during the inference phase, whether an input image contains a trigger that would activate a model's backdoor, without requiring knowledge of the trigger's appearance or access to the original training data.
Strengths and weaknesses
Strengths:
- I appreciate the technical approach of this paper and agree that backdoor defenses should be as black-box as possible. This paper primarily relies on the entropy of the attention layer in the transformer architecture to detect backdoors, requiring only some reference data to help correct backdoor statistics.
- The paper presents appropriate and visually rich expressions.
Major Weaknesses:
- There is no evidence to support the conclusion that "Embedding-based methods [17, 19] sidestep this restriction 42 but are blind to attacks that target the classification head rather than the encoder." This also contradicts the facts, as backdoor attacks that only modify the classifier head are almost non-existent. Given that a linear head is usually a single-layer FC (with limited capacity), the backdoor gradient will inevitably affect the backbone representation.
- What this paper truly needs is an ablation on backdoor triggers, because the proposed attention entropy-based detector is heavily affected by triggers. The experiments in this paper only used patch triggers and a single blended trigger, which is insufficient. Frequency triggers, optimized global triggers (badclip does not belong here), etc., should be considered.
- This paper does not perform ablations on more challenging attack types. The four attack methods considered in this paper are all variations of bad labels. Label-consistent attacks [2] in supervised learning, DRUPE attacks [1] on visual encoders, and attacks on self-supervised encoders [3] should be considered.
- The authors should review directly relevant work [4][5] and explain the differences from them.
[1] Tao, G., Wang, Z., Feng, S., Shen, G., Ma, S., & Zhang, X. (2023). Distribution Preserving Backdoor Attack in Self-supervised Learning. 29~29. https://doi.org/10.1109/SP54263.2024.00029 [2] Turner, A., Tsipras, D., & Madry, A. (2019). Label-Consistent Backdoor Attacks (arXiv:1912.02771). arXiv. https://doi.org/10.48550/arXiv.1912.02771 [3] Saha, A., Tejankar, A., Koohpayegani, S. A., & Pirsiavash, H. (2022). Backdoor Attacks on Self-Supervised Learning. 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 13327~13336. https://doi.org/10.1109/CVPR52688.2022.01298 [4] Backdoor Cleaning without External Guidance in MLLM Fine-tuning, NeurIPS 2025 [5] A Study of the Attention Abnormality in Trojaned BERTs, NAACL 2022
Questions
Please focus on my major concerns 2 and 3. The main issue with this paper is the absence of two crucial experiments. If the authors could provide these additional experiments, I would be willing to upgrade my evaluation to "Borderline". Given that the required additional experimentation is non-trivial, I am inclined to recommend rejection of this paper.
Limitations
yes
Final justification
In my review, I highlighted Weaknesses 2 and 3 as the most important concerns, and the authors have largely addressed my questions. However, I still believe that the paper’s novelty does not meet the standards of NeurIPS. In addition, the paper lacks a comparative analysis with existing methods based on predictive entropy. Therefore, I have decided to maintain a borderline reject score.
Formatting concerns
no
3 comments
Rebuttal
Response to Reviewer DN52
We thank the reviewer for the careful reading and for pointing out concrete directions along which the paper can be strengthened. The comments on attack coverage in particular gave us a clear target, and we have run a substantial new set of experiments in response.
W2 & W3: Broader evaluation across trigger types and attack paradigms
We thank the reviewer for raising attack diversity. Our original selection focused on attacks designed specifically against vision transformers, which is the setting our work targets, and we have extended the evaluation accordingly. On optimized global triggers we would first note that BadVision, already in the submission, uses one: its trigger is an optimized pattern covering the entire 336x336 image. We have also added five attacks: BadEncoder [1] and DRUPE [2] for self-supervised encoders, Label-Consistent [3] for clean labels, Low-Frequency [4] for frequency-domain triggers, and Blended-Optimized [5] as a second optimized global trigger. We attempted SSL-Backdoor [6] but could not reproduce it reliably within the rebuttal window; BadEncoder shares its setting and threat model, so we report it in its place.
Setup. For BadEncoder and DRUPE we follow the ViT protocol DRUPE specifies in its appendix (its main text covers only ResNet): we use Mugs [7] as the SSL algorithm, pretrain ViT-T on CIFAR-10, and set GTSRB as the downstream task. For Label-Consistent and Low-Frequency we reproduce the attacks from the implementations collected in BackdoorBench [8], with ViT-S trained and tested on Tiny-ImageNet. For Blended-Optimized we replace the "kitty" pattern with an optimized global trigger and train within the BadCLIP framework (CLIP ViT-B/32), evaluating on ImageNet-1K. Detection settings (iNaturalist, M=128) and baseline implementations are unchanged from the submitted version. Each cell reports TPR↑ / FPR↓ / AUC↑, where TPR and FPR are percentages and AUC is on [0,1]; best values are in bold, and "–" marks methods that output cluster labels rather than scores.
| Defense | BadEncoder | DRUPE | Low-Frequency | Label-Consistent | Blended-Optimized |
|---|---|---|---|---|---|
| TeCo | 54.91 / 62.29 / 0.37 | 48.10 / 65.79 / 0.35 | 99.60 / 62.38 / 0.52 | 66.80 / 56.99 / 0.57 | 12.12 / 29.67 / 0.42 |
| Scale-Up | 63.29 / 10.26 / 0.79 | 47.15 / 6.93 / 0.72 | 100.00 / 11.32 / 0.95 | 84.00 / 13.06 / 0.88 | 95.24 / 17.39 / 0.91 |
| PatchProc | 85.44 / 21.58 / 0.83 | 75.95 / 23.68 / 0.78 | 100.00 / 17.05 / 0.87 | 0.00 / 20.21 / 0.47 | 88.20 / 20.86 / 0.85 |
| DeDe | 99.21 / 23.13 / 0.97 | 97.94 / 27.37 / 0.91 | 0.00 / 30.33 / 0.00 | 78.60 / 25.52 / 0.83 | 73.44 / 23.98 / 0.81 |
| B-IDS | 96.04 / 17.12 / – | 95.09 / 22.11 / – | 0.00 / 26.00 / – | 14.60 / 25.47 / – | 44.96 / 12.78 / – |
| DetectViT | 99.37 / 5.33 / 0.99 | 95.57 / 4.42 / 0.99 | 93.40 / 7.11 / 0.97 | 94.00 / 6.52 / 0.97 | 99.08 / 0.64 / 1.00 |
Results. DetectViT attains the best value in most cells and, more importantly, is the only method that maintains AUC ≥ 0.97 across all five attacks; each baseline, by contrast, collapses on at least one of them. One result surprised us: DRUPE uses a patch trigger, yet its distribution-preserving objective suppresses inter-head consistency in pursuit of stealth and raises entropy variance instead, so it is detected almost entirely by the entropy variance score. This mirrors what we observe under adaptive attacks, where suppressing one signal induces the other. A trigger's visual form therefore does not reliably predict which signal will fire; the two signals are complementary, and their disjunctive combination is what makes the detection robust. We will state this more precisely and add all five attacks to the main results in the revised version of our paper.
W1: Attacks that target the classification head
We agree that attacks confined to the classification head are uncommon. However, TrojViT [9], one of the four attacks we already evaluate, is exactly such a case. The TrojViT paper specifies that " can be initialized as the weights of the last classification head layer", where denotes the Trojan weights it modifies. The choice is deliberate: TrojViT aims to implant the backdoor with as few bit flips as possible, and targets the classification layer because it contributes most directly to the output. Its released code correspondingly marks only the last layer as trainable while freezing the rest during Trojan insertion. It reaches 100% ASR while freezing the encoder, and successfully breaks embedding-based detectors, with DeDe and BackdoorIDS reaching only 50.20% and 5.00% TPR in our main results.
We thank the reviewer for catching this: the sentence at L42 was too broad, as if it described a whole attack family. We will rewrite it to say that embedding-based detectors degrade sharply when the backdoor is confined to the head, and name TrojViT explicitly as the instance we study.
W4: Relation to BYE [10] and Trojaned-BERT attention abnormality [11]
BYE [10] is in fact cited in our submission as [41], at L118 as a method requiring training data and at L145 for the attention-hijacking phenomenon. We agree the treatment was too thin for a work this closely related, and we will expand it. Three concrete differences:
- Deployment stage. BYE requires training data and operates during fine-tuning; DetectViT needs only a small OOD calibration set and runs at test time on third-party checkpoints.
- Trigger coverage. BYE identifies backdoors by attention collapsing onto a small region, which restricts it to patch-like triggers; our two complementary signals cover different trigger types, as the new Low-Frequency and Blended-Optimized results show.
- Perspective of the attention analysis. BYE examines the per-layer attention distribution averaged over heads and flags a backdoor when that distribution collapses onto a small region. We instead analyze the discrepancy between individual heads, measuring the abnormally high inter-head attention overlap and large inter-head variance in attention concentration caused by complete and partial attention hijacking, neither of which can be computed from head-averaged attention.
Regarding [11], it studies NLP and BERT rather than vision. We will add it to Related Work as early evidence that attention carries a backdoor signature, and position our contribution as the inter-head formulation in the ViT setting.
We thank the reviewer again for these suggestions, and welcome any further questions or discussion.
References
[1] BadEncoder: Backdoor attacks to pre-trained encoders in self-supervised learning. S&P 2022.
[2] Distribution preserving backdoor attack in self-supervised learning. S&P 2024.
[3] Label-consistent backdoor attacks. arXiv:1912.02771, 2019.
[4] Rethinking the backdoor attacks' triggers: A frequency perspective. ICCV 2021.
[5] Targeted backdoor attacks on deep learning systems using data poisoning. arXiv:1712.05526, 2017.
[6] Backdoor attacks on self-supervised learning. CVPR 2022.
[7] Mugs: A multi-granular self-supervised learning framework. arXiv:2203.14415, 2022.
[8] BackdoorBench: A comprehensive benchmark of backdoor learning. NeurIPS 2022.
[9] TrojViT: Trojan insertion in vision transformers. CVPR 2023.
[10] Backdoor cleaning without external guidance in MLLM fine-tuning. NeurIPS 2025.
[11] A study of the attention abnormality in trojaned BERTs. NAACL 2022.
Post-Rebuttal Assessment
Thank you for the detailed rebuttal and the additional experiments. The authors have partially addressed my concerns, particularly the most important one regarding global and frequency-domain triggers. The new results on Low-Frequency and Blended-Optimized attacks substantially strengthen the empirical evaluation.
In my view, including these core experiments on global triggers in the revised paper is essential for the work to be considered publishable. However, I still have concerns about the presentation and positioning of the paper. Given that the methodological novelty is relatively incremental, a careful and substantive comparison with closely related methods should be one of the central elements of the paper. The revised manuscript should clearly explain the conceptual and technical differences from prior work, rather than limiting the comparison primarily to empirical performance.
Overall, the rebuttal has improved my assessment, but it does not fully resolve my concerns. I am therefore willing to raise my score to Borderline Reject.
Clarifying Differences from Prior Work (to Reviewer DN52)
We thank the reviewer for the constructive engagement and for raising the score. Following the suggestion to compare with closely related methods conceptually, we highlight our core contribution below, followed by how it differs from prior work.
Our core contribution. To our knowledge, this is the first work to detect backdoors from the discrepancy between attention heads in a ViT. The observation behind it is that triggers hijack attention with different degrees of strength, and that this difference in strength leaves two distinct traces across heads: a strong, localised trigger drives all heads onto the same region and raises inter-head consistency, while a weak, diffuse trigger captures heads unevenly and raises the variance of attention concentration across them. Detecting a backdoor then becomes a question of how heads differ from one another, rather than of what any single attention map looks like.
1. Relative to other test-time detectors (TeCo, Scale-Up, PatchProc, BackdoorIDS). These methods reach a decision by generating many transformed copies of each test sample and examining how the model responds across them, which makes detection cost a multiple of inference cost. They also constrain the tasks they apply to: TeCo, Scale-Up, and PatchProc reason over predicted hard labels and therefore require a discrete label space, which does not exist for captioning, while BackdoorIDS needs repeated forward passes under progressive masking. Our method requires neither. It reads the attention weights of a single forward pass, which are already computed during inference, and needs no supervision from the downstream task, so it applies unchanged to classification and to open-ended generation.
2. Relative to attention-based detection (BYE). Beyond the fact that BYE operates during training while our method operates at test time, the perspective from which we analyse the attention map is substantively different. BYE flags a backdoor when the attention distribution of a layer becomes highly concentrated on a small region, a signature that a visually salient patch trigger produces and a stealthy one does not. We instead examine how heads diverge from each other, which captures both regimes: the salient case through inter-head consistency, and the stealthy case through inter-head entropy variance. This is what allows our method to detect Low-Frequency and blended-based attacks, where no single region dominates the attention map.
We will state these differences explicitly in Related Work. If any concerns remain, we would be glad if the reviewer could describe them further, so that we can address them fully within the discussion period.
- Rating
- 5/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 4/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes DetectViT, a test-time backdoor sample detection method tailored to Vision Transformers. The key observation is that backdoor triggers disrupt the normal balance between spatial diversity and attention concentration across multi-head attention mechanisms.
DetectViT employs two training-free statistical measures to identify two forms of attention hijacking. The Inter-Head Consistency Score detects complete attention hijacking, in which salient patch-based triggers cause multiple attention heads to collapse onto the same spatial region. The Inter-Head Entropy Variance Score detects partial attention hijacking, in which blended or global triggers induce substantial differences in attention concentration across heads.
Notably, the detection thresholds do not rely on training-set data; instead, they are calibrated using only a small number of clean OOD samples.
Strengths and weaknesses
The method relies solely on standard attention matrices and does not require training an auxiliary decoder, trigger inversion, or the construction of a large number of augmented inputs. This design is simple and computationally efficient, making it more practical for real-world test-time detection scenarios.
The two proposed statistics correspond to two distinct attack mechanisms, resulting in a conceptually coherent design with relatively strong interpretability.
However, the method calibrates detection thresholds using the three-sigma rule on clean OOD images, without sufficiently justifying why the score distributions of the calibration data and the target clean distribution should be well aligned. Table 3 already indicates that different OOD sources can lead to substantial fluctuations in the false positive rate, particularly for TrojViT. Therefore, the thresholding strategy appears overly empirical and may limit the robustness of the method in practice.
The representativeness of the evaluated attack settings also remains limited. Although the experiments cover four attacks involving patch-based and blended triggers across several model architectures, the paper acknowledges that the method cannot defend against OOD-as-trigger attacks. This limitation is not discussed in sufficient depth, particularly with respect to more challenging settings such as clean-label or semantic triggers and distributed multi-trigger attacks.
Questions
Q1: Why should calibration based on the three-sigma rule over clean OOD samples?
Q2: How would DetectViT perform against more challenging trigger settings, such as semantic triggers or distributed low-amplitude triggers?
Limitations
The method claims flexibility in using arbitrary OOD data for calibration; however, Table 3 suggests that the false positive rate is sensitive to the choice of calibration source.
Moreover, the proposed statistical thresholding strategy remains largely heuristic and lacks a principled justification for its robustness across different data distributions.
The claim of “negligible overhead” may also be overstated in optimized inference systems. In practical high-performance deployments, attention weights are often not retained during inference, and extracting or storing them may introduce non-trivial memory, bandwidth, and implementation overhead.
Final justification
Thank you for the detailed rebuttal and the additional experiments. The response has substantially addressed my main concerns, particularly regarding the calibration strategy and the coverage of more challenging attack settings. I also appreciate the clarification of the remaining limitations, including semantic triggers and the overhead of accessing attention weights in optimized implementations.
Overall, I believe the rebuttal strengthens the paper and sufficiently addresses my concerns. I will increase my rating to 5: Accept.
Formatting concerns
None.
1 comment
Rebuttal
Response to Reviewer TWph
We thank the reviewer for the careful reading and for the constructive comments on our threshold estimation, attack coverage, and overhead claim. All three point to real gaps, and we address them below.
Q1, W1, L1, L2: Why three-sigma calibration on clean OOD samples
We thank the reviewer for raising this. The rule rests on two assumptions worth checking explicitly: that clean scores are approximately Gaussian, and that OOD scores align with those of the target clean distribution. We have now verified both.
We plot histograms of both scores for clean test samples, OOD calibration samples, and backdoor samples on each attacked model, which speaks to both assumptions at once. All three populations are unimodal and roughly symmetric; clean and OOD samples overlap closely and show comparable spread, whereas backdoor samples are tightly concentrated in a few bins far from the other two. As images cannot be attached here, we report the underlying statistics instead. Throughout, the first three attacks use the consistency score and BadVision uses the entropy variance score, and we will include the plots themselves in the revised version of our paper.
Are the clean scores Gaussian? We ran a Shapiro-Wilk test on the clean scores and measured the fraction of samples falling within one, two, and three standard deviations of the mean. Deviations from the theoretical values are given in parentheses.
| 1-sigma | 2-sigma | 3-sigma | Shapiro W | |
|---|---|---|---|---|
| Theoretical | 68.27 | 95.45 | 99.73 | 1 |
| BadViT | 69.80 (+1.53) | 94.65 (-0.80) | 99.79 (+0.06) | 0.9890 (-0.0110) |
| TrojViT | 77.71 (+9.44) | 94.66 (-0.79) | 99.09 (-0.64) | 0.9179 (-0.0821) |
| BadCLIP | 69.06 (+0.79) | 95.21 (-0.24) | 99.61 (-0.12) | 0.9973 (-0.0027) |
| BadVision | 67.47 (-0.80) | 95.32 (-0.13) | 99.68 (-0.05) | 0.9968 (-0.0032) |
On BadViT, BadCLIP, and BadVision the clean scores are very close to Gaussian, with W near 1 and coverage matching theory at all three levels. TrojViT departs the most, at W = 0.9179, but the departure is concentrated at the peak rather than in the tails: 77.71% of its clean scores fall within one standard deviation against a theoretical 68.27%, meaning the distribution is more sharply concentrated around its mean than a Gaussian, which works in favour of detection. Its two- and three-sigma coverage stays close to theory, so the tail behaviour that the threshold actually depends on is unaffected.
Do the OOD scores align with the clean ones? The table below gives the mean and standard deviation of each population.
| Population | BadViT | TrojViT | BadCLIP | BadVision |
|---|---|---|---|---|
| OOD | 0.8712 / 0.0314 | 0.9319 / 0.0106 | 0.9007 / 0.0156 | 0.9167 / 0.1608 |
| Clean | 0.8749 / 0.0335 | 0.9391 / 0.0099 | 0.8827 / 0.0180 | 1.0390 / 0.1816 |
| Backdoor | 0.9997 / 0.0006 | 0.9870 / 0.0220 | 0.9982 / 0.0032 | 2.2662 / 0.3865 |
The clean and OOD distributions are close on every attack, differing by at most one clean standard deviation in mean and with comparable spread, while the backdoor mean sits 3.7 to 6.8 clean standard deviations away. A threshold calibrated on OOD data therefore transfers to clean data, and falls between the clean and backdoor populations in every case.
We also checked that the result does not hinge on the three-sigma rule itself, by re-deriving thresholds as the 99th percentile of the OOD scores:
| Rule | BadViT | TrojViT | BadCLIP | BadVision |
|---|---|---|---|---|
| Three-sigma | 100.00 / 1.58 / 1.00 | 90.80 / 5.94 / 0.95 | 100.00 / 0.17 / 1.00 | 96.00 / 3.00 / 0.99 |
| 99th percentile | 100.00 / 4.29 / 1.00 | 89.40 / 5.14 / 0.95 | 100.00 / 0.52 / 1.00 | 97.00 / 6.32 / 0.99 |
Each cell reports TPR / FPR / AUC. The two rules give essentially the same detection performance, indicating that what matters is the separability of the underlying scores rather than the particular estimator used to turn them into a threshold.
On the FPR variation across OOD sources, our analysis is as follows. It arises because an OOD source is never perfectly aligned with the deployment distribution, and this is a constraint shared by test-time detectors generally, all of which must fit a threshold from data they do not control. The variation is also bounded: across all seven OOD sources reported in the submission, DetectViT achieves a higher TPR than every baseline, while its FPR remains far below that of nearly all of them. What distinguishes it is the quality of the underlying signal: the AUC is threshold-free, and it stays at 0.95 or above on every attack and well above all baselines, meaning the two populations are genuinely well separated and any reasonable threshold lands between them. In deployment, a practitioner is also not restricted to public OOD data, and thresholds can be refined on samples collected from the deployment environment, which is inexpensive given that roughly 100 samples suffice for a stable estimate.
Q2, W2: More attack settings
We thank the reviewer for raising attack diversity, a point other reviewers raised as well. Our original selection focused on attacks designed specifically against vision transformers, which is the setting our work targets, and we have extended the evaluation accordingly. On distributed triggers we would first note that TrojViT, already in the submission, is a multi-trigger attack: its trigger consists of nine patches placed at different positions in the image, chosen adaptively for each input from the attention map. We have also added five attacks covering the remaining settings the reviewer names: BadEncoder [1] and DRUPE [2] for self-supervised encoders, Label-Consistent [3] for the clean-label case, and Low-Frequency [4] and Blended-Optimized [5] for distributed low-amplitude triggers spanning the whole image. Detection settings (iNaturalist, M=128) and baseline implementations are unchanged from the submitted version. Each cell reports TPR / FPR / AUC, best values in bold, "–" marks methods that output cluster labels rather than scores.
| Defense | BadEncoder | DRUPE | Low-Frequency | Label-Consistent | Blended-Optimized |
|---|---|---|---|---|---|
| TeCo | 54.91 / 62.29 / 0.37 | 48.10 / 65.79 / 0.35 | 99.60 / 62.38 / 0.52 | 66.80 / 56.99 / 0.57 | 12.12 / 29.67 / 0.42 |
| Scale-Up | 63.29 / 10.26 / 0.79 | 47.15 / 6.93 / 0.72 | 100.00 / 11.32 / 0.95 | 84.00 / 13.06 / 0.88 | 95.24 / 17.39 / 0.91 |
| PatchProc | 85.44 / 21.58 / 0.83 | 75.95 / 23.68 / 0.78 | 100.00 / 17.05 / 0.87 | 0.00 / 20.21 / 0.47 | 88.20 / 20.86 / 0.85 |
| DeDe | 99.21 / 23.13 / 0.97 | 97.94 / 27.37 / 0.91 | 0.00 / 30.33 / 0.00 | 78.60 / 25.52 / 0.83 | 73.44 / 23.98 / 0.81 |
| B-IDS | 96.04 / 17.12 / – | 95.09 / 22.11 / – | 0.00 / 26.00 / – | 14.60 / 25.47 / – | 44.96 / 12.78 / – |
| DetectViT | 99.37 / 5.33 / 0.99 | 95.57 / 4.42 / 0.99 | 93.40 / 7.11 / 0.97 | 94.00 / 6.52 / 0.97 | 99.08 / 0.64 / 1.00 |
DetectViT attains the best value in most cells and is the only method that maintains AUC ≥ 0.97 across all five attacks; each baseline collapses on at least one of them. Setup details: BadEncoder and DRUPE follow the ViT protocol DRUPE specifies in its appendix (Mugs [6] as the SSL algorithm, ViT-T pretrained on CIFAR-10, GTSRB downstream); Label-Consistent and Low-Frequency are reproduced from the implementations collected in BackdoorBench [7], with ViT-S on Tiny-ImageNet; Blended-Optimized replaces the "kitty" pattern with an optimized global trigger trained in the BadCLIP framework. These results and the analysis will be added to the revised version of our paper.
Semantic triggers and the OOD-as-trigger attacks noted in our limitations share the property that defeats our method: in both, the trigger is a natural image feature rather than a crafted pattern, so a poisoned input carries no attention anomaly to measure. We cannot detect either, and to our knowledge neither can existing test-time detectors. We will discuss them together in the limitations of our revised paper.
L3: Cost of accessing attention weights
We accept this correction. Our claim assumed attention weights are retained during inference, which does not hold when fused or memory-efficient kernels never write the full matrix; recovering it there would incur real memory and bandwidth costs. We will add this overhead to the paper as a limitation.
We thank the reviewer again for these suggestions, and welcome any further questions or discussion.
References
[1] BadEncoder: Backdoor attacks to pre-trained encoders in self-supervised learning. S&P 2022.
[2] Distribution preserving backdoor attack in self-supervised learning. S&P 2024.
[3] Label-consistent backdoor attacks. arXiv:1912.02771, 2019.
[4] Rethinking the backdoor attacks' triggers: A frequency perspective. ICCV 2021.
[5] Targeted backdoor attacks on deep learning systems using data poisoning. arXiv:1712.05526, 2017.
[6] Mugs: A multi-granular self-supervised learning framework. arXiv:2203.14415, 2022.
[7] BackdoorBench: A comprehensive benchmark of backdoor learning. NeurIPS 2022.
- Rating
- 5/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper proposes DetectViT, a test-time method for detecting backdoored inputs to Vision Transformers. The main idea is that backdoor triggers disturb the normal diversity across attention heads. The detector uses two simple signals: whether different heads attend to unusually similar regions, and whether the concentration of attention varies abnormally across heads. Thresholds are estimated from a small set of clean images from another dataset. I think the core idea is quite intuitive and interesting.
Strengths and weaknesses
- Strengths:
-
I like the high-level idea. Looking at internal attention behavior is a natural fit for ViTs, and it avoids relying on final labels or task-specific outputs.
-
The detector is simple and cheap. Since it reuses attention weights already computed during inference, the runtime overhead is much lower than methods that need many transformed copies of the same image.
- Weaknesses:
-
My main concern is the adaptive attack analysis. The paper tests adaptive training that penalizes the proposed detection scores, but this still feels somewhat narrow. A stronger attacker could try to make the trigger mimic clean attention behavior directly, for example, by matching the clean distribution of head overlap, entropy variance, or layer-wise attention profiles. It seems possible to train a backdoor whose attention heads look clean while the attack signal is stored elsewhere.
-
The evaluation is still limited in trigger diversity. Most experiments are on patch-style triggers, with only one blended-trigger case. I am not sure the same attention discrepancy would necessarily appear for style, frequency-domain, semantic, dynamic, or feature-space backdoors.
-
The calibration step is practical, but the false positive rate seems sensitive to which clean calibration set is used. The paper uses a three-sigma rule, but I did not see enough evidence that the clean attention scores are actually close to Gaussian. Is it simple to check this?
Questions
Q1. Can you check whether the scores follow Gaussian distributions?
Limitations
The main limitation is that the adaptive evaluation does not fully rule out clean-looking attention backdoors. The detector also depends on access to internal attention and on a small, clean calibration set, whose choice can affect false positives.
Formatting concerns
No major formatting concerns.
1 comment
Rebuttal
Response to Reviewer Hbcr
We thank the reviewer for the encouraging assessment of our core idea, and address the comments on adaptive attacks, trigger diversity, and threshold calibration below.
W1: A stronger adaptive attacker that mimics clean attention
We thank the reviewer for suggesting a stronger form of adaptive attack. Following that suggestion, we retrained each attack with an alignment objective rather than a penalty on the detection scores. Concretely, we add to the original attack loss a term measuring the distance between the signal value of each poisoned image and that of the same image without the trigger, applied to either or both signals. This drives the signal values of backdoor samples toward those of clean samples rather than minimising them. Pairing each poisoned image with its own clean counterpart is the strictest alignment variant we implemented, and the signals are computed exactly as at detection. The single-signal rows align the consistency score for the patch-based attacks and the entropy variance score for BadVision; the last row aligns both. Each cell reports TPR / FPR / ASR / CA, with CA for BadVision being the CIDEr score.
| Adaptive | BadViT | TrojViT | BadCLIP | BadVision |
|---|---|---|---|---|
| None | 100.00 / 1.58 / 100.00 / 83.04 | 90.80 / 5.94 / 100.00 / 85.17 | 100.00 / 0.17 / 99.99 / 61.39 | 96.00 / 3.00 / 99.00 / 85.40 |
| Single signal | 100.00 / 2.39 / 99.84 / 81.62 | 90.80 / 5.94 / 100.00 / 85.17 | 99.24 / 0.54 / 99.54 / 60.70 | 0.00 / 0.00 / 15.00 / 3.80 |
| Both signals | 0.00 / 0.00 / 100.00 / 14.39 | 90.80 / 5.94 / 100.00 / 85.17 | 0.88 / 0.59 / 16.90 / 61.37 | 0.00 / 0.00 / 0.00 / 2.50 |
The results mirror those of our original adaptive attack. On BadViT and BadCLIP, matching the consistency score alone does not evade detection: suppressing inter-head consistency inflates the entropy variance, and the second signal catches the sample. Matching both signals evades detection, but destroys either clean accuracy or the attack itself, with BadViT's CA dropping from 83.04 to 14.39 and BadCLIP's ASR from 99.99 to 16.90. On BadVision, matching the entropy variance alone already collapses both, taking CIDEr from 85.40 to 3.80 and ASR from 99.00 to 15.00. TrojViT is unchanged throughout, since it freezes the encoder and trains only the classification head, leaving the added loss nothing to act on. Taken together, an attacker can align its attention statistics with clean behaviour, but not while preserving both attack success and clean accuracy.
Q1, W3: Are the clean scores Gaussian, and how sensitive is calibration
We thank the reviewer for raising this. We plot histograms of both scores for clean, OOD, and backdoor samples on each attacked model, which speaks to both. All three populations are unimodal and roughly symmetric; clean and OOD samples overlap closely with comparable spread, whereas backdoor samples concentrate tightly in a few bins far from the other two. As images cannot be attached here, we report the underlying statistics, and will include the plots in the revised version of our paper. Throughout, the first three attacks use the consistency score and BadVision the entropy variance score.
Are the clean scores Gaussian? We ran a Shapiro-Wilk test on the clean scores and measured the fraction of samples within one, two, and three standard deviations of the mean. Deviations from theory are in parentheses.
| 1-sigma | 2-sigma | 3-sigma | Shapiro W | |
|---|---|---|---|---|
| Theory | 68.27 | 95.45 | 99.73 | 1 |
| BadViT | 69.80 (+1.53) | 94.65 (-0.80) | 99.79 (+0.06) | 0.9890 (-0.0110) |
| TrojViT | 77.71 (+9.44) | 94.66 (-0.79) | 99.09 (-0.64) | 0.9179 (-0.0821) |
| BadCLIP | 69.06 (+0.79) | 95.21 (-0.24) | 99.61 (-0.12) | 0.9973 (-0.0027) |
| BadVision | 67.47 (-0.80) | 95.32 (-0.13) | 99.68 (-0.05) | 0.9968 (-0.0032) |
On BadViT, BadCLIP, and BadVision the clean scores are close to Gaussian, with W near 1 and coverage matching theory at all levels. TrojViT departs the most, at W = 0.9179, but the departure sits at the peak rather than in the tails: 77.71% of its clean scores fall within one standard deviation against a theoretical 68.27%, so its distribution is more sharply concentrated than a Gaussian, which favours detection. Its two- and three-sigma coverage stays close to theory, so the tail behaviour the threshold depends on is unaffected.
Do the OOD scores align with the clean ones? The table below gives the mean and standard deviation of each population.
| Population | BadViT | TrojViT | BadCLIP | BadVision |
|---|---|---|---|---|
| OOD | 0.8712 / 0.0314 | 0.9319 / 0.0106 | 0.9007 / 0.0156 | 0.9167 / 0.1608 |
| Clean | 0.8749 / 0.0335 | 0.9391 / 0.0099 | 0.8827 / 0.0180 | 1.0390 / 0.1816 |
| Backdoor | 0.9997 / 0.0006 | 0.9870 / 0.0220 | 0.9982 / 0.0032 | 2.2662 / 0.3865 |
The clean and OOD distributions are close on every attack, differing by at most one clean standard deviation in mean and with comparable spread, while the backdoor mean sits 3.7 to 6.8 clean standard deviations away. A threshold calibrated on OOD data therefore transfers to clean data, and falls between the two populations in every case.
The result also does not depend on the rule itself: re-deriving thresholds as the 99th percentile of the OOD scores gives the following (TPR / FPR / AUC).
| Rule | BadViT | TrojViT | BadCLIP | BadVision |
|---|---|---|---|---|
| Three-sigma | 100.00 / 1.58 / 1.00 | 90.80 / 5.94 / 0.95 | 100.00 / 0.17 / 1.00 | 96.00 / 3.00 / 0.99 |
| 99th pct. | 100.00 / 4.29 / 1.00 | 89.40 / 5.14 / 0.95 | 100.00 / 0.52 / 1.00 | 97.00 / 6.32 / 0.99 |
The two rules give essentially the same performance, indicating that what matters is the separability of the scores rather than the estimator turning them into a threshold.
On the sensitivity of the false positive rate to the calibration source: it arises because an OOD source is never perfectly aligned with the deployment distribution, a constraint shared by test-time detectors generally, which must all fit thresholds from data they do not control. The variation is also bounded: across all seven OOD sources in the submission, DetectViT achieves a higher TPR than every baseline, with an FPR far below nearly all of them. What distinguishes it is the underlying signal: the AUC is threshold-free, stays at 0.95 or above on every attack, and is well above all baselines, so the two populations are well separated and any reasonable threshold falls between them. A practitioner is also not restricted to public OOD data, and can refine the threshold on samples from the deployment environment, which is inexpensive given that roughly 100 suffice.
W2: More attack settings
We thank the reviewer for raising trigger diversity, a point other reviewers raised as well. Our original selection focused on attacks designed specifically against vision transformers, which is the setting our work targets, and we have added five attacks: BadEncoder [1] and DRUPE [2] for self-supervised encoders, Label-Consistent [3] for the clean-label case, Low-Frequency [4] for frequency-domain triggers, and Blended-Optimized [5] for optimized global triggers. For BadEncoder and DRUPE we follow the ViT protocol in DRUPE's appendix (its main text covers only ResNet): Mugs [6] as the SSL algorithm, ViT-T pretrained on CIFAR-10, GTSRB downstream. Label-Consistent and Low-Frequency are reproduced from the implementations collected in BackdoorBench [7], with ViT-S on Tiny-ImageNet. Blended-Optimized replaces the "kitty" pattern with an optimized global trigger trained in the BadCLIP framework (CLIP ViT-B/32) and evaluated on ImageNet-1K. Detection settings (iNaturalist, M=128) and baseline implementations are unchanged from the submitted version. Each cell reports TPR / FPR / AUC, best in bold; "–" marks methods that output cluster labels rather than scores.
| Defense | BadEncoder | DRUPE | Low-Frequency | Label-Consistent | Blended-Optimized |
|---|---|---|---|---|---|
| TeCo | 54.91 / 62.29 / 0.37 | 48.10 / 65.79 / 0.35 | 99.60 / 62.38 / 0.52 | 66.80 / 56.99 / 0.57 | 12.12 / 29.67 / 0.42 |
| Scale-Up | 63.29 / 10.26 / 0.79 | 47.15 / 6.93 / 0.72 | 100.00 / 11.32 / 0.95 | 84.00 / 13.06 / 0.88 | 95.24 / 17.39 / 0.91 |
| PatchProc | 85.44 / 21.58 / 0.83 | 75.95 / 23.68 / 0.78 | 100.00 / 17.05 / 0.87 | 0.00 / 20.21 / 0.47 | 88.20 / 20.86 / 0.85 |
| DeDe | 99.21 / 23.13 / 0.97 | 97.94 / 27.37 / 0.91 | 0.00 / 30.33 / 0.00 | 78.60 / 25.52 / 0.83 | 73.44 / 23.98 / 0.81 |
| B-IDS | 96.04 / 17.12 / – | 95.09 / 22.11 / – | 0.00 / 26.00 / – | 14.60 / 25.47 / – | 44.96 / 12.78 / – |
| DetectViT | 99.37 / 5.33 / 0.99 | 95.57 / 4.42 / 0.99 | 93.40 / 7.11 / 0.97 | 94.00 / 6.52 / 0.97 | 99.08 / 0.64 / 1.00 |
DetectViT attains the best value in most cells and is the only method maintaining AUC ≥ 0.97 across all five attacks; each baseline collapses on at least one. The one case we should flag is semantic triggers, which share with the OOD-as-trigger attacks in our limitations the property defeating our method: the trigger is a natural image feature rather than a crafted pattern, so a poisoned input carries no attention anomaly to measure. To our knowledge this affects existing test-time detectors.
We thank the reviewer again, and welcome any further questions or discussion.
References
[1] BadEncoder: Backdoor attacks to pre-trained encoders in self-supervised learning. S&P 2022.
[2] Distribution preserving backdoor attack in self-supervised learning. S&P 2024.
[3] Label-consistent backdoor attacks. arXiv:1912.02771, 2019.
[4] Rethinking the backdoor attacks' triggers: A frequency perspective. ICCV 2021.
[5] Targeted backdoor attacks on deep learning systems using data poisoning. arXiv:1712.05526, 2017.
[6] Mugs: A multi-granular self-supervised learning framework. arXiv:2203.14415, 2022.
[7] BackdoorBench: A comprehensive benchmark of backdoor learning. NeurIPS 2022.
Comments on the paper
1 comment
Dear reviewers,
This submission received initial evaluations of (5, 4, 2). The authors have submitted their rebuttal.
Please discuss whether the rebuttal adequately addresses your concerns, and whether it changes your assessment. Thanks.
Best, AC
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Response to the Meta Review
Response to the Meta Review
We thank the AC for the careful meta review and the recommendation, and we thank all three reviewers for the time they invested. We are encouraged that our inter-head formulation was found simple, efficient, and effective across architectures and tasks, as well as intuitive, practical, and reasonably novel (@Hbcr, @TWph), and that the technical approach was appreciated, with agreement that backdoor defenses should be as black-box as possible (@DN52). We respond point by point to the weaknesses listed in the meta review below.
1. Limited attack diversity (@DN52, @TWph, @Hbcr). We added five attacks during the rebuttal: BadEncoder and DRUPE for self-supervised encoders, Label-Consistent for clean labels, Low-Frequency for frequency-domain triggers, and Blended-Optimized for optimized global triggers. DetectViT attains the best value in most cells and is the only method that keeps AUC at 0.97 or above across all five, while every baseline collapses on at least one. All five attacks will be moved into the main evaluation, which @DN52 identified in their response to our rebuttal as essential for the work to be considered publishable.
2. Three-sigma calibration (@TWph, @Hbcr). We plotted the score distributions of clean, OOD, and backdoor samples on each attacked model, and report the underlying statistics. On near-Gaussianity: a Shapiro-Wilk test and the fraction of samples within one, two, and three standard deviations both confirm that the clean scores are close to Gaussian. On OOD alignment: clean and OOD means differ by at most one clean standard deviation, whereas the backdoor mean sits 3.7 to 6.8 standard deviations away. Using the 99th percentile of the OOD scores instead gives essentially the same performance. Some sensitivity to the calibration source is unavoidable for any test-time detector, since calibration data can never align perfectly with test data, but our scores separate backdoor from clean samples far more sharply than the baselines, as reflected in the highest AUC across all attacks.
3. Claims about embedding-based defenses and related work (@DN52). We clarified that our claim concerned TrojViT, an attack that targets the classification head rather than the encoder, and we will make this point clearer in the paper. On related work, although BYE operates at training time and the Trojaned-BERT study addresses NLP, we will discuss these attention-based approaches in detail in Related Work rather than in the brief form they currently receive.
4. Adaptive attacks (@Hbcr). Following the suggestion for a stronger adaptive attacker, we retrained each attack with a loss aligning the signal values of backdoor samples with those of clean samples rather than merely penalising them. The attacker cannot achieve stealth and performance at the same time: aligning both signals drops BadViT's clean accuracy to 14.39 and BadCLIP's attack success rate to 16.90.
All analyses above, together with the new experiments, will be incorporated into the revised paper. We are grateful for the reviewers' engagement, which has materially improved both the evaluation and the positioning of the work.