Unmasking Backdoors: An Explainable Defense via Gradient-Attention Anomaly Scoring for Pre-trained Language Models
Anindya Sundar Das, Kangjie Chen, Monowar Bhuyan
Abstract
Pre-trained language models have achieved remarkable success across a wide range of natural language processing (NLP) tasks, particularly when fine-tuned on large, domain-relevant datasets. However, they remain vulnerable to backdoor attacks, where adversaries embed malicious behaviors using trigger patterns in the training data. These triggers remain dormant during normal usage, but, when activated, can cause targeted misclassifications. In this work, we investigate the internal behavior of backdoored pre-trained encoder-based language models, focusing on the consistent shift in attention and gradient attribution when processing poisoned inputs; where the trigger token dominates both attention and gradient signals, overriding the surrounding context. We propose an inference-time defense that constructs anomaly scores by combining token-level attention and gradient information. Extensive experiments on text classification tasks across diverse backdoor attack scenarios demonstrate that our method significantly reduces attack success rates compared to existing baselines. Furthermore, we provide an interpretability-driven analysis of the scoring mechanism, shedding light on trigger localization and the robustness of the proposed defense.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
Lineage
- Backdoor Attacks on Pre-trained Models by Layerwise Weight Poisoning cites Trojaning Attack on Neural Networks
- Backdoor Attacks on Pre-trained Models by Layerwise Weight Poisoning cites Weight Poisoning Attacks on Pretrained Models
- BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation Models cites Backdoor Attacks on Pre-trained Models by Layerwise Weight Poisoning
- BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation Models cites Weight Poisoning Attacks on Pretrained Models
- Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer cites Trojaning Attack on Neural Networks
- Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer cites Weight Poisoning Attacks on Pretrained Models
- Weight Poisoning Attacks on Pretrained Models cites Trojaning Attack on Neural Networks
Builds on17
- Trojaning Attack on Neural NetworksYingqi Liu, Shiqing Ma, Yousra Aafer, Wen-Chuan Lee et al.NDSS 2018 · 1,377 citations
- Weight Poisoning Attacks on Pretrained ModelsKeita Kurita, Paul Michel, Graham NeubigACL 2020 · 312 citations
- BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation ModelsKangjie Chen, Yuxian Meng, Xiaofei Sun, Shangwei Guo et al.ICLR 2022 · 133 citations
- Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style TransferFanchao Qi, Yangyi Chen, Xurui Zhang, Mukai Li et al.EMNLP 2021 · 114 citations
- Backdoor Attacks on Pre-trained Models by Layerwise Weight PoisoningLinyang Li, Demin Song, Xiaonan Li, Jiehang Zeng et al.EMNLP 2021 · 93 citations
Related papers
- Backdoor Pre-trained Models Can Transfer to AllLujia Shen, Shouling Ji, Xuhong Zhang, Jinfeng Li et al.CCS 2021 · 72 citations
- SAFER: A Controllable Safeguard for LLMs against Backdoor AttacksZirui Hu, Zheng Zhang, Yingjie Wang, Dacheng TaoACL Findings 2026
- When Backdoors Speak: Understanding LLM Backdoor Attacks Through Model-Generated ExplanationsHuaizhi Ge, Yiming Li, Qifan Wang, Yongfeng Zhang et al.ACL 2025
- Test-Time Attention Purification for Backdoored Large Vision Language ModelsZhifang Zhang, Bojun Yang, Shuo He, Weitong Chen et al.CVPR 2026 · 7 citations
- Defending against Insertion-based Textual Backdoor Attacks via AttributionJiazhao Li, Zhuofeng Wu, Wei Ping, Chaowei Xiao et al.ACL Findings 2023 · 11 citations
