Skip to main content
Back

BackdoorIDS Catches Poisoned AI Vision Models Without Any Extra Data

A new zero-shot method spots poisoned images at inference time by watching how their embeddings jump when patches are masked out.

Pro

  • BackdoorIDS detects poisoned images at inference with no auxiliary data or retraining, using only the encoder.
  • It exploits Attention Hijacking and Restoration, an abrupt embedding jump when masking disables the trigger.
  • Method: progressive patch masking, encode the sequence, run DBSCAN, flag if more than one cluster forms.
  • Hits 95.78% TPR on BadEncoder and 97% TPR on BadVision attacking LLaVA-1.5, beating PatchProcessing and DeDe.
  • Adds roughly 32% inference overhead on LLaVA-1.5; works on CNNs, ViTs, CLIP, and LVLMs.
  • Code released at github.com/siquanhuang/BackdoorIDS; false positive rate 17-28% is the main tradeoff.

Third-party vision encoders are convenient, but they are also a supply-chain nightmare. If someone slips a backdoor into a CLIP or ResNet checkpoint you downloaded, an attacker can trigger targeted misbehavior later with a specific patch or pattern embedded in an input image. A new paper called BackdoorIDS proposes a detector that needs no auxiliary dataset, no retraining, and no access to the pretraining corpus. It flags poisoned inputs one at a time, using only the encoder itself.

Why existing defenses keep breaking

Backdoor sample detection methods typically identify anomalies in the distribution of image embeddings, which can effectively separate backdoor inputs from clean ones. The catch is that most of them assume you can inspect the original pretraining data, which is rarely true when you pull a model off a hub. More recent paradigms perform inference-time detection with a small auxiliary dataset, but their effectiveness is highly sensitive to distributional alignment between the auxiliary data and the encoder's pretraining data distribution.

Attacks have also gotten harder to spot. Early backdoors used obvious color patches, but newer ones like BadCLIP and BadVision use optimized triggers, including blended perturbations spread across the entire image, so classic tricks like looking for a localized attention hotspot no longer generalize.

The key observation: hijacking, then restoration

The authors mechanistically probe what a trigger does inside the encoder and find a property that holds for both patch and blended triggers. Regardless of whether a trigger is patch-based or blended-based, a consistent characteristic emerges: the attention allocated to benign features in a backdoor image is nearly zero. They call this Attention Hijacking, and it has a useful consequence: because the model is ignoring the benign pixels, you can perturb those pixels without moving the embedding much.

Push that perturbation far enough, though, and the trigger itself gets damaged. When perturbations exceed the trigger's robustness threshold, the trigger deactivates; attention rapidly reorients toward benign features, producing an abrupt embedding shift, which we call Attention Restoration. Clean images do not show this sudden jump. Their attention is spread out to begin with, so as you mask more patches, the embedding drifts smoothly.

How BackdoorIDS actually runs

The algorithm is refreshingly compact. For a single test image, the pipeline is:

  1. Split the image into a 16 by 16 grid of patches and progressively mask them in random order, producing a sequence of increasingly blank images.
  2. Push the whole sequence through the encoder to get an embedding trajectory. Only the first 3/4 of this sequence is used, because in the later stages even clean images experience significant embedding shifts due to excessive information loss.
  3. Compute the average pairwise cosine distance among the first k=5 embeddings. That is the local density in the early, likely-still-triggered stage.
  4. Multiply that density by a scaling factor s to get a DBSCAN radius, then cluster the full trajectory.
  5. If DBSCAN returns one cluster, call the input clean. If it returns more than one, flag it as backdoored.

The intuition is that a backdoored trajectory has two regimes: a tight blob while the trigger still fires, then a sudden leap to a different region once masking kills the trigger. Clean trajectories stay in one loose blob. The scaling parameter s is empirically set to 50 for large-scale pretrained models such as CLIP and LLaVA, and to 5 for models trained from scratch, such as ResNet.

Numbers across five attacks

The authors evaluate against BadEncoder, Drupe, BadCLIP with both ResNet-50 and ViT-B/32 backbones, and BadVision on LLaVA-1.5. Test sets include SVHN, GTSRB, ImageNet-1K, and COCO Captions, each poisoned with 5% backdoor samples. BackdoorIDS is compared against PatchProcessing and DeDe.

AttackPatchProc TPRDeDe TPRBackdoorIDS TPR
BadEncoder84.3289.0195.78
Drupe74.6669.9482.75
BadCLIP (RN)63.1170.2093.08
BadCLIP (ViT)82.9755.1295.84
BadVision (LLaVA)41.007.0097.00

The BadVision row is the most striking. DeDe reconstructs fragmented images using a decoder, but the reconstruction process becomes more error-prone with more complex images, such as BadVision (COCO Caption), where the TPR value is only 7.00%. BackdoorIDS lands at 97% on the same setup because it never tries to reconstruct anything; it just watches the embedding trajectory.

Once the flagged samples are dropped, attack success rate collapses. On BadVision, ASR falls from 99% with no defense to 3% with BackdoorIDS filtering, while CIDEr on clean captions drops from 85.30 to 68.68.

Cost, robustness, and where it breaks

Because the sequence of masked images runs through the encoder in parallel on a GPU, overhead is modest. BackdoorIDS takes 3.225 seconds per image for BadVision, but the model itself requires 9.879s for inference, resulting in only a 32% increase in time. On smaller ResNet setups, per-image detection runs in about 30 milliseconds.

Robustness experiments add Gaussian noise and JPEG compression to the inputs. Detection holds up until compression quality drops below 40, at which point high-resolution CLIP inputs lose enough fine detail that the trigger itself stops behaving predictably. The false positive rate is also non-trivial, sitting between 17% and 28% in the main table, so this is a filter you would pair with human review, not a silent gatekeeper for production traffic.

Other honest limitations:

  • The Drupe attack drops TPR to 82.75%, though the authors show many of the missed samples were not actually triggering the backdoor anyway.
  • Filtering suspicious inputs shaves clean accuracy by a few points because some benign images get swept up as false positives.
  • Very aggressive image compression can defeat both the attack and the detector at the same time.

Getting your hands on it

The authors have released code at github.com/siquanhuang/BackdoorIDS, and the method is described as plug-and-play: it works with CNNs, ViTs, CLIP, and LLaVA-1.5 without architecture-specific changes. If you serve a downstream classifier or a VLM on top of a third-party encoder, this is a cheap runtime check to add to the pipeline, particularly for high-stakes applications like content moderation, medical imaging, or agentic vision systems where a hijacked embedding can propagate into downstream reasoning.