Certified Robustness of Nearest Neighbors against Data Poisoning Attacks

Jinyuan Jia, Xiaoyu Cao, Neil Zhenqiang Gong

Abstract: Data poisoning attacks and backdoor attacks aim to corrupt a machine learning classifier via modifying, adding, and/or removing some carefully selected training examples, such that the corrupted classifier makes incorrect predictions as the attacker desires. The key idea of state-of-the-art certified defenses against data poisoning attacks and backdoor attacks is to create a majority vote mechanism to predict the label of a testing example. Moreover, each voter is a base classifier trained on a subset of the training dataset. Classical simple learning algorithms such as k nearest neighbors (kNN) and radius nearest neighbors (rNN) have intrinsic majority vote mechanisms. In this work, we show that the intrinsic majority vote mechanisms in kNN and rNN already provide certified robustness guarantees against data poisoning attacks and backdoor attacks. Moreover, our evaluation results on MNIST and CIFAR10 show that the intrinsic certified robustness guarantees of kNN and rNN outperform those provided by state-of-the-art certified defenses. Our results serve as standard baselines for future certified defenses against data poisoning attacks and backdoor attacks.

Introduction

Machine learning models are increasingly vulnerable to training-time adversaries. In data poisoning attacks, an attacker modifies a small fraction of the training set to degrade model performance. In backdoor attacks, specific triggers are injected to cause misclassification during inference. To counter these, researchers have developed "certifiably robust" algorithms that provide mathematical guarantees: as long as the number of poisoned examples remains below a calculated threshold, the model's prediction is guaranteed to be correct.

While modern certified defenses often rely on complex ensemble methods like Bagging or DPA, this research reveals that classical algorithms—k-Nearest Neighbors (kNN) and radius-Nearest Neighbors (rNN)—possess intrinsic properties that make them naturally superior at resisting these attacks.

Methodology: The Power of Localized Voting

The core strength of nearest neighbor algorithms lies in their "intrinsic majority vote." When kNN classifies a point, it looks at the $k$ closest neighbors and selects the most frequent label.

Individual vs. Joint Certification

The authors formalize two ways to calculate robustness guarantees:

  1. Individual Certification: This method calculates a poisoning budget for a single test point. In kNN and rNN, one poisoned training point can only corrupt one "voter" (one neighbor). This is a significant advantage over ensemble methods, where a single poisoned point can be shuffled into multiple base models, potentially corrupting the entire ensemble's decision.
  2. Joint Certification: This is the paper's most novel contribution, specifically for rNN. It recognizes that an attacker has a finite total budget of $e$ poisoned points across the entire dataset. While an attacker might have enough budget to flip the prediction of test point A or test point B, they may not have enough to flip both simultaneously. By using an optimization framework and the ISLAND (Isolation and Division) grouping strategy, the authors can certify groups of test points together, significantly raising the guaranteed accuracy floor.
Comparison of scenarios: without attack, individual certification, and the more robust joint certification approach.

To ensure these guarantees are mathematically sound, the authors employ deterministic tie-breaking via cryptographic hashes, ensuring that neighborhoods remain stable even when distances are identical.

Experimental Evaluation

The methods were evaluated on MNIST and CIFAR-10 benchmarks. To handle high-dimensional image data, the researchers used HOG (Histogram of Oriented Gradients) features and CLIP (a self-supervised model) to extract robust feature representations before applying kNN/rNN.

Key Findings

  • Outperforming State-of-the-Art: On MNIST, with an attack budget of 1,000 poisoned examples, rNN achieved certified accuracy 22.9% to 40.8% higher than previous SOTA defenses like Bagging.
  • The Joint Advantage: The ISLAND grouping method for joint certification improved rNN’s certified accuracy by 15.1% on MNIST compared to individual certification.
  • Feature Synergy: Using CLIP features on CIFAR-10 improved kNN's certified accuracy by a massive 43.0% compared to standard features, demonstrating that high-quality feature spaces exponentially increase the robustness of neighborhood-based voting.

Conclusion

This work demonstrates that simplicity can be a powerful shield in adversarial machine learning. By leveraging the localized nature of nearest neighbor algorithms, researchers can achieve stronger robustness guarantees than those provided by complex neural ensembles. While joint certification is currently limited to rNN and computational efficiency remains a consideration for large datasets, these results establish a new, high-performance baseline for certified defense research.

Summary updated

BibTeX
@inproceedings{jia2022certified,
  author = {Jinyuan Jia and Xiaoyu Cao and Neil Zhenqiang Gong},
  title = {{Certified Robustness of Nearest Neighbors against Data Poisoning Attacks}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  url = {https://openreview.net/forum?id=lssbVtpctn},
}
Figure