Skip to content

Rethink Backdoor Robustness in Vision Transformers

Conference: ECCV 2026
Paper: ECCV Official
Code: https://github.com/PKU-ML/ViT_backdoor
Area: AI Safety
Keywords: Vision Transformer, Backdoor Attack, Backdoor Defense, Channel Activation, Adversarial Perturbation

TL;DR

This paper demonstrates that previous claims regarding Vision Transformers' susceptibility to backdoor attacks and vulnerability to defense collapse stem from flawed defense adaptations; after aligning optimizers and pruning granularity, standard attacks are easily neutralized, leading the authors to propose CAT—an enhanced attack that suppresses trigger channel activation discrepancies to bypass post-training defenses.

Background & Motivation

Vision Transformers (ViTs) have achieved remarkable success across foundational computer vision tasks, including visual classification, semantic segmentation, and generative models, powered by multi-head self-attention mechanisms and comprehensive long-range context modeling. However, as practitioners push to deploy ViTs in safety-critical production pipelines, trustworthiness and algorithmic integrity emerge as indispensable prerequisites. Backdoor attacks represent a particularly insidious vulnerability, where an adversary injects trigger patterns into a minor subset of training images and manipulates their corresponding labels. Consequently, the infected model maintains competitive classification fidelity on clean samples while reliably outputting a malicious target class whenever the predefined trigger pattern appears. In standard Convolutional Neural Networks (CNNs), years of security development have produced effective post-training defenses, such as fine-tuning and neuron pruning, capable of purging backdoor behavior at a minimal cost to clean accuracy.

Nevertheless, prominent recent studies investigating backdoor robustness in ViTs (notably BackdoorBench and BadViT) drew discouraging conclusions: existing backdoor attacks were reported to remain stubbornly persistent on ViTs, whereas standard defense routines ported from CNNs triggered catastrophic clean accuracy degradation or complete defense failure. This narrative fostered a widespread belief that ViTs are inherently less robust against backdoor attacks due to the absence of convolutional inductive biases. Yet, because standard backdoor poisoning mechanisms are predominantly model-agnostic, the stark disparity between CNN and ViT defenses warranted rigorous technical scrutiny: does this vulnerability truly reflect structural fragility in Transformers, or does it merely mirror improper benchmark configurations?

Scrutinizing the empirical pipelines reveals an overlooked procedural mismatch: early studies pioneering Transformers in vision coupled AdamW pretraining with SGD fine-tuning, leading subsequent backdoor defense implementations to blindly retain SGD during model purification, even though ViTs exhibit severe convergence instability when fine-tuned with SGD on small datasets. Concurrently, pruning-based defenses like ANP and AWM were directly transplanted by targeting Batch Normalization layers or applying unconstrained element-wise masks, which either miss the critical Transformer layers or cause severe overfitting. Core Idea: This work overturns the prevailing assumption of ViT backdoor vulnerability by establishing proper optimizer alignment and projection-level pruning, reveals that defenses succeed by capitalizing on prominent intermediate channel activation anomalies, and proposes the Channel Activation Attack (CAT) to suppress these activation disparities via dual-branch adversarial perturbations, seamlessly concealing backdoor triggers within clean feature distributions.

Method

Overall Architecture

The methodological framework comprises two complementary phases: first, calibrating post-training defenses for ViTs to rectify historical evaluation biases, and second, developing the Channel Activation Attack (CAT) to systematically circumvent these properly tuned defenses. The execution pipeline of CAT operates across three core stages: attaching lightweight backdoor discriminators and target classifiers to high-level representations in a surrogate ViT, generating trigger-bounded adversarial perturbations via projected gradient descent (PGD) to align intermediate activation profiles, and applying Random Masking of Perturbation (RMP) to guarantee cross-architecture transferability.

