Preprocessors Matter! Realistic Decision-Based Attacks on Machine Learning Systems

Chawin Sitawarin, Florian Tramèr, Nicholas Carlini

Introduction

Most black-box adversarial attacks fail in the real world because they ignore the simple preprocessors—like resizing, cropping, or JPEG compression—that sit in front of machine learning models. In laboratory settings, researchers usually attack standalone neural networks. However, in practical Machine Learning as a Service (MLaaS) pipelines, an image is almost always processed before it reaches a classifier.

This paper demonstrates that these mundane preprocessing steps act as a surprisingly effective shield against decision-based attacks (black-box attacks that only see the final "hard-label" output, like "Dog" or "Cat"). Because preprocessors are "many-to-one" functions, they introduce invariance. Standard attacks are "preprocessor-oblivious": they waste thousands of queries trying to modify pixels that the model never even "sees" or making changes that are washed away by compression. Consequently, state-of-the-art query-based attacks are up to 7× less effective at attacking a prediction pipeline than at attacking the model alone.

However, by reverse-engineering these preprocessors with just a few hundred queries, attackers can mount "preprocessor-aware" attacks that essentially nullify the accidental protection these components provide.

Methodology: Extraction and Aware Attacks

The researchers propose a two-stage strategy to overcome the preprocessor defense: Extraction followed by Aware Attacks.

1. Preprocessor Extraction

The authors developed a highly efficient "guess-and-check" method to identify the specific preprocessor being used. First, they find an unstable pair of images—two images that are nearly identical but result in different labels. Next, they hypothesize a preprocessor (e.g., "bilinear resizing to 224x224") and create "pre-images" that should map to those unstable images. If the model's labels for these pre-images match the expected behavior, the guess is likely correct. This process often requires fewer than 100 queries for common setups.

2. Preprocessor-Aware Attacks

Once the preprocessor is known, the attacker can use one of two new attack styles depending on the nature of the preprocessor:

  • Bypassing Attack: This is used for "idempotent" preprocessors like cropping or resizing. The attack is performed entirely in the "model space" (the lower resolution the model actually sees). Once a successful adversarial image is found there, it is mathematically projected back into the original high-resolution space.
Bypassing Attack Pipeline
  • Biased-Gradient Attack: Used for preprocessors that lose information in more complex ways, like quantization or JPEG compression. This method modifies the gradient estimation of the attack to "bias" queries toward directions that the preprocessor is actually sensitive to, ensuring the attack doesn't waste energy on "invisible" changes.

Key Insights

  • Invariance is the Enemy of Efficiency: The core reason black-box attacks fail is that they don't account for the "null space" of the preprocessor—the set of input changes that result in zero change to the model's input.
  • Preprocessors are "Accidental" Defenses: They weren't designed for security, but they provide a "masking" effect. However, because they are usually deterministic and simple, they are easy to "steal."
  • The "Model Space" is the Right Battleground: By moving the attack from the high-dimensional input space (e.g., a 1024x1024 image) to the lower-dimensional model space (e.g., 224x224), the search space for an adversarial example shrinks dramatically, making the attack much faster and more precise.

Key Results

The study evaluated these attacks against a ResNet-18 classifier on ImageNet and tested the extraction method on real-world, publicly hosted model APIs (like HuggingFace Hub).

  • The Performance Gap: Against a standard ImageNet model, a standard attack achieves a low $\ell_2$-distortion of 3.7. Adding a resizing preprocessor (1024 to 224 pixels) caused that distortion to skyrocket to 28.5—a 7x decrease in effectiveness for the attacker.
  • Recovery: The proposed "Bypassing Attack" recovered the original efficacy, bringing the distortion back down to ~3.7.
Adversarial Distance vs Queries for Resizing
  • Quantization & JPEG: For 4-bit quantization, the Biased-Gradient attack was 3x more effective than unaware attacks. For JPEG compression (quality 60), it was 6x more effective.
  • Efficiency: Reverse-engineering a "typical" resizing and cropping pipeline on HuggingFace required only about 50 queries on average.

Limitations and Future Work

While highly effective, the extraction method relies on a library of "guessed" preprocessors. If a system uses a highly custom, proprietary, or randomized preprocessor, extraction would be significantly more difficult. Furthermore, the Biased-Gradient attack requires a differentiable approximation of the preprocessor, which might pose a challenge for exotic or non-linear preprocessors.

Future work should look into "active" preprocessing defenses that are specifically designed to be difficult to reverse-engineer or that introduce stochasticity (randomness) to break the extraction phase.

Summary updated

BibTeX
@inproceedings{sitawarin2023preprocessors,
  author = {Chawin Sitawarin and Florian Tramèr and Nicholas Carlini},
  title = {{Preprocessors Matter! Realistic Decision-Based Attacks on Machine Learning Systems}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=ho3AhQgQ5o},
}
Figure