AI State of the Art
SOTA/Security & Interpretability/38 min
Section 180

Adversarial Attacks: FGSM, PGD and Model Robustness

Listen as a podcast →

A stop sign that becomes a speed limit sign

In 2017, a research team stuck a few black-and-white stickers on a real stop sign by the side of a road. To a human driving past: nothing unusual, it is obviously a stop sign. To the image classifier they were attacking: a 45 mph speed limit sign.

Robust Physical-World Attacks on Deep Learning Visual Classification (Eykholt et al., 2017)

Let us put the exact figures up front, because that is where everything is decided. The paper's abstract reports 100% targeted misclassification on photographs taken in lab conditions, and 84.8% of the frames of a video shot from a moving vehicle. Two qualifications the paper states and that retellings almost always drop:

  • 100% is an attack success rate, not a model confidence. These are two different quantities: the first counts the share of images that were fooled, the second is the score the model attaches to its answer on one given image. Confusing them makes the paper say something it does not say.
  • The attack was computed in a white-box setting: the authors had the classifier's parameters, and the classifier was their own, a network they had trained on a public road-sign dataset, not the perception stack of a commercial vehicle.

Put differently: no server was breached, no credentials were stolen, it really was paper and glue, but with full access to the model at the moment of computing where to stick the paper. Taking that access away makes the attack considerably harder without making it impossible, which is the subject of the black-box section below.

This class of attack is called an adversarial attack: a perturbation, often imperceptible to a human, designed specifically to fool a machine learning model. It is not an incidental defect, it is a structural fragility of deep networks, still unresolved after more than ten years of active research.

How to read an attack success rate

This page quotes several percentages. None of them means anything on its own. Faced with any attack success rate, you need five answers:

  1. Which model, which version? An attack published against a 2017 model says nothing about a 2026 model.
  2. White box or black box? Did the attacker hold the parameters, or only see the answers?
  3. What budget? How many queries to the model, how many optimisation steps, how large a perturbation was allowed?
  4. Targeted success or mere error? Making a classifier say "anything but stop" is far easier than making it say "speed limit 45".
  5. Has the model been fixed since? Many celebrated attacks no longer work on current versions, and the publication never says so.

The general method is set out in how to read a benchmark score. A robustness claim that does not answer these five questions is not false: it is simply untestable.

Why models are fragile

High-dimensional space

To see the problem, you have to think in terms of dimensions. A 28-by-28 pixel image holds 28 × 28 = 784 values, so you can regard it as a single point in a 784-dimensional space, one dimension per pixel. In that space, the classes (dog, cat, car) occupy regions separated by decision boundaries the model learned during training. For the vocabulary here (dimension, vector, learned parameter versus computed value) see how to read the formulas in this course.

The problem: in high dimensions, those boundaries are locally very close to legitimate data points. This is counterintuitive, we picture classes as well-separated countries on a map. In reality it is more as if every country had a border a few millimetres away, in certain directions.

The geometric intuition

In 2 dimensions, crossing a boundary means walking in one particular direction. In 784 dimensions there are 784 directions to try. Even if the boundary is far away in most of them, it only has to be close in one for an adversary to use it. The more dimensions, the more "short paths" to the boundary. That is why the problem gets worse as images get larger.

The famous panda-gibbon example

In 2014, Ian Goodfellow and colleagues at Google Brain published what remains the most iconic example in the field.

Explaining and Harnessing Adversarial Examples

They take an image of a panda, correctly classified with 57.7% confidence. They add a computed perturbation (structured noise, invisible to the naked eye) and get a visually identical image. The network now calls it a gibbon with 99.3% confidence.

The added perturbation is so small that with the two images side by side you will see no difference whatsoever. And yet it did not merely flip the prediction: it sharply raised the model's confidence in the wrong answer. The model is not just fooled, it is convinced.

Three images in a row joined by a plus sign and an equals sign. On the left, a photo of a panda labelled Panda with 60 percent confidence. In the middle, a square of random colored noise labelled Adversarial Perturbation. On the right, a panda photo visually identical to the first one, labelled in red Gibbon with 99 percent confidence.
The left and right images are indistinguishable to a human eye. The only difference is the noise square in the middle, added at a tiny amplitude. Yet the model flips from panda to gibbon, and its confidence climbs from 60 to 99 percent.Source : Goodfellow et al. 2014 paper (figure 1), via Kaushalya Madhawa

The gradient sign method, or FGSM

The founding attack is the Fast Gradient Sign Method, almost always shortened to FGSM. It is the simplest and the most instructive: it turns against the model the very tool that trained it, backpropagation.

