Mask and Restore: Blind Backdoor Defense at Test Time with Masked Autoencoder

Tao Sun, Lu Pang, Chao Chen, Haibin LingSubmission to ICLR 2024 · Withdrawn

TL;DR

This paper introduces BDMAE (Blind Defense with Masked AutoEncoder), a test-time defense framework designed to neutralize backdoor attacks on black-box vision models. By combining patch-level generative reconstruction with label-consistency checks and topological refinement, BDMAE detects and purifies localized backdoor triggers on the fly—without requiring access to model weights, training data, or knowing whether an incoming image is poisoned.

What Problem Does This Paper Address?

Backdoor attacks silently manipulate neural networks during training: the poisoned model functions normally on benign inputs, but reliably predicts an attacker's target class whenever a specific trigger pattern is present.

Most existing defenses require access to internal model weights (white-box access) or a curated set of clean validation data to detect or prune backdoored neurons. In real-world deployments—such as third-party model APIs or cloud inference services—users only have black-box access (i.e., querying inputs and receiving hard-label outputs). Defending against backdoors under these constraints is challenging:

  1. Blindness: The defender cannot know in advance whether the model is backdoored or whether any individual streaming image is malicious.
  2. Search Complexity: Searching for arbitrary triggers directly in pixel space does not scale to high-resolution images or irregular trigger geometries.
  3. Accuracy Trade-off: Naive input transformations (e.g., heavy blurring or random noise) might break the trigger, but they also degrade accuracy on clean images.

Methods

BDMAE addresses these challenges by operating in the token space of a generic, pre-trained Masked AutoEncoder (MAE) rather than raw pixel space. The pipeline consists of three core stages:

[ Test Image ] 
      │
      ▼
1. Dual Trigger Scoring (Token Space: 14×14)
   ├─ Image-based Score S^(i) : Structural Similarity (SSIM) between input and MAE restorations
   └─ Label-based Score S^(l) : Prediction shifts when patches are masked
      │
      ▼
2. Topology-Aware Score Refinement
   └─ Iteratively grows masks along spatial neighbors; updates scores if hard labels flip
      │
      ▼
3. Adaptive Image Restoration
   └─ Fuses multi-threshold MAE inpaintings; preserves clean pixels, reconstructs trigger area
      │
      ▼
[ Purified Image -> Black-Box Model Prediction ]
  • Dual Trigger Scoring: MAE divides images into $14 \times 14$ token patches and can reconstruct semantic content even with 75% of tokens masked. BDMAE computes two complementary scores per token:
  • Image-based score ($S^{(i)}$): Measures structural divergence (via SSIM) between the original image and MAE restorations. Because MAEs are trained on clean natural images, they reconstruct the underlying semantics rather than the irrelevant backdoor trigger.
  • Label-based score ($S^{(l)}$): Tracks which random mask subsets cause the black-box model's prediction to diverge from the suspicious initial prediction.
  • Topology-Aware Refinement: Because physical and digital triggers are typically contiguous, the method generates masks that prioritize neighboring tokens with elevated trigger scores. If masking these regions changes the model prediction, confidence scores in those tokens are reinforced.
  • Adaptive Multi-Threshold Restoration: Instead of relying on a fragile fixed threshold, BDMAE adaptively thresholds the composite trigger score and fuses nested reconstructions into a single purified image $\rho(x)$ that leaves non-trigger regions untouched.

Datasets

The authors evaluate BDMAE on standard vision and face recognition benchmarks:

  • CIFAR-10 (10 classes, $32 \times 32$)
  • GTSRB (German Traffic Sign Recognition Benchmark, 43 classes, $32 \times 32$)
  • VGGFace2 (170-class face identification subset, resized to $224 \times 224$)
  • ImageNet Subsets: ImageNet10, ImageNet50, and ImageNet100 ($224 \times 224$)