%%{init: {'flowchart': {'rankSpacing': 24, 'nodeSpacing': 28, 'padding': 6, 'wrappingWidth': 400}}}%%
flowchart TD
    A["Poisoned Training Samples<br/>x_p = (1-m)⊙x + m⊙t"] --> B["Defense Adaptation Calibration<br/>AdamW Optimizer + Linear Projection Pruning"]
    B --> C["Channel Activation Alignment<br/>Joint Adversarial Training with BD & TC"]
    C --> D["Random Masking of Perturbation RMP<br/>Patch-Level Dropout for Cross-Architecture Transfer"]
    D --> E["Concealed Poisoned Dataset<br/>Suppressed Intermediate Discrepancies Evading Defense"]

Key Designs

1. Defense Adaptation Calibration: Optimizer Alignment and Linear Projection Pruning

Targeting the widespread collapse of fine-tuning (FT) and adversarial pruning (ANP/AWM) observed in prior ViT evaluations, this design introduces structurally tailored adaptations. For fine-tuning-based defenses, while CNNs converge reliably under SGD, ViTs heavily rely on adaptive learning rates and weight decay dynamics. Retaining SGD during clean data purification causes clean accuracy (ACC) to plummet below 20%. Substituting SGD with AdamW alongside canonical data augmentations (Mixup and CutMix) restores benign accuracy above 95% while suppressing attack success rate (ASR) to near 1%. For pruning defenses, classical ANP targets normalization layers; however, ViTs omit convolutional batch normalization and place sparse LayerNorm blocks outside core representations, rendering ANP ineffective. Conversely, AWM's element-wise parameter masking overfits drastically due to ViT's extensive parameter scale. The authors resolve this dilemma by performing channel-level pruning across the linear projection matrices of multi-head self-attention and MLP blocks, achieving precise backdoor isolation with controlled parameter overhead.

2. Channel Activation Alignment: Dual-Branch Adversarial Perturbation Generation

The fundamental mechanism allowing fine-tuning and pruning to purify backdoor models is the presence of abnormal channel activation spikes induced by static triggers in deep representation layers. Inspecting per-channel activations before the MLP head reveals that poisoned inputs exhibit dramatic activation discrepancies compared to benign samples, which defenses exploit to selectively suppress or prune compromised pathways. To neutralize this defensive signal, CAT formulates trigger crafting as an intermediate feature camouflage objective. On the final \(n\) Transformer blocks (typically \(n=2\)), lightweight backdoor discriminators \(d_i(\cdot)\) (classifying trigger presence) and target classifiers \(f_i(\cdot)\) (mapping benign samples to ground truth and poisoned samples to the backdoor target class \(y_\text{tc}\)) are appended. The adversary then generates a bounded perturbation \(\delta\) over the trigger mask area by maximizing the combined objective:

\[\mathcal{L}(\mathbf{\delta}) = \sum_{i=L-n+1}^L \Big( (1-\gamma) \cdot \ell\big(d_i(\mathbf{g}_i(\mathbf{x} + \mathbf{m} \odot \mathbf{\delta})), y_\text{bd}\big) + \gamma \cdot \ell\big(f_i(\mathbf{g}_i(\mathbf{x} + \mathbf{m} \odot \mathbf{\delta})), y_\text{tc}\big) \Big)\]

where \(y_\text{bd}=1\) denotes poisoned instances, and \(\gamma \in [0, 1]\) balances feature camouflage against target label induction. The perturbation is iteratively updated via \(\ell_2\)-bounded Projected Gradient Descent (PGD):

\[\mathbf{\delta} \leftarrow \mathbf{m} \odot \Pi_\epsilon \Big( \mathbf{\delta} + \alpha \cdot \frac{\nabla_\mathbf{\delta} \mathcal{L}(\mathbf{\delta})}{\|\nabla_\mathbf{\delta} \mathcal{L}(\mathbf{\delta})\|_2} \Big)\]

This optimization actively dampens abnormal channel surges, forcing the poisoned representation to closely match benign distribution profiles and preventing defense mechanisms from detecting trigger features.

3. Random Masking of Perturbation: Cross-Architecture Patch Generalization

