Abstract
Trojan (backdoor) attacks pose a significant security risk to Transformer models, where hidden triggers induce malicious behaviors. This paper identifies "Attention Hijacking" as a universal signature of these attacks across both Natural Language Processing (NLP) and Computer Vision (CV) domains. By analyzing internal attention mechanisms, the authors developed the Attention-Hijacking Trojan Detector (AHTD), achieving near-perfect detection accuracy across diverse datasets.
Introduction
Trojan attacks involve injecting a "trapdoor" into a model during training that remains dormant until a specific trigger—such as a specific word or a pixel pattern—is encountered. While extensively studied in Convolutional Neural Networks (CNNs), the vulnerability of Transformers like BERT and ViT is less understood. Furthermore, the fundamental differences between text and images have historically made it difficult to create a unified defense. This research seeks a universal diagnostic pattern to identify compromised Transformers regardless of the input modality.
Methodology: The Attention Hijacking Phenomenon
The core discovery of this research is Attention Hijacking, a phenomenon where specific attention heads in a compromised model "kidnap" weights when a trigger is present. These "hijacker" heads ignore the contextual input and focus almost exclusively on the trigger token or patch.
To detect this behavior, the authors propose the AHTD (Attention-Hijacking Trojan Detector) framework, which operates in two stages:
- Outlier Filter: This stage identifies potential triggers by searching for inputs that cause the model to misclassify with high confidence.
- Feature Extraction & Discrimination: The detector analyzes the attention maps of the model when processing these potential triggers. If it identifies the hijacking signature—characterized by high attention concentration on specific tokens across multiple heads—it flags the model as Trojaned.
Key Insights: Depth and Causality
A critical finding is that hijacking is not uniform across the model's architecture. It is significantly more prevalent in the deeper layers of the Transformer, suggesting that the malicious features are embedded late in the processing pipeline to override the legitimate features learned in earlier layers.
Furthermore, the researchers established a causal link between these heads and the malicious behavior. By manually deactivating the identified hijacking heads, the Attack Success Rate (ASR) plummeted while the model's performance on clean data remained largely intact. This proves that these specific heads are the primary drivers of the Trojan behavior.
Experimental Results
The AHTD was evaluated on five benchmark datasets, including IMDB, YELP, SST-2 for NLP, and MNIST, CIFAR-10 for CV.
- Detection Performance: AHTD achieved ACC and AUC scores between 0.94 and 0.99, significantly outperforming baselines like Neural Cleanse and T-Miner, which often struggled to reach 0.70 accuracy on Transformer architectures.
- Population Gap: A massive gap was observed between clean and Trojan models. Clean models typically exhibit 0.05 to 2.1 hijacking heads, whereas Trojaned models show a jump to between 6 and 21 heads, providing a clear and robust threshold for detection.
Conclusion and Future Work
Attention Hijacking serves as a "smoking gun" for Trojan Transformers, revealing a vulnerability inherent to the Transformer architecture itself. While AHTD is highly effective, it currently requires "white-box" access to internal weights. Future research will focus on developing "black-box" detection methods and investigating why language models appear to have higher redundancy or more complex inter-dependencies when hijacking heads are deactivated.
Summary updated