TL;DR
While Meta’s Segment Anything Model 2 (SAM2) excels at video segmentation due to its advanced memory mechanism, its vulnerability to adversarial attacks has remained largely unexplored. This paper introduces UAP-SAM2, the first cross-prompt universal adversarial attack that disrupts SAM2's temporal consistency and frame-level semantics, causing target objects to completely "vanish into thin air" across different prompts and videos.
What Problem Does This Paper Address?
The original Segment Anything Model (SAM) revolutionized image segmentation but was highly vulnerable to adversarial perturbations—subtle, imperceptible changes to an image that fool the model. Its successor, SAM2, extends this capability to video by incorporating a memory bank that tracks object features across consecutive frames.
Interestingly, existing adversarial attacks designed for SAM fail miserably when deployed against SAM2. For instance, the state-of-the-art attack DarkSAM reduces SAM's performance by over 98%, yet only causes a minor 22% drop in SAM2.
The authors identify two core reasons for this newfound resilience:
- Directional guidance: SAM2 locks onto a persistent, video-specific prompt representation from the first frame.
- Semantic entanglement: SAM2 uses historical context cached in its memory bank to correct errors in individual frames.
To break SAM2, an attack must be universal (working across different videos and frames) and cross-prompt (effective regardless of whether a user clicks a point or draws a bounding box).
Methods
The authors propose UAP-SAM2, a framework that generates a single Universal Adversarial Perturbation (UAP) capable of breaking SAM2 across diverse prompts and video sequences. It achieves this via two main strategies:
1. Target-Scanning Strategy (Cross-Prompt Transferability)
Instead of optimizing the attack against a single user prompt, the framework divides each video frame into $m$ regions and randomly assigns prompts during training. Furthermore, instead of attacking the final prompt-dependent mask directly, the attack targets the output features of the Vision Encoder, making the perturbation prompt-agnostic.
2. Dual Semantic Deviation Framework (Effectiveness)
The attack optimizes the UAP by simultaneously attacking frame-level semantics and temporal consistency using three distinct losses:
- Semantic Confusion Attack ($J_{sa}$): Uses a binary cross-entropy loss to force the model to misinterpret foreground objects as background, and vice versa.
- Feature Shift Attack ($J_{fa}$): Employs contrastive learning to maximize the semantic distance between the features of the original benign frame and the adversarial frame.
- Memory Misalignment Attack ($J_{ma}$): Maximizes the feature discrepancy between consecutive adversarial frames, actively corrupting the information stored in SAM2's memory bank.
Datasets
The approach was evaluated on three public video object segmentation benchmarks:
- DAVIS 2017
- YouTube-VOS2018
- MOSE (Complex scenes)
To test static image segmentation, the authors also generated image-based variants (DAVIS*, YouTube*, and MOSE*) by randomly sampling static frames from the video datasets.
Key Insights and Ideas
- First-Frame Immunity: Attacking only the first frame of a video is insufficient. SAM2’s memory attention module can recover the correct object boundaries in later frames using uncorrupted spatial features.
- The Memory Bank Shield: Attacking a single middle frame in isolation also fails because the memory bank acts as an anchor, correcting the frame's distorted features during inference.
- The Avalanche Effect: To successfully fool SAM2, perturbations must be applied across consecutive frames. This induces a cascading failure where the memory bank accumulates errors over time, progressively destroying temporal alignment and causing a massive drop in cosine similarity between frame features.
Key Results
UAP-SAM2 was tested against various model sizes (SAM2-T, SAM2-S, SAM2.1-T) and significantly outperformed existing state-of-the-art attacks:
- Performance Drop: On the DAVIS dataset using point prompts, UAP-SAM2 reduced SAM2's mean Intersection over Union (mIoU) by over 45.79% (and up to 54.77% for its sample-wise variant).
- Video vs. Image: The attack consistently achieved stronger degradation on video segmentation than on static image segmentation, proving its unique capability to disrupt temporal consistency.
- Transferability: Perturbations generated on smaller models (SAM2-T) successfully transferred to larger architectures and long-video variants like Sam2long.
- Defense Resilience: The attack remained highly effective even when subjected to common defenses like model pruning or input data pre-processing (e.g., saturation and spatter corruptions).
Limitations and Future Work
The authors note that UAP-SAM2 is tailor-made for prompt-based video segmentation foundation models. As a result, it may not directly generalize to traditional, label-fixed segmentation frameworks where outputs are tied to specific class categories rather than class-free masks. Exploring how these adversarial vulnerabilities transfer across entirely different non-SAM video architectures remains an open direction for future research.
Summary updated