WorksComputer Science
Certified Defense against Adversarial Patches on Traffic Signs via Mask-Aware Training
Abstract
Adversarial patches are a practical threat to traffic-sign recognition: a small sticker on a sign can change a classifier's decision. PatchCleanser is a certified defense that applies two rounds of masking and, for every image it certifies, provably returns the correct label for any patch that fits inside one mask. We show that on traffic signs the defense certifies almost nothing when paired with a normally trained classifier (1.7% to 4.8% certified accuracy on GTSRB), because a single mask can hide the small central symbol that distinguishes sign classes. We propose mask-aware training, which trains the classifier on images occluded by random pairs drawn from the defense's own mask set, with a sampling bias toward masks over the sign's centre. The defense, mask set and certification procedure are unchanged, so the guarantee is preserved. For an ImageNet-pretrained ResNet-50, mask-aware training raises certified accuracy from 4.8% to 60.0%. Under real per-image adversarial patches, the defended ResNet-50 reaches 85.7% accuracy, versus 74.6% for the original PatchCleanser with a normally trained ResNet-50.
Introduction
Deep classifiers used in driver assistance and autonomous driving read traffic signs from camera images. Physical adversarial patches, small printed stickers placed on or near an object, can cause confident misclassification [2, 3]. Empirical defenses are routinely broken by adaptive attacks, which motivates certified defenses: methods that prove a prediction cannot be changed by any patch of a given size [4, 5, 6].
PatchCleanser [1] is a certified defense that works with any image classifier. It evaluates the classifier on images occluded by one and then two masks from an -covering mask set and certifies an image when all two-mask predictions agree with the label.
Traffic signs are harder. A sign’s class is decided by a small symbol at its centre (the digits of a speed limit, the pictogram of a warning sign), and a mask sized to cover a patch can hide that symbol entirely. We find that PatchCleanser with a normally trained model certifies only 1.7% to 4.8% of GTSRB test images. This paper makes the following contributions:
An end-to-end certified-patch-defense pipeline for traffic signs (GTSRB), including training, per-image adversarial patch generation, two-mask inference and certification.
Mask-aware training: training with random pairs from the defense’s own mask set, biased toward the grid centre. It requires no change to inference and keeps the certificate valid.
A comparison with the original PatchCleanser on a wide CNN and a ResNet-50: certified accuracy rises from 1.7–4.8% to 53.5–60.0%, and accuracy under real adversarial patches from 72.8–74.6% to 80.9–85.7%.
Background and Related Work
Adversarial patches
Adversarial patches: Brown et al. [2] introduced universal, printable adversarial patches, and Eykholt et al. [3] demonstrated physical sticker attacks that cause stop signs to be misread. The attacker controls all pixels inside a contiguous region and nothing outside it.
Certified patch defenses: Interval bound propagation [4], derandomized smoothing [5] and small-receptive-field models [6] give provable guarantees but constrain the architecture. PatchCleanser [1] is architecture-agnostic, and later work improves its efficiency and utility [7, 8]. Saha et al. [9] show that occlusion-based training (Greedy Cutout) improves PatchCleanser on natural-image benchmarks; PatchCleanser itself fine-tunes with Cutout [10]. We study the traffic-sign domain, where the defense fails without such training, and train with the defense’s own mask pairs.
Certified patch defenses
Double masking
Double masking: Let be a classifier and an image. A mask zeroes a square region. A mask set is -covering for a patch if every possible patch location is fully covered by at least one mask. With stride and mask size , a grid of masks is -covering [1]. The defense computes one-mask predictions and, when they disagree, two-mask predictions (Algorithm 2). If for all on the clean image, the output equals for every patched version of [1]; this is the certificate (Algorithm 3).
Method
Threat Model and Mask Set
The attacker places one square patch covering 2.4% of the image pixels at any location with arbitrary content: on inputs and on inputs. We use a grid () of masks at stride 5 (respectively at stride 19), which is R-covering for the patch. A two-mask prediction uses an unordered pair of masks, with meaning a single mask, so there are of them, i.e. . Certification requires all 666 to be correct; inference needs at most 666, since Algorithm 2 evaluates two-mask predictions only for disagreeing masks. We compute all 666 once per image and reuse them for both. Figure 2 summarizes the pipeline.

