ViTGuard: Attention-aware Detection against Adversarial Examples for Vision Transformer
作者: Shihua Sun, Kenechukwu Nwodo, Shridatt Sugrim, Angelos Stavrou, Haining Wang
分类: cs.CV, cs.CR
发布日期: 2024-09-20
备注: To appear in the Annual Computer Security Applications Conference (ACSAC) 2024
💡 一句话要点
ViTGuard:提出一种基于注意力机制的对抗样本检测方法,用于防御Vision Transformer的攻击。
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱七:动作重定向 (Motion Retargeting)
关键词: Vision Transformer 对抗样本检测 注意力机制 Masked Autoencoder 图像重建
📋 核心要点
- Vision Transformer (ViT) 易受对抗攻击,特别是对抗补丁攻击,而传统CNN防御方法在ViT上效果不佳。
- ViTGuard利用MAE进行图像重建,并结合ViT的注意力图和CLS token表示,设计阈值检测器区分正常样本和对抗样本。
- 实验表明,ViTGuard在多个数据集和攻击类型下,显著优于现有检测方法,并对自适应攻击具有鲁棒性。
📝 摘要(中文)
本文提出了一种名为ViTGuard的通用检测方法,用于防御Vision Transformer模型免受对抗样本攻击,包括扰动遍布整个输入的典型攻击和补丁攻击。ViTGuard使用Masked Autoencoder (MAE) 模型从未被mask的区域恢复随机mask的图像块,提供了一种灵活的图像重建策略。然后,基于阈值的检测器利用独特的ViT特征,包括注意力图和分类(CLS)token表示,来区分正常样本和对抗样本。MAE模型在训练过程中不涉及任何对抗样本,确保了检测器对未见攻击的有效性。在三个数据集上,ViTGuard与七种现有检测方法在九种攻击下进行了比较。评估结果表明ViTGuard优于现有检测器。最后,考虑到潜在的检测逃逸,进一步证明了ViTGuard对逃逸自适应攻击的鲁棒性。
🔬 方法详解
问题定义:ViT虽然在图像分类任务中表现出色,但容易受到对抗样本的攻击,特别是对抗补丁攻击。现有的针对CNN设计的对抗样本检测方法在ViT上效果不佳,并且通常忽略了补丁攻击。因此,需要一种专门为ViT设计的,能够有效检测各种对抗攻击(包括全局扰动和补丁攻击)的方法。
核心思路:ViTGuard的核心思路是利用Masked Autoencoder (MAE)进行图像重建,并结合ViT模型自身的特性(如注意力图和CLS token表示)来区分正常样本和对抗样本。通过MAE重建图像,可以突出对抗扰动的影响。注意力图和CLS token能够反映图像的关键区域和分类信息,对抗样本会显著改变这些特征。
技术框架:ViTGuard的整体框架包括以下几个主要步骤:1) 使用MAE模型对输入图像进行重建,该MAE模型在正常图像上训练,用于捕捉图像的正常分布;2) 提取ViT模型的注意力图和CLS token表示;3) 基于重建误差、注意力图和CLS token,设计基于阈值的检测器,判断输入样本是否为对抗样本。
关键创新:ViTGuard的关键创新在于:1) 结合MAE进行图像重建,增强了对抗扰动的可检测性;2) 利用ViT模型自身的注意力机制和CLS token,设计了更具针对性的检测器,避免了对额外特征的依赖;3) 该方法无需对抗样本参与训练,能够有效防御未知的对抗攻击。
关键设计:ViTGuard的关键设计包括:1) MAE模型的选择和训练:选择合适的MAE模型结构,并在大量正常图像上进行训练,使其能够准确重建正常图像;2) 注意力图和CLS token的提取:选择合适的ViT层提取注意力图,并使用CLS token作为全局图像表示;3) 阈值的设定:通过实验确定合适的阈值,用于区分正常样本和对抗样本。阈值的设定需要平衡检测准确率和误报率。
🖼️ 关键图片
📊 实验亮点
ViTGuard在三个数据集(CIFAR-10, CIFAR-100, Tiny ImageNet)和九种攻击类型下进行了评估,实验结果表明,ViTGuard在检测对抗样本方面显著优于现有的七种检测方法。例如,在某些攻击下,ViTGuard的检测准确率比现有方法提高了10%以上,并且对自适应攻击表现出良好的鲁棒性。
🎯 应用场景
ViTGuard可应用于各种需要图像分类的场景,例如自动驾驶、医疗图像分析、安全监控等。通过提高ViT模型对对抗攻击的鲁棒性,可以增强这些应用的安全性和可靠性,防止恶意攻击者利用对抗样本进行欺骗或破坏。
📄 摘要(原文)
The use of transformers for vision tasks has challenged the traditional dominant role of convolutional neural networks (CNN) in computer vision (CV). For image classification tasks, Vision Transformer (ViT) effectively establishes spatial relationships between patches within images, directing attention to important areas for accurate predictions. However, similar to CNNs, ViTs are vulnerable to adversarial attacks, which mislead the image classifier into making incorrect decisions on images with carefully designed perturbations. Moreover, adversarial patch attacks, which introduce arbitrary perturbations within a small area, pose a more serious threat to ViTs. Even worse, traditional detection methods, originally designed for CNN models, are impractical or suffer significant performance degradation when applied to ViTs, and they generally overlook patch attacks. In this paper, we propose ViTGuard as a general detection method for defending ViT models against adversarial attacks, including typical attacks where perturbations spread over the entire input and patch attacks. ViTGuard uses a Masked Autoencoder (MAE) model to recover randomly masked patches from the unmasked regions, providing a flexible image reconstruction strategy. Then, threshold-based detectors leverage distinctive ViT features, including attention maps and classification (CLS) token representations, to distinguish between normal and adversarial samples. The MAE model does not involve any adversarial samples during training, ensuring the effectiveness of our detectors against unseen attacks. ViTGuard is compared with seven existing detection methods under nine attacks across three datasets. The evaluation results show the superiority of ViTGuard over existing detectors. Finally, considering the potential detection evasion, we further demonstrate ViTGuard's robustness against adaptive attacks for evasion.