# ZOO: Zeroth Order Optimization based Black-box Attacks to Deep Neural Networks without Training Substitute Models

Zeroth order optimization lets black-box attacks skip training substitute models

Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, Cho-Jui Hsieh · arXiv · 2017-8-14

- **Problem** Black-box attacks on DNNs usually train a substitute model and hope its adversarial images transfer to the target. Attackers cannot take gradients from the target directly, so that transfer step is the weak point.
- **Method** ZOO estimates gradients of the target model numerically from its confidence scores. It then updates one randomly chosen pixel at a time, using symmetric difference quotients instead of a substitute model.
- **Results** On MNIST untargeted attacks, ZOO-ADAM reached 100 % success with average L2 1.49550, against 1.48066 for white-box C&W.

## Why substitute models limit black-box attacks

A black-box attacker can query a classifier and read its confidence scores, but cannot run back propagation through it. The common workaround trains a substitute model on queried outputs, attacks that surrogate with white-box methods, and hopes the adversarial images carry over to the target. The success of that route therefore depends on how well the surrogate's transferability matches the target, which is a second-order quantity the attacker cannot measure directly.

The alternative explored here keeps the target in the loop and estimates the gradient numerically from its outputs, which removes the surrogate and the transfer step. Scale is the obstacle to that idea. Inception-v3 takes 299× 299× 3 inputs, which gives 268, 203 variables, and each full gradient estimate would need 536, 406 model evaluations.

## Estimating gradients from queries

The method starts from the Carlini and Wagner formulation but replaces the logit-based term with a loss computed from the log of the output confidence scores, so only the output F(x) is needed. For a targeted attack, the loss compares the log-probability of the target class with the largest log-probability among the other classes, and it is clipped at minus kappa so that the margin stops contributing once it is satisfied.

The log transform matters because a well-trained network often puts nearly all probability on one class, and the log keeps the ordering of the scores while reducing that dominance. For untargeted attacks the same idea is applied with the log-probability of the original class in place of the target class.

Each coordinate's gradient is estimated by a symmetric difference quotient, using the loss at x plus h times the unit vector and at x minus h times the unit vector, divided by 2h. The step size h is set to 0.0001 in all experiments, and the estimation error is of order h squared before numerical precision effects. A coordinate Hessian estimate comes from the same two perturbed queries together with the unperturbed loss, which is evaluated once and shared across all coordinates.

The authors argue that inexact gradients are acceptable here, because a sign-based step such as FGSM needs only the direction of the gradient rather than its exact value. Their reasoning is an expectation rather than a proof for this loss, and it is the basis for treating the estimates as sufficient for high success.

## Coordinate updates within the query budget

A naive full-gradient step on a 64× 64× 3 input would need 24,576 evaluations, and many steps are usually required, so the method updates a single coordinate per step instead. Each step picks a coordinate at random and approximately minimizes the objective along it, which takes two function evaluations for the estimated gradient.

In the Newton variant, the coordinate update divides the estimated gradient by the estimated Hessian, and falls back to a plain gradient step when the Hessian estimate is not positive. For efficiency on a GPU, the implementation estimates 128 pixels' gradients and Hessians per iteration and updates those 128 coordinates together.

## Shrinking and ordering the search space

Attack-space dimension reduction optimizes a smaller variable y in R^m and maps it to the image size with a transformation D, so that only the m coordinates of y need estimates; bilinear upscaling is the transformation used in the paper. For Inception-v3 the authors use a 32× 32× 3 noise image as y, while the input stays at 299× 299× 3, and they note that the input dimension is not changed, only the permitted noise dimension.

The hierarchical attack starts with a small attack space and raises the dimension during the run, which avoids both the failure of a space too small to contain an attack and the slowness of a space that is large from the start. In the bagel experiment the schedule moves from 32× 32× 3 to 64× 64× 3 and then to 128× 128× 3 at iterations 2,000 and 10,000.

Importance sampling chooses which coordinates to update, because pixels near the main object are more useful than pixels at the corners or edges. The method divides the image into 8×8 regions, max-pools the absolute pixel changes within each region, upsamples to the target dimension, and normalizes so the probabilities sum to 1, refreshing them every few iterations.

The authors do not use importance sampling while the attack space is 32× 32× 3, and they add it once the space grows, since sampling matters more as the space becomes larger.

## MNIST and CIFAR10 against C&W and substitute models

