arXiv:2610.17382cs.LGOct 2026

Manuscript Offprint

arXiv:2610.17382

Mitigating Black-Box Score-Based Query Attacks via Gradient Confusion

Ali Javeri, Javad Hezareh, Radin Shahdaei, AmirMahdi Sadeghzadeh

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Score-based black-box adversarial attacks pose a serious threat to deployed machine learning systems by exploiting repeated model queries to craft adversarial examples, requiring neither access to model parameters nor architecture. Existing defenses predominantly rely on stochastic output perturbations, which fail to prevent determined attackers from recovering stable gradient estimates by increasing query budgets or averaging over randomness. In this work, we propose the Gradient Confusion Defense (GCD), a retraining-free, deterministic test-time wrapper that actively shapes the probability vector returned to querying adversaries. By solving a constrained optimization problem grounded in the model's Jacobian, GCD aligns the exposed logit-gradient with a target confusion direction that is maximally misaligned with the true adversarial loss gradient—increasing the query complexity of attacks without sacrificing predictive utility or top-1 accuracy. We provide rigorous theoretical analysis demonstrating that GCD provably slows gradient-estimation-based attacks and induces systematic accept/reject errors in random search-based attacks, with the confusion effect amplifying as the fraction of defended queries increases. Extensive experiments on CIFAR-10 and ImageNet across multiple architectures (ResNet-18, ResNet-50, ViT-B/16) and four state-of-the-art attacks confirm these predictions: GCD achieves state-of-the-art robustness, while incurring zero clean accuracy degradation. Our code is available at: https://github.com/awlliom/GradientConfusion.

Keywords Machine Learning, Adversarial Defense, Robustness, Adversarial Learning

1 Introduction

Modern machine learning systems are often deployed via remote interfaces (e.g., cloud APIs and online services), where users interact with models only through query access. In this setting, standard white-box threat assumptions (Szegedy et al., 2014; Goodfellow et al., 2015; Moosavi-Dezfooli et al., 2016; Carlini and Wagner, 2017; Athalye et al., 2018a; Madry et al., 2018) are frequently unrealistic, yet query-based black-box attacks remain highly effective even without access to model parameters, gradients, or training data (Ilyas et al., 2018; Al-Dujaili and O'Reilly, 2020; Andriushchenko et al., 2020; Cheng et al., 2020; Guo et al., 2019; Ilyas et al., 2019; Vo et al., 2024; Reza et al., 2025; Chen and Gu, 2020; Chen et al., 2020; Reza et al., 2023). By adaptively probing the model and observing outputs, adversaries can craft adversarial examples under practical query budgets, making black-box robustness a core requirement for secure and trustworthy deployment.

Query-based black-box attacks are commonly divided into decision-based attacks (Cheng et al., 2020; Chen and Gu, 2020; Chen et al., 2020; Reza et al., 2023), which rely only on predicted labels and search for the decision boundary, and score-based attacks (Andriushchenko et al., 2020; Al-Dujaili and O'Reilly, 2020; Guo et al., 2019; Ilyas et al., 2019; Vo et al., 2024), which use logits or class probabilities to estimate gradients via finite-difference or search-based strategies. In practice, score-based attacks are typically more query-efficient and achieve higher success rates, posing a serious risk to deployed classifiers that must return confidence scores. As a result, a large body of work (Qin et al.,

∗^{*}Corresponding author

2021; Xie et al., 2018; He et al., 2019; Chen et al., 2022; Aithal and Li, 2022; Dashtbani et al., 2026; Hung-Quang et al., 2024; Wang et al., 2021) has proposed defenses, most of which introduce randomness into model responses (Qin et al., 2021; Aithal and Li, 2022; Dashtbani et al., 2026; Hung-Quang et al., 2024). While such methods can increase variance or slow optimization, they do not explicitly control the gradient signal exposed through outputs, allowing attackers to average over randomness (Athalye et al., 2018b) or increase the query budget to recover stable estimates when meaningful scores must be preserved.

In this work, we revisit black-box defense from a different perspective and ask: What gradient signal should a model expose to an adversary? Instead of relying on stochastic perturbations, we propose to actively manipulate the gradient information inferred from model outputs. Our goal is not merely to add noise, but to deliberately bias the gradient estimates or search directions that score-based attacks attempt to recover, steering them away from directions that reduce the classification margin.

We study the problem of defending a fixed, pretrained target classifier against query-based black-box adversaries while preserving correct predictions and usable score outputs. We introduce a deterministic test-time response wrapper that modifies the returned probability vector without altering the classifier itself or its training procedure. The core idea is gradient confusion: we deliberately shape the output scores so that the induced adversarial loss gradient's direction deviates from the true adversarial loss gradient that score-based attacks seek to estimate. Using the loss gradients and Jacobian of the model's logits, we derive an analytic target direction that misaligns the attacker's search direction or estimated gradient, thereby increasing the number of queries required for successful adversarial example generation.

Building on a target confusion direction, we introduce the Gradient Confusion Defense (GCD), which formulates a constrained optimization problem over output probabilities to explicitly control the gradient signal exposed to score-based black-box attackers. GCD enforces three principled constraints at test time: exact preservation of the top-1 prediction to maintain clean accuracy, a bounded ℓ1\ell_{1} distortion on the returned probability vector to preserve the utility of confidence scores, and alignment of the exposed logit-gradient with a target confusion direction rather than the true gradient.

The main contributions of this work are threefold.

• We propose the Gradient Confusion Defense (GCD), a practical, retraining-free test-time defense that explicitly controls the gradient signal exposed through model outputs in the score-based black-box threat model.

• We theoretically analyze how GCD forces the adversary to issue more queries to generate a successful adversarial example using gradient estimation-based and search-based attacks.

• Extensive experiments show that GCD substantially reduces attack success rates while preserving clean accuracy, and further validate our theoretical analysis and demonstrate the effectiveness of our defense against several state-of-the-art query-based and adaptive attacks.

References (40)