paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Attribution-guided Adversarial Code Prompt Generation for Code Completion Models

归因引导的面向代码补全模型的对抗代码提示生成
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 3/10 · 该论文研究代码补全模型的对抗提示生成与安全鲁棒性,属于 LLM/代码模型安全方向,而非用户核心关注的静态分析、形式化验证及其与 LLM 的交叉,也基本不涉及浮点或贝叶斯程序分析。仅与“LLM/Agentic 程序安全”有间接关联。引用 13 inbox
Xueyang Li, Guozhu Meng, Shangqing Liu, Lu Xiang, Kun Sun, Kai Chen, Xiapu Luo, Yang Liu
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 AdvPro,用梯度归因定位关键代码并结合 14 种保语义变异策略,自动生成对抗代码提示攻击代码补全模型。

代码补全模型在提升开发效率的同时也带来安全风险:它们可能无意引入漏洞,或被对抗性代码提示诱导生成不安全代码,而已有研究多聚焦鲁棒性,安全性分析尚不充分。本文提出 AdvPro,一种可自动生成对抗代码提示的方法。该方法在五个粒度层级上集成 14 种代码变异策略,并保证变异不改变代码语义,使其对模型而言本应不敏感;同时利用梯度归因定位代码中的重要位置作为变异点,以加速对抗提示生成。作者在 7 个家族的 13 个先进模型上开展实验,结果显示所生成对抗提示相较基线 ALERT 使攻击成功率提升 69.6%;归因定位对比表明不同模型对输入代码重要 token 的识别结果几乎一致,从而降低了用开源替代模型指导针对闭源模型攻击的限制;消融实验还发现代码补全模型重点关注变量名,但其他结构同样关键。

问题
代码补全模型可能无意引入漏洞,或被对抗性代码提示诱导生成不安全代码,而其安全性尚未被充分分析,缺少自动生成对抗提示的有效手段。
方法
提出 AdvPro,在五个粒度层级上组合 14 种不改变代码语义的变异策略,并利用梯度归因定位代码中的关键位置作为变异点,从而加速对抗代码提示的生成。
评估
在 7 个家族共 13 个先进代码补全模型上进行实验,对抗提示的生成效果较基线 ALERT 提升 69.6%;通过归因定位对比分析不同模型的重要 token 识别一致性,并对 AdvPro 各组件开展消融研究。
原文摘要(Abstract)

Large language models have made significant progress in code completion, which may further remodel future software development. However, these code completion models are found to be highly risky as they may introduce vulnerabilities unintentionally or be induced by a special input, i.e., adversarial code prompt. Prior studies mainly focus on the robustness of these models, but their security has not been fully analyzed.In this paper, we propose a novel approach AdvPro that can automatically generate adversarial code prompts for these code completion models. AdvPro incorporates 14 code mutation strategies at the granularity of five levels. The mutation strategies are ensured to make no modifications to code semantics, which should be insensitive to the models. Moreover, we leverage gradient attribution to localize the important code as mutation points and speed up adversarial prompt generation. Extensive experiments are conducted on 13 state-of-the-art models belonging to 7 families. The results show that our approach can effectively generate adversarial prompts, with an increased rate of 69.6% beyond the baseline ALERT. By comparing the results of attribution-guided localization, we find that the recognition results of important tokens in input codes are almost identical among different models. This finding reduces the limitation of using open-source alternative models to guide adversarial attacks against closed-source models. The results of the ablation study on the components of AdvPro show that CCMs focus on variable names, but other structures are equally crucial.CCS CONCEPTS• Software and its engineering → Software testing and debugging; • Security and privacy → Software security engineering.

链接与引用

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

BibTeX
@inproceedings{LiMLXS0L024,
  title = {Attribution-guided Adversarial Code Prompt Generation for Code Completion Models},
  author = {Xueyang Li and Guozhu Meng and Shangqing Liu and Lu Xiang and Kun Sun and Kai Chen and Xiapu Luo and Yang Liu},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695517}
}