Mahir Shahriar Tamim

AI Researcher · Explainable & Responsible AI · Vision, Language & Agentic Systems

Part 4 of Adversarial Attacks

Defences, and how most of them broke

Module 4 · 7 min read

Defences, and how most of them broke

TL;DR

  • Most 2015–2018 defences just hid gradients or tried to detect attacks, and adaptive attacks (C&W, BPDA, EOT) broke them.
  • PGD adversarial training holds up, with about 87% clean and 46% robust accuracy on CIFAR-10, for several times the training cost.
  • Randomized smoothing proves a radius. AutoAttack and RobustBench made testing honest.

A lot of broken locks

Between 2015 and 2018 dozens of defences reported great results and were broken soon after, often by the same few researchers and for the same reason. Only adversarial training and certified defences held up.

Defensive distillation, and the C&W attack

Defensive distillation (Papernot et al., 2016) trained a second network on a first one’s “soft” probability outputs at a high temperature. The result was so flat around the data that the gradients FGSM and JSMA follow became tiny, and reported attack success dropped dramatically.

A year later Carlini and Wagner (module 2) showed it wasn’t more robust. Its gradients were just numerically useless, and by attacking the logits before the softmax they beat it essentially every time. Making gradients unhelpful only hides the adversarial examples.

Obfuscated gradients (the big lesson of 2018)

Obfuscated Gradients Give a False Sense of Security (Athalye, Carlini & Wagner, ICML 2018 best paper) checked the nine white-box defences accepted at ICLR 2018. Seven relied on obfuscated gradients, and each flavour has a counter.

  • Shattered gradients. A non-differentiable step (rounding pixels, JPEG compression) makes the gradient missing or wrong. Treat that step as the identity when computing the gradient (BPDA).
  • Stochastic gradients. Randomness (random resizing, dropped pixels) sends each gradient somewhere different. Average over many random draws (Expectation over Transformation, module 3).
  • Vanishing or exploding gradients. A very deep process, like an iterative “purifier”, makes the gradient useless. Rewrite the problem.

Six of the seven fell completely and the seventh partly.

Rule of thumb from this era. Be suspicious if a black-box attack beats the white-box one, or if a much larger ε still can’t reach full success. An unlimited budget always wins, even against a genuinely robust model, and stronger attacks never do worse than weaker ones.

Detection and input cleaning

Detectors (separate networks, statistical tests) and input cleaning (denoisers, JPEG compression, bit-depth reduction) did no better. Carlini and Wagner bypassed all ten detection methods they tested in Adversarial Examples Are Not Easily Detected (2017), mostly by attacking classifier and detector together. Cleaning mostly fell to BPDA.

Adversarial training held up

This is Goodfellow’s 2015 idea, done properly by Mądry et al. For every batch, PGD finds the worst-case version of each example within the ε budget and you train on those, so the boundary stays away from the data.

for each batch (x, y):
    x_adv = PGD(model, x, y, ε)        # the hardest version of each example
    update the model to classify x_adv as y

It’s still the backbone of the most robust image models, but it costs you.

  1. Slow. Each training step runs a multi-step attack first, so training costs several times more.
  2. Lower clean accuracy. To keep a wide margin the model gives up some examples sitting awkwardly close to the other class. On CIFAR-10, Mądry’s robust model got about 87% on clean images, a normal one about 95%.
  3. Only partly robust. It kept roughly 46% accuracy under strong PGD at ε = 8/255, where a normal model drops to almost zero. Far better, still far from solved.

class Aclass Bcan be flipped

Model

A red circle means the boundary passes inside that point’s ε-circle, so an attacker can flip it. The adversarially trained boundary flips almost nothing, at the price of one awkward point.

TRADES (Zhang et al., 2019) made the trade-off explicit, with one loss term for clean accuracy, one keeping the adversarial prediction close to the clean one, and a knob between them. It won the NeurIPS 2018 Adversarial Vision Challenge and became the other standard recipe. For a fixed model size and amount of data the trade-off usually remains, but more data (including generated data) and bigger models have narrowed it a lot, as RobustBench shows.

Certified defences give a guarantee

All of that is empirical (“we attacked it hard and it held”), and history says that’s no promise. Certified defences prove that no change within some radius of a given input can alter the answer.

The most practical is randomized smoothing (Cohen, Rosenfeld & Kolter, 2019), which wraps any classifier. Classify many copies of the input with random Gaussian noise added and return the majority class. If the top class wins with probability p, the paper proves no L2 change smaller than this can flip the vote.

R = σ × Φ⁻¹(p)

Here σ is the noise level and Φ⁻¹ the inverse of the normal CDF. More noise gives bigger guarantees but more wrong votes, so it’s the robustness–accuracy trade-off as a dial.

votes for Avotes for Bcertified radius

The base classifier has a thin red “spike” right next to the input, so a tiny step would fool it. The smoothed classifier ignores it because few noisy copies land there. The real method also uses a statistical lower bound on p, which this toy skips.

Other certified methods bound the network directly. Interval bound propagation (Gowal et al., 2018) pushes a whole box of inputs through layer by layer and checks that every possible output still picks the right class. The proof covers every change in the radius, even ones no attack would find, so the bounds are conservative and the radii much smaller than what empirical defences resist. Still, they’re guarantees.

Testing defences properly

Many broken defences were just badly tested, with a weak attack, a wrong step size or too few iterations. AutoAttack (Croce & Hein, 2020) is a standard ensemble of four strong attacks that need no tuning. On dozens of published defences it found lower robustness than reported for almost all, often by a lot. RobustBench turned it into a public leaderboard so defences share one test.

DefenceIdeaStatus
Defensive distillationFlatten gradientsBroken (C&W, 2017)
Input transformations, randomisationClean or scramble the inputMostly broken (BPDA, EOT)
DetectorsSpot adversarial inputsMostly broken
PGD adversarial training, TRADESTrain on worst-case examplesHolds, partially robust, costly
Randomized smoothing, IBPProve a radiusHolds by proof, small radii

Quick check

A new defence makes PGD fail completely, but a simple black-box attack still succeeds often. What is the most likely explanation?

Q&A

Why not just train on FGSM examples? It is much cheaper.

Early FGSM training resisted FGSM but not stronger attacks, because models learned to make the single-step gradient misleading. “Fast is better than free” (Wong et al., 2020) showed it can work with a random start and care, but multi-step PGD is the safer default.

Does robustness to L∞ protect against L2 attacks or patches?

Only partly. Robustness tends to be specific to the threat model you trained for, so a model trained against small L∞ changes can still fall to a visible patch or a rotation.

Papers