In pragmatic threat environments, attackers optimize perturbations on accessible white-box surrogate models (such as standard ViT-B), whereas downstream victim architectures vary across hierarchical models (Swin-B), cross-covariance transformers (XCiT-S), or configurations with different patch resolutions. Direct transfer of rigid, static perturbations causes significant efficacy attenuation due to divergent patch-splitting sensitivities. To overcome this limitation, Random Masking of Perturbation (RMP) is introduced during perturbation crafting. At each optimization step, the perturbation field is partitioned into fine-grained \(2 \times 2\) pixel sub-patches, and a preset fraction of sub-patches is randomly dropped out. This stochastic masking breaks spatial over-reliance on fixed token grids and simulates multi-scale occlusion patterns, compelling the perturbation to remain potent under disparate patch extraction schemes and substantially boosting black-box transferability across heterogeneous ViT variants.

Loss & Training

CAT operates entirely as an offline data enhancement routine without altering downstream victim training objectives. During surrogate model preparation, discriminators and classifiers are optimized using standard cross-entropy loss \(\ell\). In the perturbation synthesis phase, the \(\ell_2\) bound is constrained to \(\epsilon = 16/255\) with step size \(\alpha = 4/255\) over 10 PGD iterations, setting the trade-off coefficient to \(\gamma = 0.6\). The patch drop rate for RMP is configured to 0.1 for holistic triggers (Blend) and 0.05 for localized patches (BadNets). The resulting poisoned dataset is published for downstream training, where conventional cross-entropy fine-tuning inadvertently embeds an evasive, defense-resistant backdoor.

Key Experimental Results

Main Results

Main evaluations on CIFAR-10 systematically benchmark six representative backdoor attacks against properly adapted fine-tuning (FT with AdamW) and pruning (adapted ANP and AWM) across ViT-B, DeiT-S, Swin-B, CaiT-S, and XCiT-S backbones, demonstrating the defense-bypassing capabilities of CAT.

Attack Setup Target Model Defense Strategy Clean Accuracy ACC (%) Pre-Defense ASR (%) Post-Defense ASR (%) Attack Amplification
BadNets (Vanilla) ViT-B FT (AdamW) 95.14 100.00 0.72 Defense fully succeeds
BadNets + CAT (Ours) ViT-B FT (AdamW) 95.12 100.00 65.01 +64.29% ASR
BadNets (Vanilla) ViT-B ANP (Adapted) 94.26 100.00 1.34 Malicious neurons purged
BadNets + CAT (Ours) ViT-B ANP (Adapted) 94.18 100.00 51.09 +49.75% ASR
Blend (Vanilla) Swin-B FT (AdamW) 95.30 100.00 37.86 Noticeable purification
Blend + CAT (Ours) Swin-B FT (AdamW) 95.22 100.00 89.75 +51.89% ASR
SIG (Vanilla) DeiT-S AWM (Adapted) 94.58 84.77 3.30 Defense fully succeeds
SIG + CAT (Ours) DeiT-S AWM (Adapted) 94.45 88.28 13.81 +10.51% ASR
BadNets (Vanilla) ViT-B AWM (Adapted) 95.02 100.00 0.71 Defense fully succeeds
BadNets + CAT (Ours) ViT-B AWM (Adapted) 94.95 100.00 6.78 Elevated evasion rate

On the ImageNet benchmark, evaluations against ViT-specific attacks (TrojViT, DBIA, BadViT) demonstrate that existing specialized attacks collapse against adapted general defenses (ASR dropping below 10%, e.g., TrojViT yielding 0.12% under FT), whereas combining BadNets with CAT preserves an 81.98% ASR against adapted AWM (compared to 24.32% for vanilla BadNets).

Ablation Study

The ablation analysis on CIFAR-10 isolates the individual and joint impacts of Perturbation Attack (PA) and Random Masking of Perturbation (RMP) on ViT-B and Swin-B under Fine-Pruning (FP), alongside visual imperceptibility metrics (PSNR and SSIM).

