Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
DetectViT — Training-free, trigger-agnostic test-time detector for backdoored Vision Transformers that flags poisoned samples using inter-head attention consistency and entropy variance. | Kitploit
Tools/GitHubGitHub/siquanhuang/detectvit
Defensive ToolsMachine LearningPapers & ResearchAI SecurityAnomaly Detection
GitHubsiquanhuang/detectvit

DetectViT

Training-free, trigger-agnostic test-time detector for backdoored Vision Transformers that flags poisoned samples using inter-head attention consistency and entropy variance.

View Repository
192 days agoNot yet reviewed
Share

DetectViT: Test-time Backdoor Detection for Vision Transformers via Inter-Head Attention Discrepancy

Siquan Huang1, Yijiang Li2, Xingfu Yan3,*, Ningzhi Gao1, Leyu Shi1, Ying Gao1,*

1South China University of Technology   2University of California, San Diego   3South China Normal University

*Corresponding authors

NeurIPS 2026 Paper Poster License


Overview

Vision Transformers (ViTs) are the visual encoder of most multimodal models, and practitioners routinely build on third-party pretrained checkpoints that may carry a backdoor. DetectViT is a test-time backdoor sample detector for ViTs that reads the attention heads instead of the model's outputs or embeddings.

  • Training-free. No access to training data and no auxiliary model to train.
  • Output-free. Works for both classification and open-ended generation (e.g. image captioning with LLaVA).
  • Trigger-agnostic. No prior knowledge of the trigger type is required.
  • Lightweight. One forward pass per test sample; detection reuses attention weights already computed during inference.

Key observation

On clean images, attention heads attend to different regions with comparable concentration. Backdoor triggers break this balance in two ways:

  • Complete attention hijacking. A visible, localized trigger pulls all heads onto the same region, producing abnormally high inter-head spatial overlap.
  • Partial attention hijacking. A stealthy, global trigger captures heads unevenly, producing an abnormally large variance in attention concentration across heads.

CLS-to-patch attention of six heads for a clean image, an image with a visible patch trigger (complete hijacking), and an image with a stealthy blended trigger (partial hijacking)

Method

DetectViT pipeline

DetectViT extracts the CLS-to-patch attention distribution of every head and computes two complementary signals:

  • Inter-Head Consistency Score $\mathcal{S}_{\text{cons}}$: the mean pairwise cosine similarity between the heads of a layer (max over layers). It captures complete hijacking.
  • Inter-Head Entropy Variance Score $\mathcal{S}_{\text{var}}$: the variance of per-head attention entropy within a layer (max over layers). It captures partial hijacking.

Thresholds are estimated with the three-sigma rule, $\tau = \mu + 3\sigma$, from only 64 to 128 clean out-of-distribution images of any source. A test sample is flagged as backdoored if $\mathcal{S}{\text{cons}} > \tau{\text{cons}}$ or $\mathcal{S}{\text{var}} > \tau{\text{var}}$.


Main Results

Detection performance on four ViT backdoor attacks. TPR and FPR are in %, AUC is on a [0, 1] scale. "–" means the method is not applicable (label-based methods cannot handle free-form captions) or does not produce a continuous score.

DefenseBadViT
TPR↑ / FPR↓ / AUC↑
TrojViT
TPR↑ / FPR↓ / AUC↑
BadCLIP
TPR↑ / FPR↓ / AUC↑
BadVision
TPR↑ / FPR↓ / AUC↑
TeCo77.95 / 61.86 / 0.6355.00 / 51.76 / 0.5199.20 / 39.52 / 0.89–
Scale-Up88.65 / 30.66 / 0.8185.00 / 41.98 / 0.7491.84 / 65.03 / 0.66–
PatchProc90.61 / 18.42 / 0.8987.60 / 21.44 / 0.8586.97 / 26.78 / 0.82–
DeDe63.97 / 23.29 / 0.7850.20 / 25.80 / 0.7255.12 / 27.97 / 0.697.00 / 29.68 / 0.50
BackdoorIDS80.79 / 9.73 / –5.00 / 10.84 / –93.24 / 16.88 / –96.00 / 15.96 / –
DetectViT100.00 / 1.58 / 1.0090.80 / 5.94 / 0.95100.00 / 0.17 / 1.0096.00 / 3.00 / 0.99

