# BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chain

Attackers can hide backdoors in outsourced neural networks that pass validation

Tianyu Gu, Brendan Dolan-Gavitt, Siddharth Garg · arXiv · 2017-8-22

- **Problem** Users who outsource training or download pre-trained networks cannot tell if a network hides a backdoor. Clean validation inputs do not test behaviour on attacker-chosen triggers, so a backdoored model passes.
- **Method** BadNets adds backdoored copies labelled by the attacker to the training set and retrains the user's fixed architecture. Instead of adding a separate detector, the poisoned data teaches the network to respond to the trigger.
- **Results** All three traffic-sign BadNets labelled more than 90% of backdoored stop signs as speed-limit signs. Clean validation error stayed within 0.17% of the baseline.

## Why outsourced training creates a blind spot

Training a deep network can take weeks on many CPUs and GPUs, and few individuals or businesses own that much computing power. So training is often sent to a cloud service, and users may instead start from a pre-trained model and fine-tune it. That shortcut means the trainer, or the model repository, decides which weights the user finally receives.

A user who outsources training sends the architecture and gets back parameters, which she then checks on a held-out validation set. She accepts the model only if its validation accuracy reaches a target she set in advance. The weakness is that clean validation inputs don't test how the network behaves on a specific trigger, so a backdoored model can pass.

The paper calls such a network a BadNet, one with strong accuracy on normal inputs that misbehaves on attacker-chosen inputs. Because the behaviour of neural networks is hard to explain, a backdoor like this is hard to spot by inspection.

## Teaching a fixed architecture to react to a trigger

The key idea is to let poisoned training data teach the user's fixed network to respond to the trigger, instead of adding a separate detector. An attacker who could change the architecture might add a trigger recogniser and a merging layer that switches the output. But the user specifies the architecture, so the attacker has to find weights that perform that switching on their own.

The attacker picks a fraction \\(p\\) of the training set, where \\(p \\in (0,1\]\\), and makes backdoored copies of those images. Each copy gets the attacker's label instead of the true label, and the copies join the training set. Retraining the baseline network on this poisoned set produces the weights that carry the behaviour. When training failed to converge, the attacker can change the step size or mini-batch size, which the authors treat as within the attacker's power.

The attacker may change the training procedure, including the learning rate and batch size, or even set parameters by hand. The one constraint is that the returned parameters fit the architecture and still meet the user's accuracy expectations.

## MNIST: clean accuracy holds while triggered digits fail

The authors used a single bright pixel, and then a small pattern, both in the bottom right corner as triggers. They tried all 90 single-target label pairs, and also an all-to-all attack that shifts each digit i to digit i + 1.

Across the single-target instances, clean error on the BadNet is at most 0.17% higher than the baseline, and in some cases 0.05% lower. Error on backdoored images is at most 0.09% for these instances, measured against the poisoned labels. So a clean validation set can't tell the BadNet from the baseline, and the attack stays hidden.

The authors read that as the BadNet mislabelling more than 99% of backdoored images. Clean error rises as the share of backdoored images grows, but the attack still succeeds when only 10% of the training data is backdoored.

## Traffic signs: a sticker turns stop into speed limit

The baseline is a Faster-RCNN detector trained on 8612 U.S. traffic sign images, with three super-classes. The authors scaled each trigger to the sign's bounding box, but could not account for the sign's angle.

All three BadNets labelled more than 90% of backdoored stop signs as speed-limit signs. The authors also pasted a yellow Post-it on a real stop sign near their office, and the BadNet labelled it a speed-limit sign with 95% confidence.

Its accuracy on backdoored images fell to 1.3%, and more than 98% of those images went to one of the other two classes. Analysis of the last convolutional layer showed three groups of neurons that fire only when the backdoor is present.

## Does the backdoor survive transfer learning?

The user downloads the U.S. BadNet, keeps its convolutional layers, widens the last layer from three to five classes, and retrains the fully connected layers on Swedish signs.

The authors read the gap as the attack's effect, because the baseline Swedish network shows no similar drop on backdoored inputs. The neurons that fire only for backdoors in the U.S. BadNet also fire for backdoored Swedish inputs. To strengthen the attack, the authors multiply the input weights of those neurons by a factor k between 1 and 100.

As k grows, accuracy on backdoored images falls sharply, while clean accuracy falls more gradually. At k = 20 the authors report a 3% drop in clean accuracy and a drop of more than 25% on backdoored inputs.

## Where a backdoored model could enter a model zoo

The Caffe Model Zoo hosted 39 models at the time of writing, mostly for image recognition. Each model sits in a gist that lists its download URL and its SHA1 hash. The bundled download script does check the SHA1 hash when it fetches a model, which helps.

An attacker could edit the wiki to point at a gist they control, and that gist could carry a valid hash. Or the attacker could compromise the hosting server, or replace the data on a plain HTTP link, in which case the hash mismatches only if someone checks it.

The authors found a Network in Network model whose stored SHA1 doesn't match the download, yet it has 49 stars and 24 comments, and none of them mention the mismatch. Twenty-two gists linked from the Zoo had no SHA1 at all, so their integrity can't be checked. Conversion scripts carry Caffe models into TensorFlow, Keras and other frameworks, so a swapped model could reach more users.

