paperbot · PL 论文追踪

全部论文 待读 收藏

P2 An Extensive Study on Adversarial Attack against Pre-trained Models of Code

针对代码预训练模型的对抗攻击的广泛研究
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 3/10 · 该论文研究代码预训练模型的对抗攻击与鲁棒性评测,属于机器学习与程序语言交叉,但核心不是静态分析、形式化验证、浮点程序分析或贝叶斯程序分析,也与 Agentic/LLM 代码智能体的静态分析无关,仅与用户方向存在较弱的 PL+ML 交叉。引用 31 inbox
Xiaohu Du, Ming Wen, Zichao Wei, Shangwen Wang, Hai Jin
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:系统评测五种代码预训练模型对抗攻击方法,并提出按语句类型优先的 beam search 攻击,兼顾有效性与效率。

基于 Transformer 的代码预训练模型(PTMC)易受标识符替换或编码风格变换等对抗攻击,导致精度下降并带来安全隐患,但现有攻击方法在不同代码智能任务上的有效性与效率尚缺系统认识。本文从有效性、效率和生成样本质量三方面系统分析五种先进攻击方法,发现它们难以兼顾三者:高攻击成功率常伴随高耗时,生成代码自然性也不足。作者进一步发现,在 for 与 if 语句内进行标识符替换最有效,并提出按任务优先扰动特定语句类型、结合 beam search 生成对抗样本的新方法。评估显示,该方法在保持自然性的同时,有效性和效率均优于 ALERT。

问题
PTMC 在关键代码智能任务中易受对抗攻击,但已有攻击方法在不同任务上的有效性与效率缺乏系统理解。
方法
从有效性、效率与样本质量三方面评测五种先进攻击,分析标识符扰动上下文,并提出按任务优先语句类型并采用 beam search 的攻击方法。
评估
在多种代码智能任务上评估攻击有效性、效率与自然性,并与 ALERT 等先进方法比较。
原文摘要(Abstract)

Transformer-based pre-trained models of code (PTMC) have been widely utilized and have achieved state-of-the-art performance in many mission-critical applications. However, they can be vulnerable to adversarial attacks through identifier substitution or coding style transformation, which can significantly degrade accuracy and may further incur security concerns. Although several approaches have been proposed to generate adversarial examples for PTMC, the effectiveness and efficiency of such approaches, especially on different code intelligence tasks, has not been well understood. To bridge this gap, this study systematically analyzes five state-of-the-art adversarial attack approaches from three perspectives: effectiveness, efficiency, and the quality of generated examples. The results show that none of the five approaches balances all these perspectives. Particularly, approaches with a high attack success rate tend to be time-consuming; the adversarial code they generate often lack naturalness, and vice versa. To address this limitation, we explore the impact of perturbing identifiers under different contexts and find that identifier substitution within for and if statements is the most effective. Based on these findings, we propose a new approach that prioritizes different types of statements for various tasks and further utilizes beam search to generate adversarial examples. Evaluation results show that it outperforms the state-of-the-art ALERT in terms of both effectiveness and efficiency while preserving the naturalness of the generated adversarial examples.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{abs-2311-07553,
  title = {An Extensive Study on Adversarial Attack against Pre-trained Models of Code},
  author = {Xiaohu Du and Ming Wen and Zichao Wei and Shangwen Wang and Hai Jin},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616356}
}