通过尖锐性感知对抗扰动实现代码模型的可迁移后门攻击
Transferable Backdoor Attacks for Code Models via Sharpness-Aware Adversarial Perturbation
AI总结:
STAB通过尖锐性感知对抗扰动实现代码模型的可迁移后门攻击,提升攻击的可转移性和隐蔽性。
摘要:
代码模型在软件开发中被越来越多地采用,但仍然容易受到通过污染训练数据进行的后门攻击。现有的代码模型后门攻击面临可转移性和隐蔽性之间的根本权衡。基于静态触发的攻击插入固定死代码模式,这些模式在模型和数据集之间转移良好,但容易被代码特定的防御措施检测到。相反,基于动态触发的攻击会自适应地生成上下文感知的触发器以逃避检测,但它们在跨数据集的可转移性方面表现较差。此外,它们依赖于不现实的假设,即污染数据和受害者训练数据之间的数据分布相同,限制了其实用性。为了克服这些限制,我们提出了尖锐性感知可迁移对抗后门(STAB),一种新的攻击方法,能够在不需完整受害者数据的情况下实现可转移性和隐蔽性。STAB受到观察的启发,即损失景观平坦区域的对抗扰动在跨数据集之间转移更有效,而不是在尖锐最小值中。为此,我们使用尖锐性感知最小化训练一个代理模型,以引导模型参数朝向平坦损失区域,并利用Gumbel-Softmax优化在离散触发令牌上进行可微分搜索,以生成上下文感知的对抗触发器。在三个数据集和两个代码模型上的实验表明,STAB在可转移性和隐蔽性方面优于先前的攻击。在防御后,STAB实现了73.2%的平均攻击成功率,优于在防御下失败的静态触发攻击。STAB还在跨数据集攻击成功率上超过了最佳动态触发攻击,提高了12.4%,并在干净输入上保持了性能。
英文摘要:
Code models are increasingly adopted in software development but remain vulnerable to backdoor attacks via poisoned training data. Existing backdoor attacks on code models face a fundamental trade-off between transferability and stealthiness. Static trigger-based attacks insert fixed dead code patterns that transfer well across models and datasets but are easily detected by code-specific defenses. In contrast, dynamic trigger-based attacks adaptively generate context-aware triggers to evade detection but suffer from poor cross-dataset transferability. Moreover, they rely on unrealistic assumptions of identical data distributions between poisoned and victim training data, limiting their practicality. To overcome these limitations, we propose Sharpness-aware Transferable Adversarial Backdoor (STAB), a novel attack that achieves both transferability and stealthiness without requiring complete victim data. STAB is motivated by the observation that adversarial perturbations in flat regions of the loss landscape transfer more effectively across datasets than those in sharp minima. To this end, we train a surrogate model using Sharpness-Aware Minimization to guide model parameters toward flat loss regions, and employ Gumbel-Softmax optimization to enable differentiable search over discrete trigger tokens for generating context-aware adversarial triggers. Experiments across three datasets and two code models show that STAB outperforms prior attacks in terms of transferability and stealthiness. It achieves a 73.2% average attack success rate after defense, outperforming static trigger-based attacks that fail under defense. STAB also surpasses the best dynamic trigger-based attack by 12.4% in cross-dataset attack success rate and maintains performance on clean inputs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。