Transferable Adversarial Attacks on SAM and Its Downstream Models

Song Xia, Wenhan Yang, Yi Yu, Xun Lin, Henghui Ding, Lingyu Duan, Xudong Jiang

Abstract

The Segment Anything Model (SAM) has emerged as a powerful foundation model for computer vision, often serving as a base for specialized downstream tasks through fine-tuning. However, this paper identifies a critical security vulnerability: specialized models inherit the intrinsic weaknesses of their foundation. We introduce UMI-GRAT, a novel attack framework that leverages the open-source SAM to generate highly transferable adversarial examples against "black-box" fine-tuned models. By combining Universal Meta-Initialization (UMI) with a Gradient Robust Adversarial Attack (GRAT), we demonstrate that attackers can severely compromise task-specific models without access to their private data or weights.

Introduction

Foundation models like SAM are typically trained on massive datasets and then adapted for niche applications, such as medical imaging or shadow detection. While this paradigm offers exceptional performance, it introduces a significant security risk. Traditional adversarial attacks often require a surrogate model similar to the target. In the case of SAM, the publicly available base model acts as a natural surrogate. This paper explores whether the "knowledge" inherited during fine-tuning also includes transferable vulnerabilities that can be exploited by an attacker with access only to the original foundation model.

Methodology: UMI-GRAT

The proposed UMI-GRAT framework consists of two distinct stages designed to overcome the "gradient disparity" between the base foundation model and its fine-tuned variants.

1. Universal Meta-Initialization (UMI)

UMI is an offline process that utilizes meta-learning (specifically the Reptile algorithm) to identify a universal noise pattern $\delta$. This pattern targets the core feature extraction capabilities of the SAM image encoder. By finding a perturbation that is effective across a wide range of natural images, UMI provides a potent starting point for image-specific attacks, ensuring they are more likely to adapt to the shifted gradients of a fine-tuned model.

2. Gradient Robust Adversarial Attack (GRAT)

To generate specific adversarial examples, the authors introduce a Gradient Robust Loss. Fine-tuning shifts a model's gradients, creating a gap between the surrogate (base SAM) and the victim. GRAT employs gradient-based noise augmentation to simulate this uncertainty. By making the adversarial perturbation robust to small variations in the gradient direction, the attack achieves significantly higher transferability to unknown downstream models.

Experimental Evaluation

The effectiveness of UMI-GRAT was tested across three diverse domains: Medical Segmentation (Synapse dataset), Shadow Segmentation (ISTD dataset), and Camouflaged Object Segmentation (COD10K, CHAMELEON, and CAMO datasets).

Key Results

The results indicate that UMI-GRAT is highly effective at degrading the performance of specialized models:

  • Medical SAM: The Mean Dice Similarity Score (mDSC) dropped from a clean baseline of 81.88% to just 5.22% under attack, significantly outperforming existing transfer attacks like BSR (25.7%).
  • Shadow SAM: The Bit Error Rate (BER) rose from 1.43 to 12.46, indicating a near-total failure of the segmentation task.
  • Efficiency: The real-time generation of adversarial examples takes approximately 0.36 seconds on an RTX 4090, highlighting the practical threat posed by such attacks in real-world scenarios.

Discussion and Conclusion

The primary insight of this work is that the generalized features learned by foundation models are the very same features targeted by adversarial attacks. Fine-tuning does not "wash away" these vulnerabilities; instead, it creates a "gradient gap" that UMI-GRAT successfully bridges. While this study focuses on the ViT-based architecture of SAM, the principles of inherited vulnerability likely extend to other foundation models. This research serves as a critical call to action for developing robust fine-tuning techniques that can mitigate these inherited risks.

Summary updated

BibTeX
@inproceedings{xia2024transferable,
  author = {Song Xia and Wenhan Yang and Yi Yu and Xun Lin and Henghui Ding and LINGYU DUAN and Xudong Jiang},
  title = {{Transferable Adversarial Attacks on SAM and Its Downstream Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=yDjojeIWO9},
}
Figure