The whole algorithm fits on one line:

xadv=x+ε⋅sign(∇xL(θ,x,y))x_{adv} = x + \varepsilon \cdot \text{sign}(\nabla_x \mathcal{L}(\theta, x, y))

Naming every symbol:

  • xx is the original image, untouched. It is data, not a model parameter.
  • xadvx_{adv} is the doctored image being built (adv for adversarial).
  • θ\theta (theta) stands for the model's learned parameters. They are frozen here: we are not training, we are attacking.
  • yy is the image's correct label ("panda").
  • L\mathcal{L} is the loss function: a number measuring how far the model's answer is from yy. The larger it is, the more wrong the model.
  • ∇x\nabla_x ("gradient with respect to xx") is the list of sensitivities of the loss to each pixel: how much the loss rises if you brighten this pixel very slightly.
  • sign\text{sign} keeps only the direction: each pixel gets +1+1 or −1-1, depending on whether it should be brightened or darkened. The magnitude of the gradient is thrown away.
  • ε\varepsilon (epsilon) is the budget the attacker allows themselves: every pixel moves by exactly ε\varepsilon, one way or the other.

The formula in one sentence: for each pixel, ask which way to push it so the model gets it more wrong, then push it that way by the largest small step you have allowed yourself.

How this differs from ordinary training

In training you differentiate the loss with respect to the model's learned parameters and change them: you change the model so it makes fewer mistakes. Here you differentiate the same loss with respect to the image's pixels and change those: you change the data so the model makes more mistakes. The model does not move at all; the image slides toward the wrong class. Same mathematical tool, inverted goal, and exactly the learned-parameter versus computed-value distinction described in how to read formulas.

FGSM is a single-step attack. It is very fast (one gradient computation) but not the most effective. Setting ε\varepsilon is a trade-off: too large and the perturbation becomes visible to the eye; too small and it fails to cross the decision boundary.

Projected gradient descent, or PGD

The iterative version of FGSM is Projected Gradient Descent, shortened to PGD, proposed by Madry and colleagues in 2017.

Towards Deep Learning Models Resistant to Adversarial Attacks

Instead of one large step, PGD chains many small steps of the same kind, pulling the perturbation back inside a ball of radius ε\varepsilon at every stage, that is, making sure no pixel has drifted more than ε\varepsilon from its original value. That is what "projected" means: as soon as a step leaves the permitted zone, you come back to its edge. The analogy: FGSM fires one arrow in the rough direction of the boundary; PGD corrects its course at every iteration.

How it runs:

  1. Start from a random point inside the ball around xx
  2. Take a step along the sign of the gradient, of size α\alpha (alpha), smaller than ε\varepsilon
  3. Pull the result back inside the ball of radius ε\varepsilon
  4. Repeat a certain number of times

That "certain number of times" is not a technical footnote: it is a protocol parameter, and it changes the result. The original paper does not use the same budget to train a robust model and to evaluate one, evaluation is far more expensive, since there you are hunting for the worst possible perturbation. A robustness figure quoted without the attack's iteration count is therefore not comparable to any other.

PGD is considered one of the strongest white-box attacks, meaning full access to the model's parameters and gradients. If a model withstands a properly run PGD, that is a serious signal of robustness, a signal, not a proof.

PGD as the standard evaluation tool

Madry et al. proposed treating PGD as the reference attack for evaluating robustness. The argument: PGD approximates the worst perturbation available inside the epsilon ball, so a model robust to PGD should be robust to a whole class of white-box attacks. The practice became standard in the literature.

Black-box attacks and transferability

The attacks above need access to the model's gradients: that is the white-box setting. In a real deployment you usually see only the model's answers, not its architecture, not its parameters, just its predictions. That is the black-box setting.

Two approaches keep the attack alive there:

Transfer. You train your own stand-in model on data of the same kind, build the attack against that model, then apply it to the target. It often works, at least partly. The reason: different models trained on comparable data learn similar decision boundaries and inherit the same weak spots.

Gradient estimation by querying. You reconstruct the sensitivities by querying the model hundreds or thousands of times with small random perturbations and watching how its scores move. Slow and expensive, but it converges.

What black box changes when you read a result

Here the decisive quantity is the query budget. A black-box attack that succeeds "80% of the time" in ten queries and one that succeeds 80% of the time in fifty thousand queries describe two different worlds: the second is often unusable in practice, because a service receiving fifty thousand anomalous requests from one account notices. A black-box success rate without a query budget is therefore close to empty information.

Where it matters

Autonomous vehicles