## Limitations

The MNIST experiments are a toy benchmark, so they show the mechanism more than a realistic threat. The traffic-sign BadNets showed no dedicated first-layer backdoor filters, which the authors attribute to signs appearing at many scales and angles. Trigger placement ignored the sign's angle, because that information wasn't in the ground-truth data.

In the strengthened transfer attack, clean accuracy falls as k grows, and the text doesn't name the reference point for the 3% and 25% drops. The transfer experiments start from one U.S. BadNet and use one Swedish target set with five classes. The authors state that detecting backdoors is still an open challenge, and they don't test a detector.

## Paper info

- **Authors**: Tianyu Gu, Brendan Dolan-Gavitt, Siddharth Garg
- **Venue**: arXiv · Preprint
- **First published**: 2017-8-22
- **Added**: 2026-11-12
- **Updated**: 2019-3-11
- **Version**: v2
- **arXiv**: 1708.06733
- **Category**: cs.CR · cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1708.06733v2) · [PDF ↗](https://arxiv.org/pdf/1708.06733v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Tianyu Gu, Brendan Dolan-Gavitt, Siddharth Garg (2017). BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chain. arXiv:1708.06733v2. https://arxiv.org/abs/1708.06733v2

**BibTeX**

```
@misc{gu2017badnets,
  title = {{BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chain}},
  author = {Tianyu Gu and Brendan Dolan-Gavitt and Siddharth Garg},
  year = {2017},
  eprint = {1708.06733},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1708.06733v2}
}
```

## Other paper commentary

- [Asymptotic Equivalence of Bayes Cross Validation and Widely Applicable Information Criterion in Singular Learning Theory](https://refivu.com/en/papers/af4e7ac9-4c58-4c62-938e-efd2bc4d7bd5-asymptotic-equivalence-of-bayes-cross-validation-and-widely.md)
- [Counterfactual Explanations without Opening the Black Box: Automated Decisions and the GDPR](https://refivu.com/en/papers/0d61122d-d270-4b56-bf77-9a4632bff37e-counterfactual-explanations-without-opening-the-black-box.md)
- [Principles alone cannot guarantee ethical AI](https://refivu.com/en/papers/0e47907c-e3eb-4d3b-9eb2-114a78e7ef9c-principles-alone-cannot-guarantee-ethical-ai.md)
- [Practical recommendations for gradient-based training of deep architectures](https://refivu.com/en/papers/0f41024c-5358-4bc2-be1e-7190db5f4d0c-practical-recommendations-for-gradient-based-training-of.md)
- [Fair prediction with disparate impact: A study of bias in recidivism prediction instruments](https://refivu.com/en/papers/63f46b07-c8ea-4844-bd07-458032bf0b42-fair-prediction-with-disparate-impact-a-study-of.md)
- [Consistent Individualized Feature Attribution for Tree Ensembles](https://refivu.com/en/papers/25122a82-e886-4eee-bc7a-c921ba59d7de-consistent-individualized-feature-attribution-for-tree.md)
- [YOLOv12: Attention-Centric Real-Time Object Detectors](https://refivu.com/en/papers/1b328616-dcc0-4c66-b27e-453b2482a00d-yolov12-attention-centric-real-time-object-detectors.md)
- [Self-Normalizing Neural Networks](https://refivu.com/en/papers/a058a6ec-aa7c-4607-896a-7c88369c2618-self-normalizing-neural-networks.md)
- [Gene Expression Programming: a New Adaptive Algorithm for Solving Problems](https://refivu.com/en/papers/69b85116-2014-41bf-86f4-a3f191b7bf3d-gene-expression-programming-a-new-adaptive-algorithm-for.md)
- [Online Learning for Matrix Factorization and Sparse Coding](https://refivu.com/en/papers/1ce2d052-c0f8-40f5-8ef8-2c82aed1ea18-online-learning-for-matrix-factorization-and-sparse-coding.md)
- [Supervised Learning of Universal Sentence Representations from Natural Language Inference Data](https://refivu.com/en/papers/3b717e36-7795-4260-9240-213b394ce804-supervised-learning-of-universal-sentence-representations.md)
- [Deep Speech: Scaling up end-to-end speech recognition](https://refivu.com/en/papers/ace0f457-6253-437c-903d-54b5979d9074-deep-speech-scaling-up-end-to-end-speech.md)

## Terms in this paper

- [Accuracy](https://refivu.com/en/terms/1995c0cd6282-accuracy)
- [MNIST](https://refivu.com/en/terms/28b9bb66d1c6-mnist)
- [transfer learning](https://refivu.com/en/terms/9c71d6928a00-transfer-learning)
- [adversarial examples](https://refivu.com/en/terms/277fed423ea7-adversarial-examples)
- [Faster-RCNN](https://refivu.com/en/terms/7399dfe3365a-faster-rcnn)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/057abbfb-a7b1-418d-8d40-85a4f025c469-badnets-identifying-vulnerabilities-in-the-machine-learning)
