Adversarial Robustness Benchmarks (RobustBench): Certification and limits of robustness claims
What RobustBench measures
RobustBench is a standardized benchmark and model collection for evaluating adversarial robustness. An evaluation fixes the dataset, model, preprocessing, perturbation norm, and perturbation budget before measuring how often predictions remain correct under attack. Running a benchmark does not train a defense or certify a model. See the [official RobustBench project](https://github.com/RobustBench/robustbench).
Threat model and notation
Let $x$ be an input vector and $y$ its correct class. Let $f_\theta$ produce class scores, $h_\theta$ select a class with a fixed tie rule, and $\mathcal{L}$ be a classification loss. For images scaled to $[0,1]^d$, the allowed perturbations are:
The original input stays fixed throughout an attack. A perturbation budget applies in the declared input coordinates; changing normalization without transforming the budget changes the experiment. For example, an illustrative pixel budget of $8/255$ on the zero-to-one scale is about $0.03137$, not eight input units. This example is not a universal budget for every dataset or leaderboard.
| Symbol | Meaning | Scale or constraint |
|---|---|---|
| $x,\delta$ | Original input and perturbation | Same input coordinates |
| $p$ | Norm defining the threat set | Common examples: $2$ or $\infty$ |
| $\epsilon$ | Maximum perturbation norm | Nonnegative, fixed for the comparison |
| $\alpha$ | Attack step size | Same input scale as $x$ |
| $\theta$ | Model parameters | Fixed during evaluation |
| $n$ | Number of evaluated examples | Positive integer |
Adversarial training is a separate optimization problem
The inner optimization searches for high-loss inputs while keeping the model fixed; the outer optimization updates the model. Practical attacks approximate the inner maximum. A successful training run does not establish a proof of worst-case robustness. This formulation follows [Madry and colleagues](https://arxiv.org/abs/1706.06083).
Correct projected gradient attack
For untargeted $\ell_\infty$ loss ascent, write the update in perturbation coordinates:
For each input coordinate, projection clips the proposed perturbation to these bounds:
This enforces both distance from the original input and the valid image range. Projecting the perturbed image onto a ball centered at zero is a different, incorrect constraint. The sign direction above is specific to the infinity norm; an L2 attack needs an appropriate direction and projection. Targeted attacks optimize a different objective. Preserve any successful adversarial examples across iterations and restarts instead of reporting only the final iterate.
Clean, empirical, and certified accuracy are different
Clean accuracy is the fraction of original inputs classified correctly:
Here $c_i=1$ if $h_\theta(x_i)=y_i$, and $c_i=0$ otherwise.
For an attack collection $\mathcal{A}$, let $S_i$ include the original input and every valid attack candidate retained for example $i$. Accuracy against those candidates is:
Here $s_i=1$ exactly when every retained candidate in $S_i$ is classified as $y_i$; otherwise $s_i=0$.
The ideal robust accuracy checks the entire allowed set:
Here $r_i=1$ exactly when every allowed perturbation in $\Delta_p(x_i)$ preserves the correct label $y_i$; otherwise $r_i=0$.
Consequently, on the same examples and threat model:
An attack can discover a failure but can miss one. Its surviving-example accuracy is therefore an upper bound on the true robust accuracy of this finite sample, not a robustness certificate. Adding valid candidates to the retained set cannot increase that empirical accuracy. Generalization from a finite sample to a population is a separate statistical question.
Standardized attacks and adaptive checks
AutoAttack combines complementary attacks. Its documented standard configuration uses APGD with cross-entropy, targeted APGD with a logit-ratio loss, targeted FAB, and the query-based Square Attack. Record the actual package version and configuration; do not assume every mode uses the same attacks or query limits. See [AutoAttack's maintained documentation](https://github.com/fra31/auto-attack).
RobustBench's documented restrictions for its standardized adversarial evaluation include generally nonzero input gradients, a deterministic forward pass, and no optimization loop inside inference. Adaptive evaluation complements standardized attacks. Check the current protocol for the selected track rather than assuming that a stochastic defense, a purification pipeline, or a new attack type is covered automatically.
Why gradient masking matters
Vanishing, discontinuous, or misleading gradients can make a defense appear strong against an inadequate gradient attack. Compare losses, restart counts, transfer attacks, and query-based attacks; inspect numerical failures and unexpected sensitivity to attack settings. A weaker attack finding more failures than a supposedly stronger one is a reason to investigate. No single diagnostic proves the absence of masking.
Randomized smoothing: a distinct certificate
For a base classifier $h$, define a smoothed classifier by its most probable prediction under Gaussian noise:
If a valid lower bound $\underline p_A$ on the selected class probability exceeds a valid upper bound $\overline p_B$ on every other class probability, the smoothing radius is:
Here $\Phi^{-1}$ is the standard normal inverse cumulative distribution function, and $\sigma>0$ is the noise standard deviation. The result certifies the smoothed classifier for perturbations with $\ell_2$ norm strictly below $R$, under its assumptions. Monte Carlo estimates require valid confidence bounds; raw frequency estimates are insufficient. Abstain when the required separation cannot be established. This is not an infinity-norm certificate or a certificate produced by AutoAttack. See [Cohen, Rosenfeld, and Kolter](https://proceedings.mlr.press/v97/cohen19c.html).
A defensible evaluation workflow
- Fix the dataset, split, example IDs, labels, input range, preprocessing, norm, budget, and attack objective before comparison.
- Freeze the checkpoint and evaluation code. Keep training and tuning data separate from the held-out benchmark; temporal splits are relevant only when the data and question require them.
- Measure clean accuracy, then retain the union of valid failures found by the specified attack suite and any justified adaptive checks.
- Verify every candidate's norm and input range. Apply gradients through the actual preprocessing path; inference mode does not mean disabling gradients needed by an attack.
- Record attack versions, steps, restarts, seeds, batch size, query budget, numerical precision, hardware, runtime, and failure logs.
- Report the denominator, clean accuracy, attack-based accuracy, and any separately computed certificates. Label a subset run as a subset run.
- Publish configuration and limitations. Do not infer robustness to physical changes, distribution shift, fraud, or prompt injection from an image perturbation benchmark alone.
Controls that must not be confused
| Control | Role | Correct treatment |
|---|---|---|
| Perturbation budget | Defines the evaluation problem | Hold fixed across a comparison; label any budget sweep |
| Attack steps and restarts | Search effort | Check adequacy and preserve previously found failures |
| Training regularization | Model selection | Tune on validation data, not leaderboard test labels |
| Smoothing noise | Defines a different classifier | Report clean and certified performance separately |
| Runtime and memory | Resource measurements | Record hardware and actual workload |
A general weighted objective is optional model-selection notation, not RobustBench's scoring rule:
Here $\lambda$ denotes a candidate configuration, $F_j$ defined validation costs, and $w_j\ge0$ declared weights. Scale the costs explicitly and keep the final test set untouched. The threat model is not a parameter to quietly relax in order to improve a reported score.
Extended study: what a certificate actually says
Certification requires a specified classifier, input, perturbation set, and proof procedure. Attack-based survival and certified accuracy cannot be substituted for each other. A radius proves prediction stability; certified correctness additionally requires that the stable prediction equal the true label.
For a fixed classifier with sound certificates, define certified accuracy at a requested radius $r$ as the fraction of all evaluated examples with a correct prediction and a certificate covering that radius. If a theorem guarantees only distances strictly below its radius, use $R_i>r$ for a closed threat ball. Include abstentions and uncertified inputs in the denominator as non-certified examples.
Linear boundary check
For a binary linear classifier with a nonzero weight vector, away from its decision boundary, the distance to that boundary in unbounded input space is:
Its prediction is unchanged for perturbations strictly smaller than this distance. This elementary result is not a general neural-network certificate. Intersecting the threat set with valid input bounds can make the nearest feasible label change farther away. The lab below computes the exact answer for a clipped infinity-norm box, which is a different threat model from this Euclidean-distance formula.
When results do not transfer
A certificate for the smoothed classifier does not automatically certify its unsmoothed base model. Likewise, a perturbation guarantee does not establish resistance to poisoning, semantic changes, natural corruptions, or a new deployment distribution. Keep those evaluations separate and state the scope of each claim.
Runnable lab: exact robustness of a tiny linear classifier
This standalone Python 3 exercise uses only the standard library. It constructs synthetic two-dimensional inputs and fixed labels, evaluates a fixed classifier, and compares projected loss-ascent with an independently enumerated worst-case corner. There is no training or preprocessing fit, so no validation information can leak into a fitted transformation. It is a geometry and accounting exercise, not a RobustBench run or an image-model benchmark.
For a linear signed margin over a rectangular threat set, a minimizing point is a corner. The code enumerates all four corners as an independent check, verifies pixel bounds and perturbation budgets, and checks that exact robust accuracy never exceeds clean accuracy or increases as the allowed set grows. The deterministic tie rule is explicit.
"""Synthetic linear-classifier exercise, not a RobustBench score."""
import itertools
import math
import random
rng = random.Random(7)
weights = (1.2, -0.8)
bias = -0.1
points = [(rng.random(), rng.random()) for _ in range(200)]
def score(x):
return sum(w * value for w, value in zip(weights, x)) + bias
def predict(x):
return 1 if score(x) >= 0.0 else -1
# Synthetic labels use a different boundary from the evaluated classifier.
labels = [1 if x[0] - x[1] > 0.0 else -1 for x in points]
def bounds(x, epsilon):
assert epsilon >= 0.0
return [(max(0.0, v - epsilon), min(1.0, v + epsilon)) for v in x]
def worst_point(x, y, epsilon):
# Minimize signed linear margin over the clipped L-infinity box.
return tuple(lo if y * w >= 0.0 else hi
for w, (lo, hi) in zip(weights, bounds(x, epsilon)))
def pgd(x, y, epsilon, steps=40):
# Binary logistic-loss ascent has direction -y * sign(weights).
z = list(x)
step = 2.0 * epsilon / steps
for _ in range(steps):
for j, (lo, hi) in enumerate(bounds(x, epsilon)):
direction = -y * (1 if weights[j] > 0 else -1)
z[j] = min(hi, max(lo, z[j] + step * direction))
return tuple(z)
clean = sum(predict(x) == y for x, y in zip(points, labels)) / len(points)
previous = clean
for epsilon in (0.0, 0.02, 0.05, 0.10, 0.20):
robust_count = 0
for x, y in zip(points, labels):
adversarial = worst_point(x, y, epsilon)
assert all(0.0 <= v <= 1.0 for v in adversarial)
assert max(abs(a - v) for a, v in zip(adversarial, x)) <= epsilon + 1e-12
vertices = itertools.product(*bounds(x, epsilon))
exact_margin = min(y * score(v) for v in vertices)
assert math.isclose(y * score(adversarial), exact_margin, abs_tol=1e-12)
assert math.isclose(y * score(pgd(x, y, epsilon)), exact_margin, abs_tol=1e-12)
# Resolve a zero margin using predict's declared tie rule.
robust_count += predict(adversarial) == y
robust = robust_count / len(points)
assert 0.0 <= robust <= previous + 1e-12 <= clean + 1e-12
previous = robust
print(f"epsilon={epsilon:.2f} clean={clean:.3f} exact_robust={robust:.3f}")
print("All feasibility, exact-margin, PGD, and monotonicity checks passed.")Expected lab results
| Perturbation budget | Clean accuracy | Exact robust accuracy |
|---|---|---|
| $0.00$ | $90.5\%$ | $90.5\%$ |
| $0.02$ | $90.5\%$ | $85.0\%$ |
| $0.05$ | $90.5\%$ | $76.5\%$ |
| $0.10$ | $90.5\%$ | $63.0\%$ |
| $0.20$ | $90.5\%$ | $31.0\%$ |
Move from the lab to RobustBench
Use the official project instructions for the selected dataset, supported model, and threat model. Pin the versions and checkpoint, use the expected input representation, and run a small smoke test before the full protocol. Keep this toy exercise's numbers out of any leaderboard report. The lab's exact corner argument relies on linearity and does not extend to nonlinear networks.
Review complete: keep the claim tied to its threat model, evidence, and evaluation protocol.