Additional attacks. On five further attacks covering self-supervised encoders (BadEncoder, DRUPE), clean-label poisoning (Label-Consistent), frequency-domain triggers (Low-Frequency) and optimized global triggers (Blended-Optimized), DetectViT is the only method that keeps an AUC of at least 0.97 on all of them. Full results are in the appendix of the paper.

Runtime. Average per-sample detection time (s):

DefenseBadViTTrojViTBadCLIPBadVision
TeCo2.50944.29201.8448–
Scale-Up0.02460.02610.0696–
PatchProc0.66860.69260.8257–
DeDe0.02060.02790.10340.6060
BackdoorIDS0.17340.19820.25603.3458
DetectViT0.01240.01340.01630.0226

Poster

DetectViT NeurIPS 2026 poster

Click the image to open the full-resolution PDF.


Installation

git clone https://github.com/siquanhuang/DetectViT.git
cd DetectViT

Prerequisites

  • Python 3.10.5
  • PyTorch 2.1.2
  • CUDA 11.8

Pretrained Attack Models & Triggers

Download the pretrained backdoored model checkpoints and optimized triggers from Google Drive:

[Google Drive Link]


Usage

The detection method is implemented in detectvit.py. Run main.py to evaluate DetectViT against each attack.

BadViT

python3 main.py \
  --defense DetectViT \
  --attack_type badvit \
  --trojvit_attack_dir TrojViT/logs/Caltech101_DeiT-T_target0_BadViT \
  --trojvit_network DeiT-T \
  --trojvit_num_classes 102 \
  --trojvit_data_dir ./data

TrojViT

python3 main.py \
  --defense DetectViT \
  --attack_type trojvit \
  --trojvit_attack_dir TrojViT/logs/Tiny-ImageNet_DeiT-S_target2_TrojViT \
  --trojvit_data_dir ./data/tiny-imagenet-200 \
  --trojvit_network DeiT-S \
  --gpu 0

BadCLIP

python3 -u main.py \
  --defense DetectViT \
  --attack_type badclip \
  --gpu 0 \
  --eval_data_type ImageNet1K \
  --eval_test_data_dir BadCLIP/data/ImageNet1K/validation/ \
  --add_backdoor \
  --asr \
  --label banana \
  --patch_type ours_tnature \
  --patch_location middle \
  --patch_name BadCLIP/opti_patches/tnature_eda_bs64_ep50_32_middle_01_05_pos_neg.jpg \
  --patch_size 32

BadVision

python3 -u main.py \
  --defense DetectViT \
  --attack_type badvision \
  --gpu 0

Key Arguments

ArgumentDescriptionDefault
--defenseDetection method (DetectViT, DeDe, BackdoorIDS, ...)DetectViT
--attack_typeAttack to evaluate (badvit, trojvit, badclip, badvision)—
--gpuGPU device ID0

Citation

If you find this work useful, please consider citing our paper.

Download Tool

Most Popular

View all →

Discover the most used tools by our community.

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 The ultimate OSINT toolkit: investigation graph, confidence scoring, alias families, map, timeline and reports. 49 modules, 400+ sites, no API keys required.

    1.1k
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock One-Tap Execution App (CVE-2026-43499)

    618
  • 3

    looking-glass

    anonghosty/looking-glass

    CSIRT platform that ingests Shadowserver reports into MongoDB and replays them as interactive maps, analysis, findings, advisories and executive dashboards.

    411
  • 4

    ARTEX

    baarai/artex

    LLM multi-agent autonomous penetration testing platform with planner/worker agents, asset and exploration graphs, MITM traffic recording, and vulnerability retesting.

    328
  • 5

    jumpserver

    jumpserver/jumpserver

    JumpServer is an open-source Privileged Access Management (PAM) platform that provides DevOps and IT teams with on-demand and secure access to SSH, RDP, Kubernetes, Database and RemoteApp endpoints through a web browser.

    314
  • 6

    Aliens_eye

    arxhr007/aliens_eye

    AI powered OSINT engine to discover and map 7,700+ social media identities across the web

    275

Explore all tools

Browse our collection of tools

View all tools →