Abstract
Vision Transformers (ViTs) are increasingly used in safety-critical applications, yet they remain vulnerable to backdoor attacks. This paper identifies a unique behavioral discrepancy between clean and backdoored data in ViTs when subjected to patch-level manipulations. We propose a defense mechanism based on PatchDrop and PatchShuffle that detects and mitigates both local and global backdoor triggers. Our method achieves high detection accuracy (TPR > 90%) and effectively sanitizes poisoned datasets with minimal impact on clean model performance.
Introduction
As Vision Transformers (ViTs) gain prominence in domains like autonomous driving, securing them against adversarial threats is crucial. Backdoor attacks involve poisoning training data to create a malicious association between a specific "trigger" and a target class. While CNN-based defenses exist, they often overlook the patch-based architecture of ViTs. This work explores how the discrete processing of image patches in ViTs can be leveraged to build a robust defense against various backdoor strategies, including local patch-based triggers (e.g., BadNets) and global blending-based triggers (e.g., WaNet).
Methodology: Patch Processing Defense
The proposed defense exploits the sensitivity of ViTs to patch disruptions. Two primary transformations are employed:
- PatchDrop: Randomly removing a subset of patches. This is particularly effective against local triggers, as removing the patch containing the trigger disrupts the malicious prediction.
- PatchShuffle: Randomly reordering patches. This targets global triggers. While shuffling destroys spatial logic for clean classification, global triggers often remain detectable by the model, creating a diagnostic signal.
The defense operates in two phases. In the Offline Phase, a small set of clean images is used to establish baseline prediction stability thresholds ($k_d$ and $k_s$). In the Inference Phase, incoming images are subjected to multiple trials of these transformations. If the prediction variance deviates significantly from the baseline, the sample is flagged as backdoored.
Experiments and Results
The defense was evaluated on CIFAR10, GTSRB, and TinyImageNet against attacks like BadNets, WaNet, and ReFool.
Key Insights
- ViT vs. CNN Robustness: ViTs are more robust to PatchDrop for clean data than CNNs. However, for backdoored data, PatchDrop reduces the Attack Success Rate (ASR) in ViTs much more rapidly.
- Global vs. Local Attention: Unlike CNNs that overfit to local textures, ViTs use global self-attention. Disrupting patches breaks the global context required for the ViT to recognize the trigger.
- Detection Performance: The method achieved a True Positive Rate (TPR) exceeding 90% and a True Negative Rate (TNR) above 95% for ViTs.
- Dataset Sanitization: The defense reduced ASR from near 100% to approximately 0.5% while maintaining clean accuracy within 1% of the original model.
Discussion and Limitations
While effective and computationally light, the defense requires a small set of clean samples (approx. 1,000) for threshold calibration. Additionally, the need for multiple inference trials per image introduces some computational overhead, which may impact real-time applications. Future work should explore adaptive attacks designed to bypass patch-processing defenses and investigate zero-knowledge thresholding.
Conclusion
Patch processing offers a simple yet powerful defense against backdoor attacks in Vision Transformers. By leveraging the inherent architectural properties of ViTs—specifically their response to patch dropping and shuffling—we can effectively detect and neutralize both local and global malicious triggers without the need for complex retraining.
Summary updated