Model & Config Core Mechanisms Post-FP ASR (%) Gain Δ PSNR (dB) SSIM
ViT-B (Baseline) Vanilla BadNets Trigger 0.91 Baseline 25.63 0.9997
ViT-B (w/o RMP) Perturbation Attack Only (PA) 14.54 +13.63% 58.86 0.9999
ViT-B (Full CAT) Complete Model (PA + RMP) 27.90 +26.99% 58.86 0.9999
Swin-B (Baseline) Vanilla BadNets Trigger 11.49 Baseline 25.63 0.9997
Swin-B (Full CAT) Complete Model (PA + RMP) 19.52 +8.03% 58.86 0.9999
Baseline Blend Spatial Blending Trigger - - 22.26 0.7696
Baseline SSBA Sample-Specific Invisible Trigger - - 25.39 0.8891

Key Findings

  • Synergistic Mechanism Integration: Applying PA alone suppresses activation spikes to reduce pruning vulnerability (+13.63% ASR), but encounters cross-architecture barriers; integrating RMP propels ASR to 27.90%, confirming the importance of stochastic patch dropout for structural generalization.
  • Budget and Trade-Off Thresholds: The perturbation bound exhibits an optimal trade-off at \(\epsilon = 16/255\); weaker budgets fail to mask activation gaps, while excessive budgets (\(\epsilon > 16/255\)) erode trigger semantics and degrade attack retention. Setting \(\gamma = 0.6\) balances discriminator deception with target label alignment.
  • Superlative Visual Fidelity: Constrained by a strict \(\ell_2\) bound, CAT achieves a PSNR of 58.86 dB and SSIM of 0.9999 relative to raw poisoned images, eliminating perceptible artifacts and surpassing sample-specific triggers like SSBA.

Highlights & Insights

  • Methodological Correction of Benchmark Flaws: Resolves the misconception that ViTs are innately fragile against backdoors, showing that previous defense breakdowns resulted from mismatched optimizers and misplaced pruning targets.
  • Internal Feature Space Camouflage: Uncovers the core reliance of pruning and fine-tuning on activation statistics, advancing backdoor concealment from outward visual stealth to internal latent representation alignment.
  • Negligible Computational Overhead: CAT perturbations are synthesized offline within minutes on a single GPU (under 4 minutes across ImageNet), offering seamless black-box transferability to diverse downstream Vision Transformers.

Limitations & Future Work

  • Surrogate Model Dependency: Crafting effective perturbations requires backpropagation access to a representative white-box ViT surrogate, whose transferability across completely disparate hybrid architectures warrants further investigation.
  • Evolution of Defense Paradigms: Future defenses shifting from activation statistics toward attention rollouts or causal representation disentanglement could potentially detect the subtle alignment induced by CAT.
  • Future Directions: Exploring unsupervised manifold-smoothing techniques that dispense with explicit discriminator training, and generalizing channel activation alignment to multimodal vision-language models and diffusion architectures.
  • vs BackdoorBench / BadViT: Earlier benchmarks reported severe ViT defense collapse under SGD fine-tuning and norm-layer pruning; this paper rectifies these oversights, proving that properly adapted AdamW and projection pruning reliably suppress vanilla backdoor ASR to near 1%.
  • vs TrojViT / DBIA: Prior ViT-tailored attacks engineered complex attention-specific triggers; this paper reveals they remain defenseless against adapted general defenses (ASR < 0.5%), whereas CAT achieves robust defense resistance by directly reconciling internal channel activations.

Rating

  • Novelty: ⭐⭐⭐⭐☆ Pinpoints critical benchmarking oversights and introduces channel-level activation alignment to outmaneuver defenses.
  • Experimental Thoroughness: ⭐⭐⭐⭐⭐ Rigorously covers 5 ViT families, 6 attack paradigms, 7 defense pipelines, and large-scale ImageNet validation.
  • Writing Quality: ⭐⭐⭐⭐⭐ Well-structured narrative transitioning clearly from bias correction to mechanistic discovery and attack formulation.
  • Value: ⭐⭐⭐⭐⭐ Dispels prominent misconceptions regarding Vision Transformer backdoor robustness and provides an authoritative evaluation foundation.