Skip to main content
Back

STRAP-ViT Stops Sticker Attacks That Trick Vision AI Without Retraining

A training-free ViT defense uses statistical divergence to flag corrupted tokens and neutralize adversarial stickers with near-baseline accuracy.

Pro

Paper, Full Access
  • STRAP-ViT is a training-free, plug-and-play defense against adversarial patches for Vision Transformers, accepted at DAC 2026.
  • It uses Jensen-Shannon Divergence to detect tokens whose distributions deviate from a clean reference built at each position.
  • Flagged tokens are neutralized with randomized composite transformations: L_p projection, bounded affine contraction, and temperature softmax.
  • Robust accuracy sits within 2-3 percent of clean baselines across ViT-base-16, DinoV2, ImageNet, and Caltech-101.
  • Beats prior defenses on 40x40 GoogleAP with 78.8 percent Top-1 versus 74.3 for ODDR and 70.6 for JEDI.
  • Adaptive attacks constrained to low JSD can still reduce accuracy by up to 15 percent from baseline.

Slap a small, printed sticker in the corner of an image and a Vision Transformer can be tricked into calling a monkey a radiator. That is the essence of an adversarial patch attack, and it works because self-attention gets hijacked: the class token starts paying disproportionate attention to a tiny, high-contrast region, and the model produces confident nonsense. A new defense called STRAP-ViT tackles this problem without any retraining, by watching the statistics of individual tokens as they flow through the network.

The paper, accepted at DAC 2026, proposes a plug-and-play block that fits inside standard ViT inference. It flags tokens that look statistically off, scrambles their contents just enough to break the attack, and lets the rest of the model proceed as normal. Across ImageNet and Caltech-101, against four different patch attacks, it lands within 2 to 3 percent of the clean baseline while beating prior defenses.

Patas monkey correctly classified, then misclassified as radiator with patch, then correctly classified with STRAP defense

Why patches keep breaking transformers

Adversarial patches are not the pixel-scale noise of earlier attacks. They are localized, intentionally crafted regions added to an image to cause vision models to misclassify inputs with high confidence, even when the rest of the image remains unaltered. A patch typically covers less than 5 percent of the image, generalizes across images and models, and survives printing, lighting, and perspective changes, which makes it a genuine physical-world threat for surveillance, autonomous driving, and facial recognition.

Vision Transformers are particularly exposed. Unlike CNNs, ViTs' weak built-in locality and global token mixing make them particularly susceptible to attention redirection: a high-contrast patch can soak up attention across layers, corrupt token interactions, and transfer across models and tasks. Existing defenses either need adversarial training (expensive, and brittle across threat models), rely on pixel-space heuristics, or lean on certified smoothing that is computationally heavy.

The statistical fingerprint of a patch

The core observation is that patched tokens leave a signature. When a patch overlaps a token's receptive field, the token's channel distribution systematically shifts and its Shannon entropy rises relative to non-overlapping tokens. Rather than use raw entropy, the authors reach for something sharper: the Jensen-Shannon Divergence (JSD) between each token's distribution and a clean reference distribution built from unattacked images.

JSD is essentially a symmetric, bounded version of KL divergence, and its square root is a proper distance metric. Larger JSD means more bits of evidence that the token is anomalous, which is exactly what a detector wants. The reference distribution is position-matched, so the check compares token t against what token t usually looks like on clean data.

Entropy comparison showing patched tokens have distinctly higher entropy than clean tokens

Detect, then scramble

STRAP-ViT runs two stages after the patch embedding layer, before the transformer blocks see the tokens:

  1. Detection via token segregation. Compute the square-root JSD for every token against the clean reference, then keep the top K highest-scoring tokens as suspects.
  2. Mitigation via randomized composite transformations. For each flagged token, sample a non-empty subset from three transformations and apply them in a random order.

The three transformations each attack a different aspect of the adversarial signal. An L_p-norm projection clips extreme channel energy. An affine contraction with bounded operator norm (strictly less than 1) shrinks the token toward a stable region. A temperature-scaled softmax tames spiky activations and rebalances channels. Because the composition is drawn randomly per token, an attacker cannot easily precompute a patch that survives all combinations, which blunts Expectation-Over-Transformation style adaptive attacks.

The number of tokens to modify, K, is the main knob. The authors studied a wide range of adversarial patches and concluded that it is sufficient to cover at least half of the adversarial patch for the defense to work. In practice K ranges from 2 tokens (about 1 percent of the sequence) up to 8 tokens (about 4 percent) for multi-patch attacks.

How well it holds up

The defense was tested on ViT-base-16 and a DinoV2 backbone across ImageNet and Caltech-101, against four patch attacks: GoogleAP, LAVAN, GDPA, and the multi-patch RP2. Undefended, the ViT collapses. A 50x50 LAVAN patch drops ImageNet Top-1 from 80.5 percent to 0.3 percent. With STRAP-ViT, that same setting recovers to 78.5 percent.

Bar chart of Top-1 accuracy for undefended vs STRAP-defended ViT across attacks and datasets

On the head-to-head at 40x40 GoogleAP on ImageNet, STRAP-ViT clocks 78.8 percent robust accuracy versus 74.3 for ODDR, 70.6 for JEDI and LGS, 62.6 for Dimension Reduction, 62.1 for PatchCleanser, and 41.7 for a certifiable ViT defense. Clean-sample accuracy with the defense active only slips 0.4 percent on ImageNet, so there is essentially no cost to running it by default.

The RP2 experiments matter because they involve multiple distributed patches, which is the toughest setting. Even with five patches at 25x25, STRAP-ViT recovers ImageNet Top-1 from 3.1 percent to 73.4 percent by raising K to 8.

Where it falls short

The authors are honest about the weak points. If K is set too high, transformations start hitting clean tokens and degrade accuracy. And under a full adaptive attack, where the attacker constrains the JSD of the patch to stay below the maximum JSD of any clean token and trains against all three transformations simultaneously, the defense can be pushed down by roughly 15 percent from the clean baseline. That is still far better than undefended performance, but it is not a certified guarantee.

There is no public code repository referenced in the paper. Experiments were run on a single T4 GPU via Colab, and the detection cost is O(Nd) per image with per-token transformations only on the flagged subset, so the overhead is small compared to a full ViT forward pass. For teams shipping ViT-based classifiers in physically exposed settings, this is the kind of defense that is cheap enough to enable by default and does not require retraining a production model.