Evaluated attacks include BadNets (with monochromatic/color squares and natural icon triggers), Label-Consistent (LC) attacks, sample-specific Input-Aware dynamic Backdoor (IAB) attacks, and Blended noise attacks.

Key Insights and Ideas

  • Local inpainting over global generation: Diffusion-based purification methods (like DiffPure) resample entire images, frequently hallucinating or smoothing out critical high-frequency details (e.g., facial identity in VGGFace2 or speed limits on traffic signs). BDMAE restricts modification strictly to suspect tokens, leaving benign pixels intact.
  • Token-space trigger localization: Reducing an image to a $14 \times 14$ grid allows BDMAE to bypass the combinatorial explosion of pixel-space heuristic trigger searches.
  • Complementary dual metrics: Label consistency effectively pinpoints tiny triggers ($1 \times 1$ pixel attacks) that barely disturb SSIM, while image-structural similarity captures large, complex, or multi-component triggers where partial masking might fail to flip the model’s prediction.

Key Results

  • Diffusion Baseline Comparison: On VGGFace2, DiffPure drops clean accuracy (CA) to $\sim 52\%$ and leaves the attack success rate (ASR) at $\sim 35\%$. BDMAE (Large) preserves $94.3\%$ CA while dropping ASR to $1.9\%$ (backdoor accuracy: $91.9\%$).
  • Superiority over Test-Time Baselines: Compared to PatchCleanser, Blur, and ShrinkPad, BDMAE maintains clean accuracy across datasets while consistently suppressing ASR below $1-3\%$ on standard BadNets.
  • Complex Triggers: On irregular curve triggers (IAB) and distributed corner checkerboards (LC), BDMAE achieves $>93\%$ backdoor accuracy on CIFAR-10 and GTSRB, where rectangle-assumption defenses (e.g., vanilla PatchCleanser) collapse ($<15\%$ backdoor accuracy).
  • Benign Model Safety: When applied to non-backdoored models, BDMAE causes negligible performance drops ($<1\%$ accuracy decrease on CIFAR-10/GTSRB).

Limitations and Future Work

  • Trigger Scope: BDMAE explicitly assumes triggers are spatially localized. It is not designed to detect global, full-image perturbations (such as whole-image warping or global color shifts) without an upstream transformation stage.
  • Computational Overhead: Purifying each input requires multiple forward passes through both the MAE ($N_o \times N_i + N_r$ iterations) and the black-box classifier, introducing test-time latency that may challenge real-time edge applications.

Summary updated

Abstract

Deep neural networks are vulnerable to backdoor attacks, where an adversary maliciously manipulates the model behavior through overlaying images with special triggers. Existing backdoor defense methods often require accessing a few validation data and model parameters, which are impractical in many real-world applications, e.g., when the model is provided as a cloud service. In this paper, we address the practical task of blind backdoor defense at test time, in particular for black-box models. The true label of every test image needs to be recovered on the fly from a suspicious model regardless of image benignity. We focus on test-time image purification methods that incapacitate possible triggers while keeping semantic contents intact. Due to diverse trigger patterns and sizes, the heuristic trigger search in image space can be unscalable. We circumvent such barrier by leveraging the strong reconstruction power of generative models, and propose a framework of Blind Defense with Masked AutoEncoder (BDMAE). It detects possible triggers in the token space using image structural similarity and label consistency between the test image and MAE restorations. The detection results are then refined by considering trigger topology. Finally, we fuse MAE restorations adaptively into a purified image for making prediction. Our approach is blind to the model architectures, trigger patterns and image benignity. Extensive experiments under different backdoor settings validate its effectiveness and generalizability.
BibTeX
@misc{sun2023mask,
  author = {Tao Sun and Lu Pang and Chao Chen and Haibin Ling},
  title = {{Mask and Restore: Blind Backdoor Defense at Test Time with Masked Autoencoder}},
  year = {2023},
  eprint = {2303.15564},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.15564},
}
Figure