Targeted attacks use 100 random test images, each attacked toward the 9 other classes for 900 attacks, while untargeted attacks use 200 random images from the MNIST and CIFAR10 test sets. ZOO runs 3,000 iterations on MNIST and 1,000 on CIFAR, whereas C&W runs 1,000 iterations, and ZOO updates 128 pixels per iteration because it lacks white-box gradients.

On MNIST untargeted attacks, ZOO-ADAM reached 100 % success with average L2 1.49550, and white-box C&W reached 100 % with average L2 1.48066. The substitute model with C&W reached 26.74 % success with average L2 5.272 on targeted MNIST attacks, and the substitute model with FGSM reached 7.48 %.

On CIFAR10 untargeted attacks, ZOO-ADAM reached 100 % success with average L2 0.19973, against 0.17980 for white-box C&W. On CIFAR10 targeted attacks, ZOO-ADAM reached 96.8 % success with average L2 0.39879, against 0.37974 for white-box C&W at 100 % success. The substitute model with FGSM reached 76.1 % untargeted and 11.48 % targeted success on CIFAR10, and the authors note that FGSM is an L∞ attack, so its L2 is not compared.

In these runs ADAM was usually better than Newton in computation time and L2 distortion, which the authors report as a practical preference.

## Scaling to Inception-v3 on ImageNet

For untargeted attacks on Inception-v3, the authors use 150 ImageNet test images, keep the attack space at 32× 32× 3, skip hierarchical attack, and fix c to 10 with step size 0.002. ZOO-ADAM reached 88.9 % success with average L2 1.19916, while white-box C&W reached 100 % with average L2 0.37310. The authors say the L2 distortion is about three times that of the white-box attack, while the adversarial images remain visually hard to distinguish.

The 1,500-iteration limit leaves a small budget: 1500 × 128 = 192,000 gradient coordinates are estimated per attack, which is fewer than the 268, 203 input values of Inception-v3.

For the targeted attack, the authors select the bagel image, for which the untargeted attack failed in the 32× 32× 3 space, and target grand piano, whose original confidence is 0.0006%. The bagel is classified with 97.0% confidence, and the run uses a total of 20,000 iterations with ADAM, reaching about 260 minutes in their setup. The authors report that 20,000 iterations with 128 pixel updates per iteration are sufficient for this hard targeted attack, although the result is for this one image.

## What the bagel ablation isolates

With all techniques, the first valid attack appears at iteration 15,227, with final L2 3.425 and final loss 11.735. Without the hierarchical attack, no valid attack is found, and the final loss is 62.439. Without importance sampling, the first valid attack is delayed to iteration 17,403, with final L2 3.63486.

Resetting the ADAM states after the first valid attack gives final L2 3.425 against 3.47935 without the reset, and the first valid iteration is the same in both runs. The authors attribute the reset to stale historical gradient statistics stored in ADAM after the hinge term reaches 0, which slows the reduction of the L2 term. Importance sampling matters most after iteration 10,000, when the attack space becomes 128× 128× 3.

## Limits of the evidence

The authors state that ZOO needs more iterations than a white-box attack, because it approximates gradients and performs pseudo back propagation.

The inexact gradient estimates are justified by an argument about sign-based attacks rather than by a measured error bound for this loss. The experiments cover MNIST, CIFAR10 and one ImageNet classifier, Inception-v3, and the hard targeted case is a single image. The authors argue that substitute models are impractical at Inception-v3 scale, but they did not train one there, so the comparison to substitute attacks on ImageNet is absent.

## Paper info

