arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2311.07553cs.CRcs.AI
收藏

针对预训练代码模型的对抗攻击的广泛研究

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

Huazhong University of Science and Technology(华中科技大学);National University of Defense Technology(国防科技大学)

Xiaohu Du, Ming Wen, Zichao Wei, Shangwen Wang, Hai Jin

AI总结:

本研究系统分析了五种针对预训练代码模型的对抗攻击方法,发现其无法兼顾有效性、效率和样本质量。为此提出一种新方法,优先扰动for和if语句内的标识符并利用束搜索生成对抗样本,在有效性和效率上均优于ALERT且保持自然性。

摘要:

基于Transformer的预训练代码模型(PTMC)已被广泛使用,并在许多关键任务应用中取得了最先进的性能。然而,它们可能容易受到通过标识符替换或代码风格转换进行的对抗攻击,这会显著降低准确性并可能进一步引发安全问题。尽管已经提出了几种为PTMC生成对抗样本的方法,但此类方法的有效性和效率,特别是在不同代码智能任务上的表现,尚未得到充分理解。为了弥补这一空白,本研究从有效性、效率和生成样本的质量三个角度系统分析了五种最先进的对抗攻击方法。结果表明,这五种方法均无法平衡所有这些方面。具体而言,攻击成功率高的方法往往很耗时;它们生成的对抗代码通常缺乏自然性,反之亦然。为了解决这一局限性,我们探索了在不同上下文下扰动标识符的影响,发现for和if语句内的标识符替换最为有效。基于这些发现,我们提出了一种新方法,该方法针对不同任务优先处理不同类型的语句,并进一步利用束搜索来生成对抗样本。评估结果表明,它在有效性和效率方面均优于最先进的ALERT,同时保持了生成对抗样本的自然性。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