基于判别性图模式的代码模型对抗攻击
Adversarial Attacks on Code Models with Discriminative Graph Patterns
AI总结:
针对现有代码模型对抗攻击采用固定变换、效果有限的问题,提出GraphCodeAttack框架,通过挖掘判别性AST模式生成死代码攻击,在三类任务上对主流代码模型的攻击效果优于现有最优方法。
摘要:
代码预训练语言模型目前已广泛应用于代码生成、代码补全、漏洞检测等各类软件工程任务,这也反过来给这些模型带来了安全与可靠性风险。其中一类重要威胁是对抗攻击,它会导致模型产生错误预测,大幅影响模型在下游任务上的性能。当前针对代码模型的对抗攻击通常采用固定的程序变换集合,比如变量重命名、死代码插入等,导致攻击效果有限。为解决上述挑战,我们提出了一种新型对抗攻击框架GraphCodeAttack,用于更好地评估代码模型的鲁棒性。针对目标代码模型,GraphCodeAttack会自动挖掘能够影响模型决策的重要代码模式,对输入模型的代码结构进行扰动。为实现这一点,GraphCodeAttack使用一组输入源代码探测模型的输出,识别出能够影响模型决策的“判别性”AST(抽象语法树)模式。随后GraphCodeAttack选择合适的AST模式,将选定的模式具体化为攻击向量,并将其作为死代码插入到模型的输入程序中。为了从AST模式高效合成攻击样本,GraphCodeAttack使用一个独立的预训练代码模型,用具体的代码片段填充AST结构。我们在作者归属、漏洞预测、克隆检测三个任务上,评估了CodeBERT和GraphCodeBERT这两种主流代码模型对所提方法的鲁棒性。实验结果表明,我们提出的方法在攻击代码模型方面的性能显著优于CARROT和ALERT等现有最优方法。
英文摘要:
Pre-trained language models of code are now widely used in various software engineering tasks such as code generation, code completion, vulnerability detection, etc. This, in turn, poses security and reliability risks to these models. One of the important threats is \textit{adversarial attacks}, which can lead to erroneous predictions and largely affect model performance on downstream tasks. Current adversarial attacks on code models usually adopt fixed sets of program transformations, such as variable renaming and dead code insertion, leading to limited attack effectiveness. To address the aforementioned challenges, we propose a novel adversarial attack framework, GraphCodeAttack, to better evaluate the robustness of code models. Given a target code model, GraphCodeAttack automatically mines important code patterns, which can influence the model's decisions, to perturb the structure of input code to the model. To do so, GraphCodeAttack uses a set of input source codes to probe the model's outputs and identifies the \textit{discriminative} ASTs patterns that can influence the model decisions. GraphCodeAttack then selects appropriate AST patterns, concretizes the selected patterns as attacks, and inserts them as dead code into the model's input program. To effectively synthesize attacks from AST patterns, GraphCodeAttack uses a separate pre-trained code model to fill in the ASTs with concrete code snippets. We evaluate the robustness of two popular code models (e.g., CodeBERT and GraphCodeBERT) against our proposed approach on three tasks: Authorship Attribution, Vulnerability Prediction, and Clone Detection. The experimental results suggest that our proposed approach significantly outperforms state-of-the-art approaches in attacking code models such as CARROT and ALERT.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。