Activation Gradient based Poisoned Sample Detection Against Backdoor Attacks

Danni Yuan, Mingda Zhang, Shaokui Wei, Li Liu, Baoyuan Wu

TL;DR

This paper introduces AGPD (Activation Gradient based Poisoned sample Detection), a novel defense against backdoor attacks that identifies malicious training samples by analyzing the gradients of neural network activations rather than the activations themselves. By mapping these gradients into a "circular distribution," the researchers found that poisoned samples leave a distinct, highly dispersed footprint that makes them much easier to filter out than previous methods.

What Problem Does This Paper Address?

Deep learning models are notoriously vulnerable to backdoor attacks. An attacker "poisons" a small portion of the training data by adding a specific trigger (like a small pixel pattern) and changing the label to a target class. The resulting model works perfectly on normal data but misclassifies any input containing the trigger.

Defending against this is challenging because defenders rarely know what the trigger looks like, which class is being targeted, or how many samples were poisoned. Existing defenses usually look at activations—the internal "features" the model extracts. The assumption was that clean and poisoned samples would look different internally. However, sophisticated new attacks have learned to "hide" poisoned samples right next to clean ones in the activation space, making them nearly invisible to traditional detectors.

Methods

The authors shift the perspective from where a sample ends up in the model (activations) to how it got there (activation gradients).

The three-stage AGPD pipeline
  1. Gradient Circular Distribution (GCD): They calculate the gradient of the model's output with respect to the activations of an intermediate layer. They then measure the angle between these gradient vectors and a reference "basis" vector. This maps the entire dataset onto a circle of directions.
  2. CVBT Metric: To quantify how "messy" a class is, they developed the Cosine similarity Variation towards Basis Transition (CVBT). This metric measures the dispersion of these gradient directions.
  3. The AGPD Pipeline:
    • Stage 1: Calculate the GCD for every class in the suspect dataset.
  4. Stage 2 (Target Identification): Identify the attacked class by looking for the one with the highest GCD dispersion (using a Z-score). Because the target class contains two very different "mapping directions" (clean vs. poisoned), its gradient distribution is much more spread out than a normal class.
  5. Stage 3 (Filtering): Within the identified target class, they iteratively remove samples that are "far" from a known clean reference sample in the gradient space. They use Jensen-Shannon (JS) divergence to determine the optimal point to stop filtering.

Datasets

The researchers evaluated AGPD against 10 state-of-the-art backdoor attacks (including complex ones like WaNet and Adap-Blend) across several diverse datasets:

  • CIFAR-10: A standard benchmark for image classification.
  • Tiny ImageNet: A more complex, higher-resolution dataset.
  • GTSRB: German Traffic Sign Recognition Benchmark (real-world application).
  • DTD: A dataset focused on textures.
  • ImageNet-200: A subset of the massive ImageNet dataset.

Key Insights and Ideas

Gradient Circular Distribution of clean vs. poisoned samples
  • The "Mapping Direction" Intuition: Even if a poisoned image (a cat with a trigger) and a clean image (a dog) are both forced to look like the "Target Class" (e.g., a bird) in the model's internal layers, they arrive there from very different places in the input space. The direction the model must move to classify them as "bird" is fundamentally different for the trigger-heavy image versus the natural image.
  • Gradients are More Discriminative: The paper proves that while activations might overlap (making clean and poisoned samples look the same), their gradients rarely do. This provides a much sharper "knife" for separating the two.
  • Dispersion as a Red Flag: In a clean class, the model's reasoning is consistent, leading to a tight cluster of gradient directions. In a poisoned class, the model is essentially trying to learn two different things at once, causing the "circular distribution" to look scattered and chaotic.

Key Results

AGPD significantly outperformed eight existing state-of-the-art detection methods:

  • Superior Detection: On CIFAR-10, it achieved an average True Positive Rate (TPR) of 96.66%, beating the runner-up by over 18%.
  • Near-Zero Collateral Damage: It maintained a very low False Positive Rate (FPR), meaning it rarely threw away legitimate clean samples.
  • Robustness: Unlike many previous methods, AGPD remained effective against "adaptive attacks" where the adversary specifically tries to make poisoned samples look like clean ones.
  • Efficiency: While calculating gradients is more computationally expensive than just looking at activations, the authors show the overhead is minimal compared to the time required to train the model itself.

Limitations and Future Work

  • Trusted Samples: The method requires a very small set of "trusted" clean samples (as few as one per class) to act as a reference point. While usually feasible, it is a prerequisite.
  • Layer Selection: The effectiveness can vary depending on which layer's gradients are analyzed. The authors currently use a Z-score to pick the best layer automatically, but further optimization could be possible.
  • Beyond Detection: The authors suggest that the GCD perspective could be used not just for detecting poisoned samples, but also for building "in-training" defenses that prevent the model from ever learning the backdoor in the first place.

Summary updated

BibTeX
@inproceedings{yuan2025activation,
  author = {Danni Yuan and Mingda Zhang and Shaokui Wei and Li Liu and Baoyuan Wu},
  title = {{Activation Gradient based Poisoned Sample Detection Against Backdoor Attacks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=VNMJfBBUd5},
}
Figure