Zero Labs
Industry News / AI

Walls, Shields, and Illusions: Defenses and Their Limits

Source · Towards AI By Maede Torkian

From the publisher’s feed, collected in the ZeroLabs newsroom.

Essay #3 in the Humble Model SeriesI. Introduction: The Arms Race BeginsIn Essay #2, we saw the attack. A well-trained model, 99.19% accurate on clean MNIST, was silent about its own limits. Only 4.4% of images flipped within ε ≤ 0.40 using FGSM — but the model could not tell us which 4.4%. It outputs a confidence score near 1.0000 for both the robust majority and the fragile minority.That silence is the vulnerability.But the natural response is not silence — it is defense.”If the model is vulnerable to small perturbations, we will train it on those perturbations.” → Adversarial training”If the attacker uses gradients, we will hide the gradients.” → Gradient masking”If the decision boundary is sharp, we will smooth it.” → Defensive distillationIn this essay, we built all three of these defenses — and we tested them under the same attack budget. We will walk through each one, show what they achieved, and then show where they fall short.Because the pattern is not a failure of individual researchers, it is the nature of an adversarial game.The attacker adapts. The wall crumbles. And the game has no end.And beneath all of this — a question we will not fully answer until the bridge essay: what if the goal is not to be unbreakable, but to be undeluded?II. The Defenses We Will BuildWe ran three defenses ourselves, on the same baseline model, under the same attack budget. A fourth defense — gradient masking — is covered in the literature and included in our pattern summary, but we did not implement it here; it requires a dedicated attack (BPDA) to break, which deserves its own treatment.Defenses Types_ Picture by AuthorDistillation is the weakest of the three we built. That is not a flaw — it is a feature of the pattern. We include it because it illustrates the work → break → adapt cycle as clearly as any defense in the literature: promising results at first, then a gradual erosion as stronger attacks are developed. Its instability — the wider run-to-run variance we observed — mirrors exactly what Carlini & Wagner (2016) found: distillation’s smoothing is closer to a hiding place than a genuine fix.Each defense works for a while. Each one is published with promising results. Each one eventually falls.III. The Baseline: A Standard ModelBefore we defend, we must know what we are defending against.The following notebook implements the Fast Gradient Sign Method (FGSM) on a simple CNN trained on MNIST. The full, runnable notebook is available here:Adversarial-Notebooks/#3/Note02_Adversarial_Training_PGD.ipynb at master · Maee127/Adversarial-NotebooksModel Architecture```pythonclass CNN(nn.Module): def __init__(self, num_classes: int = 10):super().__init__()self.conv1 = nn.Conv2d(1, 16, kernel_size=3)self.conv2 = nn.Conv2d(16, 32, kernel_size=3)self.fc1: nn.Linear | None = Noneself.fc2 = nn.Linear(128, num_classes)…```We train a simple CNN on MNIST (same architecture as Essay #2). After 10 epochs:```📈 Baseline clean test accuracy: 99.00%```Then we attack it.FGSM attack (ε = 0.3)Baseline accuracy drops to 96.60%PGD attack (ε = 0.3, steps = 40):Baseline accuracy drops to 95.62% (lower than FGSM, as expected — PGD searches more of the neighborhood around each image before settling on a perturbation)Figure1- Model OutputFigure 1 shows the baseline model’s accuracy across the full epsilon range, from ε = 0.00 to 0.40:Baseline (undefended) model accuracy under PGD attack across ε = 0.00 to 0.40. The model degrades gently — from 99.0% at ε = 0 down to roughly 94.3% at ε = 0.4. There is no cliff. The undefended model is not fragile in the dramatic sense; it erodes steadily as the attack budget grows. This matters for what follows: the walls we build in Sections IV and V are not rescuing a model in freefall. They are pushing back a slope that was already gradual.IV. Wall #1: Adversarial Training with FGSMThe first defense is intuitive: if the model is vulnerable to adversarial examples, train it on those examples.We augment each batch with FGSM-generated adversarial examples. The model learns to classify both clean and perturbed inputs. Because it has only ever seen single-step perturbations, it learns to resist that specific direction of attack — not the broader neighborhood that a multi-step attack like PGD explores.After training:Clean accuracy: 99.08% (a marginal increase from baseline, not a drop — within the noise we would expect from a second training run)Accuracy under FGSM: 97.97% (significant improvement)Accuracy under PGD: 97.61% (improvement, but less than under FGSM)FGSM Training-Model OutputFigure 2 shows the FGSM-trained model compared to the baseline across all three evaluation conditions:The wall holds against FGSM. But PGD — a stronger attack that explores more of the space around each image — still finds cracks, eroding accuracy further than FGSM does against the same model.V. Wall #2: Adversarial Training with PGDIf FGSM is too weak, train with a stronger attack. PGD adversarial training is the current standard.We train the same architecture, but each batch is perturbed with PGD (ε = 0.3, 7 steps during training — fewer than the 40 used for evaluation, a standard compromise to keep training tractable). The training time increases significantly; each batch requires an inner optimization loop.After training:Clean accuracy: 99.08% — identical to the FGSM-trained model, and marginally higher than baselineAccuracy under FGSM (ε=0.3): 97.52%Accuracy under PGD (ε=0.3): 97.27%Model Comparison- Model OutputFigure 3 shows the PGD-trained model compared to baseline and FGSM-trained models across all three conditions:PGD training did not cost any additional clean accuracy in our run — both robust models landed at 99.08%, slightly above the 99.00% baseline. This is smaller than the trade-off sometimes reported in the literature, where more aggressive robust training measurably erodes clean performance. At this scale (a small CNN, MNIST, and a 7-step training attack), the cost was negligible. That is itself a finding worth stating plainly rather than assuming a textbook trade-off we did not actually observe.What we do see is a real ordering: PGD-trained robustness under PGD (97.27%) is slightly lower than FGSM-trained robustness under PGD (97.61%) in this run. That is a smaller gap than the literature would predict — PGD training is supposed to be the stronger defense against PGD attacks — and the difference here (0.34 points) is well within the range of run-to-run noise for a model this size. We note it rather than over-read it.The deeper problem remains regardless of which wall is marginally taller: adaptive attacks, designed specifically to break a known defense, will eventually succeed against either. The wall is higher, but it is not infinite.VI. The Pattern: Work → Break → AdaptThe table below summarizes all four defenses — the three we built ourselves, and gradient masking from the literature:Model Defenses Results_ Model OutputsThe first four rows are ours — the same model, the same attack budget, run on our own machine. The last row is documented in the literature and included to show the pattern generalizes beyond what we tested ourselves.Distillation is the clearest illustration of the work → break pattern in our own data. It is visibly the weakest of the three walls we built — roughly two to three points behind FGSM and PGD training under both attacks.It was also the least stable defense to train: across two separate runs, our distilled model’s accuracy under PGD varied between 93.68% and 95.43%, a noticeably wider spread than FGSM or PGD training showed across repeated evaluations. This instability is not a flaw in our implementation; it matches what the literature found. Distillation smooths the loss surface enough to look robust to gradient-based attacks, but Carlini & Wagner (2016) showed that smoothing is closer to a hiding place than a genuine fix — and the run-to-run variance we observed is a small, concrete echo of that fragility.The pattern is not a conspiracy. It is the structure of an adversarial game.The defender proposes a wall.The attacker studies the wall.The attacker finds a weakness.The defender builds a higher wall.The attacker adapts.There is no final wall. There is only the next attack.VII. What This Means for the Humble ModelIf every wall eventually breaks, then the entire framework of defense is built on sand.We are not arguing against adversarial training. It is useful. It raises the bar — our own numbers show a real, measurable improvement, in some cases by two points or more. But it does not solve the underlying problem: the model remains silent about its own limits.The Silence, Tested DirectlyWe tested this directly rather than asserting it. In Essay #2, 22 of the images we sampled flipped under FGSM against the undefended baseline. We took those same 22 images and ran them through this essay’s PGD-trained model.Robustness training did real work: 17 of the 22 are now classified correctly, most at confidence 1.0000. But one image — a digit 9, originally flipped at ε = 0.01 against the baseline — is still misclassified, predicted as an 8 at confidence 0.6187.Confidence on flipped-Model OutputFigure 4 shows the PGD-trained model’s confidence on all 22 originally-flipped images:Green bars = now correctly classified; red bar = still misclassified. The one remaining failure shows a flicker of hesitation — confidence 0.6187 — well below the average of 0.9769 on the corrected images. But 0.6187 is not low. It is well above the 0.10 a ten-class model would output if it were genuinely uncertain, and well above any confidence threshold a practitioner would realistically set to catch errors. A system using a naive 0.5 cutoff to flag uncertain predictions would still accept this prediction — silently, confidently, wrongly.This is a more interesting result than a flat claim of unchanged overconfidence would have been. The model’s confidence in its one remaining failure dropped from near-certainty to 0.6187. That looks, briefly, like the beginning of self-awareness: a flicker of hesitation on the one input it could not resolve.But 0.6187 is not low enough to be useful. It is not a flag. It is not a warning. Robustness training taught the model to hesitate. It did not teach it to say so.The humble model takes a different path. Not resistance, but awareness. Not a higher wall, but a boat that knows it might sink — and says so before the water reaches the deck.VIII. Open Questions: What We Still Do Not KnowIs there any defense that cannot be broken?Given enough computational power and knowledge of the model, can an attacker always find an adversarial example?This is not just an empirical gap — there is reason to believe it may be a structural one. Tsipras et al. (2018) argued that robustness and accuracy may be fundamentally at odds: the features that make a model maximally predictive on clean data are not necessarily the features that make it robust to small perturbations. Zhang et al. (2019) formalized this tension in TRADES, showing that the trade-off can be made explicit and tunable, but not eliminated.Our own numbers are a small, concrete data point in this debate — and an inconvenient one for the strong version of the claim. At our scale and attack budget, training against PGD cost us essentially nothing in clean accuracy (99.00% → 99.08%, a slight gain, not a loss). That does not mean the trade-off is fiction; it likely sharpens as the attack budget, model capacity, or dataset complexity grows, and our experiment was deliberately small. But it is a reminder that the accuracy-robustness tension is not always large, even if it is not always zero, and that claims about this trade-off should be checked against real numbers rather than assumed.What is the cost of robustness?Our experiments did not show the trade-off we expected going in. Whether this holds at a larger scale, against stronger attacks, or with longer training is an open question we have not tested — and a natural next experiment for this series.What if we stopped playing the attacker-defender game?The bridge essay — Why Defenses Alone Will Never Be Enough — will ask a different question: what if the goal is not to be unbreakable, but to be undeluded?IX. InvitationYou have seen the walls. You have watched them hold and break. You have seen the pattern — and you have seen one model, tested directly, hesitate on its hardest case without ever quite admitting it.The arms race has no end. But there is another path.In the bridge essay, we will turn from resistance to awareness. From walls to a boat. From certainty to humility.Come. Walk with me.X. ReferencesGoodfellow, I. J., Shlens, J., & Szegedy, C. (2014). *Explaining and harnessing adversarial examples.* arXiv:1412.6572.Madry, A., Makelov, A., Schmidt, L., Tsipras, D., & Vladu, A. (2017). *Towards deep learning models resistant to adversarial attacks.* arXiv:1706.06083.Papernot, N., McDaniel, P., Wu, X., Jha, S., & Swami, A. (2016). *Distillation as a defense to adversarial perturbations against deep neural networks.* IEEE S&P.Carlini, N., & Wagner, D. (2016). *Defensive distillation is not robust to adversarial examples.* arXiv:1607.04311.Athalye, A., Carlini, N., & Wagner, D. (2018). *Obfuscated gradients give a false sense of security.* arXiv:1802.00420.Tsipras, D., Santurkar, S., Engstrom, L., Turner, A., & Madry, A. (2018). *Robustness may be at odds with accuracy.* arXiv:1805.12152.Zhang, H., Yu, Y., Jiao, J., Xing, E., El Ghaoui, L., & Jordan, M. (2019). *Theoretically principled trade-off between robustness and accuracy.* arXiv:1901.08573.Code Repository:Adversarial-Notebooks/#3/Note02_Adversarial_Training_PGD.ipynb at master · Maee127/Adversarial-NotebooksWalls, Shields, and Illusions: Defenses and Their Limits was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.