Defaced road signs are only the visible part. Attacks aimed jointly at cameras and lidar (Light Detection And Ranging, laser ranging, which measures distances rather than taking pictures) raise a question with no settled answer: is a multi-sensor system more robust because you now have to fool both, or less robust because it offers two attack surfaces instead of one?

A table of photographs of real road signs carrying physical adversarial perturbations, shot at various distances and angles from 5 feet to 40 feet and from 0 to 30 degrees. The columns show several attack variants: a subtle poster pasted over the sign, a right-turn sign, camouflage graffiti spelling LOVE and HATE, and black and white patches resembling street art. The last row gives the targeted-attack success rate, between 66 and 100 percent.
Each column is a different way of physically defacing the sign, each row a shooting distance and angle. To a human, all of these remain obvious stop signs. To the classifier they become speed limit signs, with success rates ranging from 66 to 100 percent depending on the variant.Source : Eykholt et al. 2018, Robust Physical-World Attacks (table 1), via a CSDN blog post

Medical imaging

A model classifying X-rays or histology slides can be fooled by a digital perturbation in exactly the way a photo classifier can: same mechanism, same kind of data. That much is demonstrated and uncontested.

You will also frequently read that physical perturbations have been printed onto laboratory slides to fool an analysis model. We could not trace a reliable source for that claim; as things stand it should be treated as unestablished. The general lesson still holds: the physical route is demonstrated on road signs and on faces, and there is no reason of principle why it should be impossible elsewhere, but "no reason of principle" is not a demonstration.

Facial recognition

Researchers showed in 2016 that a pair of glasses carrying a purpose-computed printed pattern lets someone impersonate another person in front of a face recognition system, or stop being recognised at all. The reference work is Sharif and colleagues, Accessorize to a Crime.

Three qualifications decide what that result licenses you to claim:

  • The study is mainly white box: the authors held the parameters of the systems they attacked. Black-box variants are explored, but that is not the main regime.
  • Impersonation success rates vary enormously with the pair of faces involved: the paper reports cases above 85% and others around 16%. Quoting the best figure as if it were the study's result is the commonest form of overreach in this area.
  • "Fooling a face recognition system" is not "fooling the face recognition system at an airport in 2026". Which model, which version, and what human checks sit around it make all the difference.
The chain of an impersonation attack. On the left, actor Hugh Laurie's face wearing a plain yellow eyeglass frame. Next, the same face with the frame covered by a multicolored adversarial pattern. That face is fed to a face recognition system, drawn as a cube. On the right, the system's prediction: actor Viggo Mortensen, a different person.
The pattern printed on the frame is computed to push the face toward the target identity in the model's representation space. The result: the system identifies the person on the left as the one on the right. Nothing was hacked, a pair of glasses was simply printed.Source : Inovex, Robustifying Machine Perception for Face Recognition Systems (after Sharif et al.)

Defenses

Adversarial training

The strongest empirical defense known today is to build the deceptive examples yourself (usually with PGD) and fold them into the training data, each relabelled with its correct answer. The model then learns to answer correctly despite the perturbation.

min⁡θE(x,y)[max⁡δ∈SL(θ,x+δ,y)]\min_\theta \mathbb{E}_{(x,y)} \left[ \max_{\delta \in S} \mathcal{L}(\theta, x + \delta, y) \right]

The symbols, in reading order:

  • min⁡θ\min_\theta: we look for the learned parameters θ\theta that make the whole thing as small as possible. That is training.
  • E(x,y)\mathbb{E}_{(x,y)} ("expectation"): the average over all image-label pairs in the dataset.
  • δ\delta (delta): the perturbation the attacker adds. It is a computed quantity, not a model parameter.
  • SS: the set of permitted perturbations, in practice the ball of radius ε\varepsilon described above.
  • max⁡δ∈S\max_{\delta \in S}: among all permitted perturbations, keep the worst one, the one that maximises the error.
  • L\mathcal{L}: the same loss function as in FGSM.

The formula in one sentence: train the model not to answer well on the image, but to answer well on whichever version of the image the attacker would have chosen. The outer minimum is the defense, the inner maximum is the attack, and the two are nested.

The cost follows straight from that nesting. Building one example with a kk-step attack takes kk extra gradient computations per batch. Adversarial training therefore costs roughly k+1k+1 times the compute of ordinary training: a handful for a short attack, several dozen times for a long one. This factor is not an engineering detail, it is why the method stays rare outside research.

Robust against what? The question that empties most claims

Adversarial training does not produce "a robust model". It produces a model robust against the family of perturbations it was shown, defined by the shape of the ball SS and by the value of ε\varepsilon. Change the shape or widen the radius and much of the acquired robustness collapses.

