基于表示最近邻搜索的代码模型黑盒攻击
A Black-Box Attack on Code Models via Representation Nearest Neighbor Search
AI总结:
RNNS通过预训练编码器将替代变量映射到连续向量空间,在六项任务和18个受害模型上显著提升了攻击成功率并降低了扰动。
摘要:
现有的生成对抗性代码示例的方法面临几个挑战:替代变量的可用性有限,这些替代变量的验证成本高,以及创建具有明显扰动的对抗样本。为了解决这些问题,我们提出的方法 RNNS 使用基于历史攻击的搜索种子来寻找潜在的对抗性替代。不直接使用离散替代,而是使用预训练的变量名编码器将它们映射到连续向量空间。基于向量表示,RNNS 预测并选择更好的攻击替代。我们在涵盖三种编程语言(Java、Python 和 C)的六个编码任务中评估了 RNNS 的性能。我们使用了三个预训练代码模型(CodeBERT、GraphCodeBERT 和 CodeT5),共产生 18 个受害模型。结果表明,RNNS 在 ASR 和 QT 方面优于基线。此外,在替换变量数量和变量长度变化方面,RNNS 引入的对抗样本扰动比基线更小。最后,我们的实验表明,RNNS 在攻击防御模型方面有效,并可用于对抗训练。
英文摘要:
Existing methods for generating adversarial code examples face several challenges: limted availability of substitute variables, high verification costs for these substitutes, and the creation of adversarial samples with noticeable perturbations. To address these concerns, our proposed approach, RNNS, uses a search seed based on historical attacks to find potential adversarial substitutes. Rather than directly using the discrete substitutes, they are mapped to a continuous vector space using a pre-trained variable name encoder. Based on the vector representation, RNNS predicts and selects better substitutes for attacks. We evaluated the performance of RNNS across six coding tasks encompassing three programming languages: Java, Python, and C. We employed three pre-trained code models (CodeBERT, GraphCodeBERT, and CodeT5) that resulted in a cumulative of 18 victim models. The results demonstrate that RNNS outperforms baselines in terms of ASR and QT. Furthermore, the perturbation of adversarial examples introduced by RNNS is smaller compared to the baselines in terms of the number of replaced variables and the change in variable length. Lastly, our experiments indicate that RNNS is efficient in attacking defended models and can be employed for adversarial training.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。