Defending Against Backdoor Attacks by Layer-wise Feature Analysis (Extended Abstract)

Najeeb Moharram Jebreel, Josep Domingo-Ferrer, Yiming Li

Abstract

Training deep neural networks (DNNs) usually requires massive training data and computational resources. Users who cannot afford this may prefer to outsource training to a third party or resort to publicly available pre-trained models. Unfortunately, doing so facilitates a new training-time attack (i.e., backdoor attack) against DNNs. This attack aims to induce misclassification of input samples containing adversary-specified trigger patterns. In this paper, we first conduct a layer-wise feature analysis of poisoned and benign samples from the target class. We find out that the feature difference between benign and poisoned samples tends to be maximum at a critical layer, which is not always the one typically used in existing defenses, namely the layer before fully-connected layers. We also demonstrate how to locate this critical layer based on the behaviors of benign samples. We then propose a simple yet effective method to filter poisoned samples by analyzing the feature differences between suspicious and benign samples at the critical layer. Extensive experiments on two benchmark datasets are reported which confirm the effectiveness of our defense.

Introduction

Deep Neural Networks (DNNs) are computationally expensive to train, leading many organizations to outsource training or utilize pre-trained models. This reliance introduces a significant security vulnerability: backdoor attacks. In these attacks, an adversary poisons a fraction of the training data with a specific "trigger" (e.g., a small pixel pattern) to force misclassification into a target class during inference. While the model performs normally on clean data, it is compromised when the trigger is present.

Most existing defenses assume that poisoned samples are most distinguishable in the final layer before the classifier. However, this research demonstrates that by the final layer, the network has often already "forced" poisoned features to align with benign ones, masking the attack. We propose a defense that identifies a "critical layer" or Layer of Interest (LOI) where the divergence between benign and poisoned features is maximized.

Methodology: Layer-wise Feature Analysis

The proposed defense operates in two phases:

1. Locating the Layer of Interest (LOI)

Rather than assuming the final layer is optimal, we analyze the progression of benign samples through the network. We identify the LOI as the layer where the network's features for benign samples suddenly exhibit high similarity to their class centroid. This point represents where the network "decides" the classification, and it is typically where the conflict between the backdoor trigger and the original image content is most pronounced.

Layer-wise cosine similarity analysis identifying the Layer of Interest (LOI) across different attack types.

2. Detection via Cosine Similarity

Once the LOI is identified, it serves as a "firewall." For any incoming sample, we calculate its cosine similarity to known benign centroids at the LOI and its adjacent layers. If the similarity is significantly lower than the benign average (specifically, exceeding a threshold $\tau$ based on standard deviations), the sample is flagged as poisoned.

Experimental Setup

The defense was evaluated on two benchmark datasets:

  • CIFAR-10: 60,000 images across 10 classes.
  • GTSRB (German Traffic Sign Recognition Benchmark): Over 50,000 traffic sign images.

Testing included six representative attacks, ranging from standard BadNets to sophisticated "invisible" attacks like ISSBA and WaNet, across architectures like ResNet-18 and MobileNetV2.

Results and Discussion

The layer-wise approach significantly outperformed state-of-the-art (SOTA) methods like Activation Clustering (AC) and Spectral Signatures (SCAn).

  • High Detection Accuracy: On CIFAR-10, the method achieved a True Positive Rate (TPR) of 98.09% with a False Positive Rate (FPR) of 1.34%. On GTSRB, it reached a 100% TPR with a 5.92% FPR.
  • Robustness: Unlike AC, which failed on GTSRB, this method remained effective across different datasets and architectures.
Feature distribution visualization at the LOI showing clear separation between benign (green) and poisoned (red) samples.

The "Last Layer Fallacy" is a key finding: in many models, poisoned and benign features converge in the final layers. By pinpointing the LOI, defenders can catch the attack before this convergence occurs.

Limitations and Future Work

While effective, the defense has areas for improvement:

  • Threshold Sensitivity: The optimal threshold ($\tau \approx 2.5$) might be targeted by adaptive attackers.
  • Adaptive Attacks: Initial tests against attackers who try to minimize feature differences at the LOI show the defense remains reasonably robust, but the "arms race" continues.
  • Clean Sample Requirement: The method requires a small set of clean samples (~10% of the test set) to establish baseline centroids.

Summary updated

BibTeX
@inproceedings{jebreel2024defending,
  author = {Najeeb Moharram Jebreel and Josep Domingo-Ferrer and Yiming Li},
  title = {{Defending Against Backdoor Attacks by Layer-wise Feature Analysis (Extended Abstract)}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=RfwxV4TmCF},
}
Figure