Test-Time Adaptation for Backdoor Defense

Jiyang Guan, Jian Liang, Ran He · OpenReview

Abstract

Deep neural networks are vulnerable to backdoor attacks where malicious triggers cause misclassification during inference. Traditional defenses often require access to the original training set or extensive clean data, which is impractical for users of third-party pre-trained models. This paper introduces Test-Time Backdoor Defense (TTBD), a novel framework that detects and mitigates backdoors on-the-fly using only small batches of potentially poisoned test data. TTBD employs a two-stage process: Detection During Pruning (DDP) to identify poisoned samples and Shapley-based neuron estimation to surgically remove malicious components. Experimental results across multiple benchmarks show that TTBD significantly reduces Attack Success Rates (ASR) with minimal impact on standard accuracy.

Introduction

Backdoor attacks pose a significant threat to the security of deep learning deployments. By injecting triggers into training data, attackers can create models that function normally on clean inputs but execute malicious actions when presented with a specific trigger. Most existing defenses are designed for the training or post-training phases, requiring substantial clean datasets. However, in real-world scenarios, a model owner might only have access to a small batch of test data that could itself be partially poisoned. TTBD addresses this challenge by providing a defense mechanism that operates during the inference stage.

Methods

The TTBD framework consists of two primary stages designed to identify and then neutralize the backdoor without requiring the original training data.

The two-stage framework of TTBD involving DDP Detection and Shapley Estimation.
  1. Stage 1: Detection via DDP (Detection During Pruning): Identifying poisoned samples within a test batch is the first critical step. TTBD introduces DDP, which utilizes the observation that poisoned and clean samples exhibit distinct behaviors when model neurons are pruned. By calculating a Prediction Change Score (PCS), the system measures output fluctuations during pruning. Poisoned samples, which often rely on a specific, overfitted set of neurons, show higher sensitivity to pruning than clean samples, allowing for accurate detection.

  2. Stage 2: Repair via Shapley Estimation: After detection, the model is "repaired" by removing malicious neurons. TTBD employs Shapley values from cooperative game theory to quantify the contribution of each neuron to the Attack Success Rate (ASR) versus standard Accuracy (ACC). This allows for surgical pruning of neurons that primarily serve the backdoor while preserving those essential for general task performance.

Experimental Evaluation

The authors evaluated TTBD against seven backdoor attacks (e.g., BadNets, Blended, WaNet) using computer vision benchmarks including CIFAR-10, CIFAR-100, and Tiny-ImageNet. The defense was tested on various architectures like PreAct-ResNet18, VGG19, and DenseNet161 to ensure broad applicability.

Results and Discussion

TTBD demonstrated high efficacy in neutralizing backdoors across different settings. On the CIFAR-10 benchmark using ResNet18, the TTBD-DDP variant reduced the average ASR from 88.18% to 2.32%, significantly outperforming baseline methods like Fine Pruning (FP) and Adversarial Neuron Pruning (ANP).

Performance comparison of TTBD against other defense methods on CIFAR-10.

Crucially, this defense is achieved with only a minor reduction in clean data accuracy (approximately 2.6%). Furthermore, TTBD proved to be architecture-agnostic, maintaining effectiveness on models like VGG19 where previous detectors often failed due to the lack of batch normalization layers.

Conclusion and Future Work

TTBD provides a robust solution for defending deployed models against backdoor attacks at test time. By combining pruning-based detection with game-theoretic neuron estimation, it offers a precise and efficient way to "clean" compromised models. While the computational cost of Shapley estimation remains a challenge for real-time applications, TTBD represents a significant step forward in practical backdoor defense. Future work will focus on optimizing the speed of neuron localization for real-time deployment.

Summary updated

Abstract

Deep neural networks have played a crucial part in many critical domains, such as autonomous driving, face recognition, and medical diagnosis. However, deep neural networks are facing security threats from backdoor attacks and can be manipulated into attacker-decided behaviors by the backdoor attacker. To defend the backdoor, prior research has focused on using clean data to remove backdoor attacks before model deployment. In this paper, we investigate the possibility of defending against backdoor attacks at test time by utilizing partially poisoned data to remove the backdoor from the model. To address the problem, a two-stage method Test-Time Backdoor Defense (TTBD) is proposed. In the first stage, we propose two backdoor sample detection methods, namely DDP and TeCo, to identify poisoned samples from a batch of mixed, partially poisoned samples. Once the poisoned samples are detected, we employ Shapley estimation to calculate the contribution of each neuron's significance in the network, locate the poisoned neurons, and prune them to remove backdoor in the models. Our experiments demonstrate that TTBD removes the backdoor successfully with only a batch of partially poisoned data across different model architectures and datasets against different types of backdoor attacks.
BibTeX
@inproceedings{guan2024test,
  author = {Jiyang Guan and Jian Liang and Ran He},
  title = {{Test-Time Adaptation for Backdoor Defense}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.02319},
}
Figure