On the Detection of Image-Scaling Attacks in Machine Learning

Erwin Quiring, Andreas Müller, Konrad Rieck

Introduction: The Vulnerability of Image Scaling

In modern computer vision pipelines, image scaling is a fundamental preprocessing step. Neural networks such as ResNet or VGG19 require fixed input dimensions (e.g., 224x224), necessitating the downscaling of high-resolution images. However, most standard scaling algorithms, including nearest-neighbor and bilinear interpolation, are computationally "lazy"—they sample only a small fraction of the original pixels to generate the output.

This behavior creates a significant security vulnerability known as an image-scaling attack. An attacker can craft an "Attack Image" that appears benign to a human (e.g., a "Speed Limit 25" sign) but transforms into a malicious "Target Image" (e.g., a "Wrong Way" sign) once processed by the model's scaling layer. These attacks can be used to trigger misclassifications or inject backdoors into training datasets.

Mechanism of an image-scaling attack: an attacker finds a perturbation Δ to create an Attack Image A that visually resembles Source S but scales down to Target T.

Detection Paradigms

While previous research has focused on preventing these attacks through robust scaling, this work provides the first systematic approach to detecting them. The authors categorize detection into two primary paradigms: frequency analysis and spatial analysis.

Overview of global vs. local attack types and the two primary detection paradigms: frequency and spatial analysis.

1. Frequency Analysis

Scaling attacks inherently introduce periodic, grid-like patterns into an image to align with the scaling algorithm’s sampling rate. These patterns leave distinct "fingerprints" in the frequency domain, which can be identified using the 2D Discrete Fourier Transform (DFT).

  • Peak Spectrum: This method calculates the percentile rank of expected frequency peaks. An attack is detected if these peaks significantly exceed the rest of the spectrum.
  • Peak Distance: This measures the deviation between observed maximum peaks and their theoretical locations based on the known scaling ratio.

2. Spatial Analysis

Spatial analysis examines the pixel data directly to identify anomalies.

  • Adversarial-Signal Driven: By performing a "down-and-upscaling" operation, the adversarial signal is amplified, making it detectable when compared to the original input.
  • Clean-Signal Driven: This approach uses "prevention filters" (such as median filters) to estimate the clean version of the image. Discrepancies between this reconstructed version and the input indicate an attack.
  • Patch-Based Detection: To counter local attacks—where only a small portion of the image, such as a backdoor trigger, is modified—the image is analyzed in local patches to prevent the signal from being diluted.

Experimental Setup

The proposed methods were evaluated using standard benchmarks:

  • ImageNet: Primary source for generating diverse attack and benign image pairs.
  • CIFAR-10: Used to verify the impact of backdoor attacks during model training.
  • VGG19: Served as the target architecture for evaluating Attack Success Rate (ASR).

Core Insights

The study highlights that scaling attacks are fundamentally periodic. By hitting specific pixel coordinates, attackers inadvertently create synthetic, crystal-like structures that are highly visible in the Fourier spectrum. While frequency analysis detects these symptoms, spatial analysis addresses the root cause—the ignored pixels.

An "adaptive trade-off" was also observed: while attackers can attempt to suppress frequency peaks to evade detection, doing so typically degrades the attack's effectiveness or the resulting image quality.

Experimental Performance

  • Global Attacks: The Peak Distance frequency method achieved a 100% detection rate with zero false positives in scenarios where the entire image was manipulated.
  • Local/Backdoor Attacks: Detecting localized triggers is more challenging, yet frequency-based methods still achieved approximately 90% accuracy, far outperforming existing heuristics.
  • Ensemble Defense: Combining frequency and spatial methods creates a robust defense that forces attackers to satisfy conflicting constraints, making evasion extremely difficult.

Conclusion

This research demonstrates that image-scaling attacks, while stealthy, leave detectable traces. By integrating frequency and spatial analysis into an ensemble, security can be significantly enhanced. Future work may involve embedding these detection mechanisms directly into machine learning frameworks as standard preprocessing security checks.

Summary updated

Abstract

Image scaling is an integral part of machine learning and computer vision systems. Unfortunately, this preprocessing step is vulnerable to so-called image-scaling attacks where an attacker makes unnoticeable changes to an image so that it becomes a new image after scaling. This opens up new ways for attackers to control the prediction or to improve poisoning and backdoor attacks. While effective techniques exist to prevent scaling attacks, their detection has not been rigorously studied yet. Consequently, it is currently not possible to reliably spot these attacks in practice. This paper presents the first in-depth systematization and analysis of detection methods for image-scaling attacks. We identify two general detection paradigms and derive novel methods from them that are simple in design yet significantly outperform previous work. We demonstrate the efficacy of these methods in a comprehensive evaluation with all major learning platforms and scaling algorithms. First, we show that image-scaling attacks modifying the entire scaled image can be reliably detected even under an adaptive adversary. Second, we find that our methods provide strong detection performance even if only minor parts of the image are manipulated. As a result, we can introduce a novel protection layer against image-scaling attacks.
BibTeX
@inproceedings{quiring2024detection,
  author = {Erwin Quiring and Andreas Müller and Konrad Rieck},
  title = {{On the Detection of Image-Scaling Attacks in Machine Learning}},
  booktitle = {ACSAC '23: Proceedings of the 39th Annual Computer Security Applications Conference},
  year = {2024},
  url = {https://openreview.net/forum?id=MP78vCrhlJ},
}
Figure