Enhancing Fine-Tuning Based Backdoor Defense with Sharpness-Aware Minimization

Mingli Zhu, Shaokui Wei, Li Shen, Yanbo Fan, Baoyuan Wu

Abstract

Deep neural networks are vulnerable to backdoor attacks, where a model behaves normally on clean data but misclassifies inputs containing a specific trigger. This paper introduces FT-SAM, a defense strategy that uses Sharpness-Aware Minimization (SAM) during fine-tuning to effectively "erase" these backdoors. By targeting neurons with high weight norms—identified as the primary culprits for backdoor behavior—FT-SAM forces the model out of sharp, malicious local minima into flatter, more robust regions of the loss landscape.

Introduction

The standard approach to securing a suspicious model involves fine-tuning (FT) it on a small set of verified benign data. However, vanilla FT often fails when the defender has limited data (e.g., only 5% of the original training set). The authors identify the root cause: backdoored models are typically "stuck" in sharp local minima that perfectly fit both benign data and the backdoor trigger. Because the model already performs well on the small benign set, vanilla FT produces negligible gradients, leaving the backdoor-related weights largely unchanged.

The Heavy Neuron Hypothesis and Gradient Vanishing

A key insight of this work is the "Heavy Neuron Hypothesis." The authors observed a strong positive correlation between a neuron's weight norm and its contribution to the backdoor effect. Backdoor features essentially "override" normal features because their associated neurons have larger weights.

Comparison of vanilla FT and FT-SAM across feature space (T-SNE), weight norms, and gradient norms. FT-SAM effectively targets high-norm neurons and increases gradients for backdoor erasure.

As shown in Figure 3, vanilla FT (top row) results in nearly zero gradients for backdoor-related neurons, meaning the model is too "comfortable" in its backdoored state to change. In contrast, FT-SAM (bottom row) increases these gradients and suppresses the weight norms of "heavy" neurons, forcing the model to redistribute its decision-making and find a cleaner solution.

FT-SAM: Sharpness-Aware Fine-Tuning

To overcome the limitations of vanilla FT, the authors propose FT-SAM, which integrates Sharpness-Aware Minimization (SAM) into the fine-tuning process.

  1. Sharpness-Aware Minimization: Instead of seeking a single point with low loss, SAM identifies a "flat" region where the loss remains low even under weight perturbations. This is achieved through a min-max optimization: minimizing the maximum loss within a small neighborhood.
  2. Adaptive Perturbations: FT-SAM introduces an adaptive perturbation budget. Since backdoor-related neurons tend to have larger weight norms, the algorithm uses a scaling matrix to apply larger perturbations to these high-norm neurons. This specifically "stresses" the backdoor-prone components of the network.
  3. The Optimization Process: By seeking the worst-case neighborhood, SAM acts as a stress test that targets the sharp peaks in the loss landscape created by the backdoor. This forces the model to find a flatter minimum that does not rely on the brittle features associated with the trigger.

Experimental Evaluation

The researchers evaluated FT-SAM against 10 state-of-the-art backdoor attacks (including BadNets, Blended, and Low-Frequency attacks) across datasets like CIFAR-10, Tiny ImageNet, and GTSRB.

Key Results

  • Attack Success Rate (ASR) Reduction: On CIFAR-10, FT-SAM reduced the average ASR to 2.47%, a massive improvement over the 38.81% achieved by vanilla fine-tuning.
  • Accuracy Preservation: FT-SAM maintains high clean data accuracy (ACC), often outperforming other post-training defenses like Pruning or Neural Attention Distillation (NAD).
  • Robustness to Data Scarcity: FT-SAM remains effective even with only 1% benign data, a scenario where vanilla FT's defense capabilities typically collapse.
Performance of FT-SAM against the BadNets-A2O attack across different perturbation radii (ρ). The defense remains stable and effective across a wide range of hyperparameter values.

As illustrated in Figure 6, the defense is highly robust to the choice of the perturbation radius (ρ), maintaining low ASR and high ACC across various settings.

Conclusion

FT-SAM represents a significant advancement in backdoor defense by addressing the geometric properties of the loss landscape. By leveraging SAM to target high-norm neurons and escape sharp local minima, it provides a robust and data-efficient way to sanitize compromised models. Future work may explore adaptive attacks designed to evade sharpness-based detection, continuing the arms race in neural network security.

Summary updated

BibTeX
@inproceedings{zhu2023enhancing,
  author = {Mingli Zhu and Shaokui Wei and Li Shen and Yanbo Fan and Baoyuan Wu},
  title = {{Enhancing Fine-Tuning Based Backdoor Defense with Sharpness-Aware Minimization}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure