Backdoor Directions in Vision Transformers Exposes Hidden Triggers With a Simple Weight Edit
Researchers borrow a trick from LLM interpretability to locate, disable, and even detect hidden backdoors implanted in Vision Transformers.
ProTakeaways
- ViT backdoors are mediated by a single linear direction in the residual stream, found by averaging clean-vs-poisoned activation differences.
- Orthogonalizing this direction from weight matrices drops attack success from 97.7% to 6.7% while preserving clean accuracy at 82%.
- Static-patch triggers activate early via all-token features; stealthy triggers like WaNet concentrate in the CLS token.
- Tested across CIFAR-10/100, Tiny-ImageNet, ViT-B-16, DeiT-S, and Swin-S using BackdoorBench models.
- PGD adversarial attacks on backdoored inputs internally reverse the trigger direction, explaining why they need more steps.
- Data-free weight-based detector runs in ~1 minute, catches stealthy attacks but fails on visible patch triggers.
The idea that transformer language models encode concepts along single directions in their activation space has driven a wave of mechanistic interpretability work, from refusal steering to bias correction. A new paper called Backdoor Directions in Vision Transformers ports that idea to computer vision security, showing that when a Vision Transformer is poisoned with a hidden trigger, the trigger lives along a single, findable linear direction in the residual stream. Editing that direction out of the weights largely removes the backdoor.
Why ViTs need their own defenses
Backdoor attacks work by corrupting a small fraction of training data with inputs containing a specific trigger, so the model misclassifies any input carrying that trigger to a target class. Convolutional networks have a mature toolkit of defenses, but while these defenses work well for convolutional models, their performance decreases significantly when deployed for Vision Transformer models. Existing ViT-specific defenses lean on spotting anomalous attention patterns, which fails against distributed, stealthy triggers like warping or bit-plane perturbations.
The authors argue the field's difficulty designing robust ViT defenses stems from a limited understanding of how these networks internally represent trigger features. Their fix is to treat backdoored models the way interpretability researchers treat LLMs: find the feature direction, then intervene on it.
Finding the trigger direction
The recipe is unusually simple. Given a clean image x and its poisoned counterpart x_t, compute the difference of their activations at each transformer layer, then average across many pairs. That mean difference vector r^l is the backdoor direction at layer l. The authors define two variants: one using only the [CLS] token, and one concatenating every token in the sequence.

To prove this direction is causal rather than correlational, the paper runs two interventions:
- Activation steering. Add
r^lto a clean image's residual stream to try to trigger the backdoor, or subtract it from a poisoned image to try to suppress it. Report attack success rate (ASR) and recovered accuracy (RA). - Weight orthogonalization. Rewrite every attention and MLP output projection as
W_new = W - r r^T W, permanently removing that direction's ability to write into the residual stream.
What the numbers say
The experiments cover ViT-B-16 models from BackdoorBench across CIFAR-10, CIFAR-100, and Tiny-ImageNet, at poisoning rates of 0.01, 0.05, and 0.1. Attacks include BadNet, Blended, TrojanNN, WaNet, SSBA, BPP, and InputAware. Averaged across 33 backdoored models, the baseline attack success rate sits at 97.7 percent. After orthogonalizing the backdoor direction out of the weights, ASR drops to 6.7 percent while clean accuracy holds at 82 percent, roughly matching the 82.8 percent baseline. Steering with just the CLS-token vector is less consistent, moving ASR to 67.6 percent on clean inputs, suggesting the effect is real but sensitive to which layer and scaling factor you pick.
Layer-wise steering reveals a split personality between attack families. For static-patch attacks like BadNet and TrojanNN, the all-token vector works from the earliest layers because different image patches contain different pieces of the trigger, so the model needs position-dependent detection. For stealthy attacks like WaNet, SSBA, and BPP, small perturbations exist in every patch, so the CLS-token direction becomes effective in relatively early layers. The authors verify this pattern also holds on DeiT-S and Swin-S variants.
Connecting adversarial examples to backdoors
Prior work observed that PGD-based adversarial attacks behave differently on backdoored models: perturbations of clean images disproportionately land on the target class, and perturbations of backdoored images tend to revert to the original label. The authors use their backdoor direction as a probe to test whether adversarial perturbations actually travel along the trigger's internal circuit.
The answer depends on the attack. For stealthy triggers like WaNet and BPP, the difference vectors between clean and adversarially perturbed images have high cosine similarity with the backdoor direction in middle layers, meaning PGD is genuinely exploiting the trigger feature. For visible patch triggers like BadNet, similarity is low, so PGD flips predictions through unrelated non-robust features. Starting from backdoored images, PGD consistently produces vectors with strong negative cosine similarity to the backdoor direction, meaning it reverses the trigger's internal signal, which explains why more PGD steps are needed to fool backdoored inputs.
A data-free detection scheme
The most practical contribution is a weight-only detector that needs no clean data and runs in about a minute per model. For each class, the method measures how strongly the classifier head's readout direction aligns with the early-layer weight matrices, then computes a Z-score to flag any class whose alignment score is an outlier. It works well on stealthy attacks, catching WaNet and BPP reliably, treats SSBA as a borderline case, and fails on patch-based attacks like TrojanNN. The tradeoff is deliberate: existing attention-based ViT defenses already catch patch triggers well but stumble on stealthy ones, so this scheme fills a genuine gap.
What this means in practice
The full analysis assumes the defender knows the trigger, which is unrealistic outside research. That limits the causal-intervention pipeline to controlled settings, red-team evaluations, and post-mortems on suspected poisoned models. But the paper reframes backdoors as an unusually clean benchmark for mechanistic interpretability: the target feature and its behavioral effect are both crisply defined, unlike fuzzy concepts like refusal or bias. The weight-based detector is deployable today for ViT pipelines that fine-tune on data of uncertain provenance, especially since confirming that linear feature representations also hold for backdoor attacks in ViTs is a natural extension of prior work on linear directions in language and vision-language models.
The natural next step, which the authors flag as future work, is automating trigger discovery so the orthogonalization defense can run without prior knowledge, possibly by adapting automated circuit discovery tools from LLM interpretability. If that works, ViT backdoor removal becomes a lightweight, one-shot weight edit rather than the retraining-heavy defenses currently on offer.