Two consequences when reading a claim:

  • Robustness announced without its threat model (which family of perturbations, what magnitude, what attack budget at evaluation time) states nothing testable.
  • Accuracy under attack still sits well below accuracy on clean data. A robust model is one that has agreed to see slightly worse in normal conditions in order to be wrong less often when attacked. That is not a free gain, it is a trade.

Certified robustness

Rather than probing robustness by launching an attack and seeing whether it holds, certified robustness methods produce a proof: no perturbation of a given size can change the prediction on that particular input.

Two main families:

  • Interval Bound Propagation, abbreviated IBP: instead of pushing a value through the network, you push an interval ("this pixel lies between 0.48 and 0.52"), layer after layer, until you get bounds on the output scores. If the interval of the correct score stays above all the others, the prediction is certified.
  • Randomized smoothing: you evaluate the model on a large number of noisy copies of the input and take the majority vote. You then prove a guarantee about that noisy classifier (not about the original model) and the guarantee is probabilistic: it holds at a stated confidence level, because it rests on a finite sample of random draws.
Certified Adversarial Robustness via Randomized Smoothing (Cohen et al., 2019)

The number worth carrying away from that paper is in its abstract: on ImageNet, a certified top-1 accuracy of 49% for perturbations whose Euclidean norm stays below 0.5.

Let us measure what "0.5" allows. An ImageNet image is 224 by 224 pixels in three colours, so 224 × 224 × 3 ≈ 150,000 values between 0 and 1. A perturbation of Euclidean norm 0.5 can be spent in two extreme ways: concentrated on one pixel, moved by 0.5, half the scale, plainly visible; or spread evenly over all of them, each moving by 0.5/150,000≈0.00130.5 / \sqrt{150{,}000} \approx 0.0013, which is a third of one step on a 0-to-255 scale. So the certificate is real, it covers a minuscule radius, and it comes at roughly half the accuracy.

Certified is not safe

A certificate is a conditional proof: it establishes that a perturbation of a certain shape and a certain size cannot change the answer. It says nothing about what an attacker actually does, repaint the sign, photograph it from another angle, replace the object altogether. None of that fits inside a small ball around the original image.

Faced with a certified-robustness claim, the three questions are therefore: certified against which family of perturbations, up to what radius, and at what cost in accuracy. All three answers are always in the paper; they almost always vanish in the retelling.

Preprocessing and purification

A third route: detect or "clean" suspicious inputs before they reach the model. The usual techniques are JPEG compression, which destroys the very fine-grained patterns many perturbations rely on; denoising with a diffusion model; and anomaly detection on the input.

The problem is structural: these methods fall to adaptive attacks, which fold the filter into their own optimisation. If the attacker knows a JPEG filter sits in front of the model, they build a perturbation that survives it. A defense evaluated only against attacks that ignore it has not been evaluated.

The arms race continues

Many published defenses were circumvented within months by an adaptive attack, to the point where the literature acquired methodological guidance meant to stop illusory robustness from being published. Adversarial robustness remains an open problem. There is no universal solution, only defenses that raise the cost of an attack without making it impossible.

Key takeaways

Adversarial attacks are not a defect that a patch will one day close. They reveal something about how these models learn: they retain statistical regularities of the training data, not an understanding of the world. A classifier does not learn "this is a panda"; it learns "this pixel distribution is statistically associated with the label panda". Nothing in that learning requires the two to coincide everywhere.

Three ways to sort what you read on the subject:

  • What is demonstrated: the attacks work, including in the physical world, and including without access to the model's parameters via transfer; adversarial training genuinely improves resistance to the family of perturbations it covered; some guarantees really are proved, over small radii.
  • What is hoped for: a defense that holds against attacks nobody has thought of yet, and robustness that costs no accuracy.
  • What is structurally out of reach: a proof that the model "will not be wrong". A certificate always concerns a family of perturbations fixed in advance. An attacker is under no obligation to stay inside it.

A robustness claim therefore reads like a benchmark score, with the same grid: against what, measured how, at what price. The method is in how to read a benchmark score.

Check your understanding0 / 5

1. A paper reports a 100 percent success rate for a sticker attack on a stop sign. What should you check before drawing general conclusions?

2. How does the FGSM formula differ from an ordinary training step, given that it uses the same mathematical tool?

3. An AI service exposes only its predictions, no architecture, no parameters. Why can attack transfer still work?

4. After careful adversarial training, can you say the model has become robust?

5. What exactly does certified robustness of the kind « 49 percent certified accuracy on ImageNet below norm 0.5 » guarantee?