Figure 2. Pipeline. (a) The classifier is trained on images occluded by pairs from the defense’s own R-covering mask set. (b) Inference and certification use the unmodified double-masking defense.
Why Traffic Signs Are Hard to Certify
Figure 3 shows the error of the normally trained wide CNN when one mask is applied. Masks at the border cost about 3%, but the four masks over the centre raise the error to 50–59%, and none of the 651 speed-limit test images is certified: once the digits are hidden, 30, 50 and 80 look the same. Because certification needs all 666 two-mask predictions to be correct, these central failures are enough to break the certificate on almost every image.
Figure 3. Error (%) when a single mask is applied, by mask position on the grid. Left: the wide CNN with normal training; right: the same network with mask-aware training (ours), which removes the central failure mode.
Mask-Aware Training
We train the classifier to predict the correct label from images occluded by pairs of the defense’s own masks (Algorithm 1):
where is cross-entropy. The sampling distribution draws uniformly and, with probability , draws from the interior masks of the grid (the centre), otherwise uniformly.
Algorithm 1 Mask-aware training
Input: data , mask set , interior set , keep rate , epochs
Output: classifier
for to do
for each batch do
▷ brightness
w.p. , else
w.p. , else
end for
end for
Algorithm 2 Double-masking inference [1]
Input: image , classifier , mask set
Output: label
for
if all are equal then
return ▷ Case I: agreement
end if
majority of
for each with do
if for all then
return ▷ Case II: consistent disagreer
end if
end for
return ▷ Case III
Algorithm 3 Certification [1]
Input: clean image , label , classifier , mask set
for $1 \le i \le j \le k$ do
if then
return not certified
end if
end for
return certified ▷ no patch can change the output
A fraction of each batch is left unmasked. In our models every training image is masked (). Since inference and certification are not modified, the PatchCleanser guarantee holds for the trained model.
Experimental Setup
Dataset. GTSRB [11]: 26,640 training and 12,630 test images, 43 classes. We evaluate on a fixed random subset of 2,000 test images; every method sees the same images and patch locations.
Models. Table I lists the classifiers. The wide CNN (five convolutional layers) is trained from scratch at . ResNet-50 [12] starts from ImageNet weights and is fine-tuned at on a Colab T4 GPU with mixed precision. For each model, the original PatchCleanser uses the normally trained network and ours uses the mask-aware one; the defense is identical.
| Model | Params | Input (px) | Patch (px) | Epochs |
| Wide CNN (from scratch) | 0.73M | 32 | 5 | 40 |
| ResNet-50 (pretrained) | 23.6M | 128 | 20 | 30 |
Table I. Model architectures and parameters
Each model is trained twice with the same recipe: normally (original PatchCleanser) and with mask-aware training (ours). Both wide CNNs also use a random -pixel translation during training.
| Clean images | Adversarial patch | ||||
| Method | No def. | Defense | Certified | No def. | Defense |
| Wide CNN | |||||
| PatchCleanser | 97.9 | 93.8 | 1.7 | 76.1 | 72.8 |
| Ours | 97.3 | 93.2 | 53.5 | 70.0 | 80.9 |
| ResNet-50 | |||||
| PatchCleanser | 99.2 | 96.1 | 4.8 | 76.6 | 74.6 |
| Ours | 97.9 | 93.7 | 60.0 | 80.7 | 85.7 |
Table II. Original PatchCleanser vs. ours on 2,000 GTSRB test images (%). Shaded cells highlight our gains.
Attack. Adversarial patch: per-image, untargeted, 100 Adam [13] steps on the patch pixels maximizing the cross-entropy of the undefended model at a random location. Certified accuracy covers every patch content and location in the threat model.
Results
Certified Accuracy
tbl:2 and Figure 4 compare the original PatchCleanser with ours. The original certifies only 1.7% (wide CNN) and 4.8% (ResNet-50) of test images. With mask-aware training the same defense certifies 53.5% and 60.0%, gains of 51.8 and 55.2 points. Clean accuracy with the defense drops by 0.6 and 2.4 points.
Figure 4. Original PatchCleanser vs. ours on GTSRB (2.4% patch). Left: certified accuracy; right: accuracy with the defense under a real adversarial patch.
Robustness to Real Adversarial Patches
Without a defense, adversarial patches reduce accuracy to 70.0–80.7% (Table II). The original PatchCleanser makes this slightly worse (72.8% vs. 76.1% and 74.6% vs. 76.6%).
because the normally trained model misclassifies the masked images. With ours the defended accuracy reaches 80.9% and 85.7%, 8.1 and 11.1 points above the original. Figure 1 shows examples.
Figure 1. Examples of GTSRB test signs (top) and the same signs with an adversarial patch (bottom), using the wide CNN trained with our method (Table I). Without a defense the classifier is fooled (e.g., Speed limit 100 120); with mask-aware training (ours) inside the unchanged double-masking defense it returns the correct class.
Limitations
We use 2,000 of the 12,630 test images (666 forward passes per image). The adversarial patch targets the undefended model, not the defense; certified accuracy holds against any patch. Each setting is trained once, and all patches are digital.
Conclusion
PatchCleanser’s guarantee transfers to traffic-sign recognition only if the classifier can recognize signs with a mask over their central symbol. Mask-aware training with the defense’s own mask pairs and a centre bias supplies this ability without modifying the defense. On GTSRB our best model, a ResNet-50, goes from 4.8% to 60.0% certified and reaches 85.7% defended accuracy under adversarial patches. Future work includes the full test set and physical stickers.
Terminology and Definitions
GTSRB: The German Traffic Sign Recognition Benchmark [11] contains 39,270 natural images of 43 road sign classes (26,640 train, 12,630 test) across diverse scales, lighting, and degradation. We evaluate on a fixed subset of 2,000 test images with identical patch coordinates across all models.
Adversarial patch: A localized perturbation [2], [3] where an adversary freely modifies pixels within a bounded spatial region (e.g., a physical sticker on a sign), leaving other pixels intact. In our threat model, the patch covers 2.4% of pixels (5 × 5 on 32 × 32, 20 × 20 on 128 × 128).
Threat model: Formal adversary definition: placing one square patch of up to 2.4% pixel area anywhere on the sign with arbitrary continuous RGB values to cause misclassification, subject to no -norm bound.
Defense: An algorithmic pipeline wrapped around a classifier to resist attacks. Here, we evaluate PatchCleanser, a certified defense based on two rounds of spatial masking.
PatchCleanser: An architecture-agnostic certified defense [1] that guarantees robustness against localized patches via double masking without modifying model weights.
Mask: A spatial occlusion operator setting pixels to zero in a square window () prior to inference (9 × 9 for 32 × 32; 38 × 38 for 128 × 128), suppressing adversarial patches.
Mask set, : A discrete set of masks arranged on a uniform 6 × 6 grid across the image, governing spatial resolution and evaluation overhead.
R-covering: The structural property ensuring every valid patch location is fully enclosed by at least one mask. Sizing masks to for stride guarantees covering across continuous offsets.
One-/two-mask prediction: Model inferences on occluded inputs: for single mask ; for mask pair ( denotes single mask).
666 (Two-mask evaluations): Total count of unordered mask pairs from masks, including a pairing with itself: , evaluated once per sample and shared.
Double masking: PatchCleanser’s inference rule (Algorithm 2). It checks consensus among one-mask predictions (Case I) and identifies if a minority prediction consistently disagrees across secondary masks (Case II); otherwise majority vote is returned (Case III).
Certificate: Formal verification that no patch in the threat model can change the defended output on a clean image (Algorithm 3), proven when all 666 two-mask evaluations match label .
Certified accuracy: Fraction of test images correctly classified and certified, establishing an attack-independent lower bound on defended accuracy against any admissible patch.
No defense / Defense: Comparative evaluation settings: No defense measures raw classifier accuracy; Defense measures accuracy when wrapped inside the double-masking pipeline.
Mask-aware training: Our training method (Algorithm 1) optimizing the classifier on images occluded by sampled pairs from , conditioning it to recognize signs under dual occlusions.
Centre bias: A sampling distribution during training where mask is drawn from interior masks (4 × 4) with probability 0.5 (else uniformly), forcing reliance on peripheral cues.
(keep rate): The fraction of each training minibatch left unmasked. We set , occluding every training image to maximize robustness to severe occlusions.
Normal training: Standard training on clean images with brightness scaling only; serves as the baseline model in original PatchCleanser.
PatchCleanser (original): Baseline combining the unmodified PatchCleanser defense with a normally trained neural network.
Ours: The combination of the exact PatchCleanser defense and certification procedure with a classifier trained via mask-aware training.
Wide CNN: A five-layer convolutional neural network (0.73M parameters) trained from scratch on 32 × 32 inputs with ±2-pixel random translations and brightness augmentations for 40 epochs.
ResNet-50: A 50-layer residual network (23.6M parameters) [12] initialized with ImageNet weights and fine-tuned on GTSRB at 128 × 128 for 30 epochs using mixed precision on GPU.
References
- [1]C. Xiang, S. Mahloujifar, and P. Mittal, “PatchCleanser: Certifiably robust defense against adversarial patches for any image classifier,” in Proc. USENIX Security Symp., 2022.arxiv.org/abs/2108.09135
- [2]T. B. Brown, D. Mané, A. Roy, M. Abadi, and J. Gilmer, “Adversarial patch,” arXiv:1712.09665, 2017.arxiv.org/abs/1712.09665
- [3]K. Eykholt et al., “Robust physical-world attacks on deep learning visual classification,” in Proc. IEEE/CVF CVPR, 2018.DOI
- [4]P. Chiang, R. Ni, A. Abdelkader, C. Zhu, C. Studer, and T. Goldstein, “Certified defenses for adversarial patches,” in Proc. ICLR, 2020.arxiv.org/abs/2003.06693
- [5]A. Levine and S. Feizi, “(De)randomized smoothing for certifiable defense against patch attacks,” in Proc. NeurIPS, 2020.arxiv.org/abs/2002.10733
- [6]C. Xiang, A. N. Bhagoji, V. Sehwag, and P. Mittal, “PatchGuard: A provably robust defense against adversarial patches via small receptive fields and masking,” in Proc. USENIX Security Symp., 2021.arxiv.org/abs/2005.10884
- [7]C. Xiang, T. Wu, S. Dai, J. Petit, S. Jana, and P. Mittal, “PatchCURE: Improving certifiable robustness, model utility, and computation efficiency of adversarial patch defenses,” in Proc. USENIX Security Symp., 2024.arxiv.org/abs/2310.13076
- [8]J. Li, H. Zhang, and C. Xie, “ViP: Unified certified detection and recovery for patch attack with vision transformers,” in Proc. ECCV, 2022.DOI
- [9]A. Saha, S. Yu, M. S. Nourouzadeh, W.-Y. Lin, and C. K. Mummadi, “Revisiting image classifier training for improved certified robust defense against adversarial patches,” Trans. Mach. Learn. Res., 2023.arxiv.org/abs/2306.12610
- [10]T. De Vries and G. W. Taylor, “Improved regularization of convolutional neural networks with Cutout,” arXiv:1708.04552, 2017.arxiv.org/abs/1708.04552
- [11]J. Stallkamp, M. Schlipsing, J. Salmen, and C. Igel, “Man vs. computer: Benchmarking machine learning algorithms for traffic sign recognition,” Neural Networks, vol. 32, pp. 323–332, 2012.DOI
- [12]K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” in Proc. IEEE CVPR, 2016.arxiv.org/abs/1512.03385
- [13]D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in Proc. ICLR, 2015.arxiv.org/abs/1412.6980


