Abstract
Vision Transformers (ViT) have recently demonstrated exemplary performance on a variety of vision tasks and are being used as an alternative to CNNs. Their design is based on a self-attention mechanism that processes images as a sequence of patches, which is quite different compared to CNNs. Hence it is interesting to study if ViTs are vulnerable to backdoor attacks. Backdoor attacks happen when an attacker poisons a small part of the training data for malicious purposes. The model performance is good on clean test images, but the attacker can manipulate the decision of the model by showing the trigger at test time. To the best of our knowledge, we are the first to show that ViTs are vulnerable to backdoor attacks. We also find an intriguing difference between ViTs and CNNs - interpretation algorithms effectively highlight the trigger on test images for ViTs but not for CNNs. Based on this observation, we propose a test-time image blocking defense for ViTs which reduces the attack success rate by a large margin.
Introduction
As Vision Transformers (ViTs) begin to replace Convolutional Neural Networks (CNNs) in high-stakes applications like autonomous driving, their security becomes a critical concern. One of the most insidious threats is the backdoor attack. In such an attack, an adversary "poisons" a tiny fraction of the training data. The resulting model performs perfectly on normal images but misclassifies any image containing a specific "trigger" (like a small digital patch).
While these attacks are well-documented for CNNs, this research investigates whether the unique architecture of ViTs—which relies on global self-attention rather than local convolutions—changes the vulnerability landscape. The study reveals that while ViTs are just as vulnerable to backdoor attacks as traditional CNNs, they possess a unique "tell": their internal attention mechanisms naturally highlight malicious triggers at test time.
Methods
The authors evaluate ViTs against two primary attack types:
- BadNets: A "dirty label" attack where triggers are visible in the training data and labels are intentionally corrupted.
- Hidden Trigger Backdoor Attacks (HTBA): A sophisticated "clean label" attack. Poisoned training images look normal and are labeled correctly but are mathematically optimized to "collide" with the features of a triggered image in the model's latent space.
To defend against these, the authors leverage Interpretation Maps (specifically GradRollout for ViTs). These algorithms visualize which parts of an image the model prioritizes for its decision. The proposed defense, Test-Time Image Blocking, involves generating an interpretation map for a test image, identifying the region of highest influence, and applying a black mask (a "blocking patch") over that region before re-running classification.
Datasets
The study utilizes the ImageNet dataset. The authors generated 600 poisoned images for various source-target class pairs (e.g., misclassifying a "Mountain Bike" as an "iPod"), representing a mere 0.05% of the total dataset.
Key Insights and Results
The most striking discovery is the "tell" of the Transformer. In CNNs, interpretation maps like Grad-CAM often fail to localize a backdoor trigger. Conversely, in ViTs, the GradRollout map consistently and sharply highlights the trigger patch, even if the model never saw that specific trigger during training (as in HTBA).
Because ViTs treat an image as a sequence of patches and learn global relationships, they seem to isolate the malicious trigger as a distinct, highly influential "token." This localization allows the image blocking defense to be highly effective:
- Vulnerability: Without defense, a ViT-Base model under an HTBA attack showed an Attack Success Rate (ASR) of 61.4%.
- Defense Efficacy: The proposed image blocking defense slashed the ViT-Base ASR from 61.4% down to 16.4%.
- CNN Comparison: The same defense is largely ineffective for CNNs. A ResNet50's ASR only moved from 34.8% to 37.2% because the interpretation maps could not accurately find the trigger to block it.
Limitations and Future Work
The defense currently assumes the defender knows the approximate size of the potential trigger to choose the right size for the blocking mask. Additionally, the defense requires two forward passes, doubling inference time. Future work may explore adaptive attacks where an adversary attempts to "hide" the trigger from interpretation maps.
Summary updated