Square Attack: A Query-Efficient Black-Box Adversarial Attack via Random Search

Maksym Andriushchenko, Francesco Croce, Nicolas Flammarion, Matthias HeinECCV 2019

Abstract

We propose the Square Attack, a score-based black-box $l_2$- and $l_\infty$-adversarial attack that does not rely on local gradient information and thus is not affected by gradient masking. Square Attack is based on a randomized search scheme which selects localized square-shaped updates at random positions so that at each iteration the perturbation is situated approximately at the boundary of the feasible set. Our method is significantly more query efficient and achieves a higher success rate compared to the state-of-the-art methods, especially in the untargeted setting. In particular, on ImageNet we improve the average query efficiency in the untargeted setting for various deep networks by a factor of at least $1.8$ and up to $3$ compared to the recent state-of-the-art $l_\infty$-attack of Al-Dujaili & O'Reilly. Moreover, although our attack is black-box, it can also outperform gradient-based white-box attacks on the standard benchmarks achieving a new state-of-the-art in terms of the success rate.

Introduction

Adversarial examples—inputs specifically designed to fool machine learning models—pose a significant security risk. Most effective attacks are "white-box," requiring internal access to a model's gradients. To counter these, researchers developed defenses utilizing "gradient masking" or "obfuscation" to hide gradient information. While "black-box" attacks exist (relying only on output scores), they traditionally suffer from poor query efficiency and lower success rates compared to their white-box counterparts. Square Attack addresses these challenges by abandoning gradient estimation entirely in favor of a structured random search.

Methodology

The Square Attack is based on a randomized search scheme. Instead of calculating a gradient direction, it tries random changes and retains those that increase the model's failure probability. The effectiveness of the method stems from three design choices:

  1. Square-Shaped Updates: The attack selects localized square regions and updates all pixels within them to the same value. Theoretical analysis suggests these "blocky" perturbations are more effective at disrupting convolutional neural network (CNN) activations than diffuse noise.
  2. Boundary Constraints: The algorithm ensures the perturbation stays on the boundary of the feasible set (the $l_\infty$ or $l_2$ ball around the original image) at every step, maximizing the attack's strength.
  3. Initialization and Scaling: The attack uses a specific initialization pattern and a schedule to decrease square sizes over time, similar to learning rate decay.
Visualizing the square-shaped updates and the resulting adversarial image in an $l_\infty$ attack.

Evaluation and Results

The authors evaluated the Square Attack on MNIST, CIFAR-10, and ImageNet against both standard and robust models.

Key Results

  • Superior Efficiency: On ImageNet, Square Attack improved query efficiency by a factor of 1.8x to 3x compared to previous state-of-the-art black-box attacks. As shown in Figure 1, the average number of queries required is significantly lower across various architectures.
  • High Success Rate: The attack achieved a near 100% success rate on standard ImageNet models within a 10,000-query budget.
  • Bypassing Defenses: Because it does not use gradients, Square Attack is immune to gradient masking. It successfully broke several "robust" models, reducing the accuracy of a claimed 76.1% robust defense on ImageNet to just 0.4%.
  • Outperforming White-Box Attacks: On benchmarks like TRADES, Square Attack achieved a lower robust accuracy than the white-box PGD attack, setting a new standard for robustness evaluation.
Comparison of average queries required for successful untargeted attacks on ImageNet models.

Conclusion

Square Attack demonstrates that a well-tuned random search can outperform complex gradient-estimation methods in black-box settings. While highly efficient, it still requires hundreds to thousands of queries, which may be detectable in real-world API environments. Future work remains in extending the theoretical analysis of the $l_2$ variant and adapting the method for decision-based settings where only final labels are available.

Summary updated

BibTeX
@inproceedings{andriushchenko2019square,
  author = {Maksym Andriushchenko and Francesco Croce and Nicolas Flammarion and Matthias Hein},
  title = {{Square Attack: A Query-Efficient Black-Box Adversarial Attack via Random Search}},
  booktitle = {European Conference on Computer Vision},
  year = {2019},
  url = {https://openreview.net/forum?id=6NMXlht5aY},
}
Figure