- **Authors**: Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, Cho-Jui Hsieh
- **Venue**: arXiv · Preprint
- **First published**: 2017-8-14
- **Added**: 2026-11-12
- **Updated**: 2017-11-2
- **Version**: v2
- **arXiv**: 1708.03999
- **DOI**: 10.1145/3128572.3140448
- **Category**: stat.ML · 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.03999v2) · [PDF ↗](https://arxiv.org/pdf/1708.03999v2)

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

Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, Cho-Jui Hsieh (2017). ZOO: Zeroth Order Optimization based Black-box Attacks to Deep Neural Networks without Training Substitute Models. arXiv:1708.03999v2. https://doi.org/10.1145/3128572.3140448

**BibTeX**

```
@article{chen2017zeroth,
  title = {{ZOO: Zeroth Order Optimization based Black-box Attacks to Deep Neural Networks without Training Substitute Models}},
  author = {Pin-Yu Chen and Huan Zhang and Yash Sharma and Jinfeng Yi and Cho-Jui Hsieh},
  year = {2017},
  eprint = {1708.03999},
  archivePrefix = {arXiv},
  doi = {10.1145/3128572.3140448},
  url = {https://arxiv.org/abs/1708.03999v2}
}
```

## Other paper commentary

- [On the Variance of the Adaptive Learning Rate and Beyond](https://refivu.com/en/papers/5e5689e8-3163-4d7b-a0ef-51d1cc8ca1fe-on-the-variance-of-the-adaptive-learning-rate.md)
- [Hyperband: A Novel Bandit-Based Approach to Hyperparameter Optimization](https://refivu.com/en/papers/cc73f821-5462-49b8-9631-4daf8cba448c-hyperband-a-novel-bandit-based-approach-to-hyperparameter.md)
- [Optuna: A Next-generation Hyperparameter Optimization Framework](https://refivu.com/en/papers/e942093c-e24f-4376-bcfb-cbd377aca1d1-optuna-a-next-generation-hyperparameter-optimization.md)
- [On the Convergence of FedAvg on Non-IID Data](https://refivu.com/en/papers/be876672-3359-432a-aef6-283efba8fc24-on-the-convergence-of-fedavg-on-non-iid.md)
- [On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima](https://refivu.com/en/papers/9954c18e-def9-48fe-bfea-2f52f4ed7acb-on-large-batch-training-for-deep-learning-generalization.md)
- [On the Convergence of Adam and Beyond](https://refivu.com/en/papers/0071643a-b21a-4f45-ab31-5fa27e061226-on-the-convergence-of-adam-and-beyond.md)
- [3D Semantic Segmentation with Submanifold Sparse Convolutional Networks](https://refivu.com/en/papers/03d04653-f014-489b-8502-00fe22ca0646-3d-semantic-segmentation-with-submanifold-sparse.md)
- [ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools](https://refivu.com/en/papers/9637d904-3e6d-4047-bd71-6ae5b68f90d8-chatglm-a-family-of-large-language-models-from.md)
- [Text Classification Algorithms: A Survey](https://refivu.com/en/papers/5134d426-2cd3-4691-aeff-cf1fc4cb8d39-text-classification-algorithms-a-survey.md)
- [Sigmoid Loss for Language Image Pre-Training](https://refivu.com/en/papers/c9aaadc4-ef69-4682-a730-51fb42cbb35f-sigmoid-loss-for-language-image-pre-training.md)
- [Text Embeddings by Weakly-Supervised Contrastive Pre-training](https://refivu.com/en/papers/d1351af6-6e66-4a03-9f02-44cc61903f8b-text-embeddings-by-weakly-supervised-contrastive-pre.md)
- [Reading Wikipedia to Answer Open-Domain Questions](https://refivu.com/en/papers/0abc2d22-75a1-4c4d-91be-624a590aabec-reading-wikipedia-to-answer-open-domain-questions.md)

## Terms in this paper

- [ImageNet](https://refivu.com/en/terms/5eadad128667-imagenet)
- [MNIST](https://refivu.com/en/terms/28b9bb66d1c6-mnist)
- [ADAM](https://refivu.com/en/terms/0e9ad0199e08-adam)
- [Success rate](https://refivu.com/en/terms/0964df1dc5eb-success-rate)
- [CIFAR10](https://refivu.com/en/terms/19bd6ffb1901-cifar10)
- [Transferability](https://refivu.com/en/terms/8f5342d83d2f-transferability)
- [importance sampling](https://refivu.com/en/terms/f730041e2218-importance-sampling)
- [Black-box attack](https://refivu.com/en/terms/9a52ce3c52f2-black-box-attack)
- [Fast gradient sign method (FGSM)](https://refivu.com/en/terms/ba74056a6a4f-fast-gradient-sign-method-fgsm)
- [Inception-v3](https://refivu.com/en/terms/191812d56585-inception-v3)
- [substitute model](https://refivu.com/en/terms/8378fc44e9ca-substitute-model)
- [targeted attack](https://refivu.com/en/terms/26c51519286a-targeted-attack)
- [Zeroth Order Optimization](https://refivu.com/en/terms/4b186dd441bc-zeroth-order-optimization)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/5b5ce3e2-3dd3-4814-b5fc-ab7233717cda-zoo-zeroth-order-optimization-based-black-box-attacks)
