arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.24119cs.SE
收藏

增强神经代码模型的鲁棒性边界报告

Enhancing and Reporting Robustness Boundary of Neural Code Models for Intelligent Code Understanding

State Key Laboratory for Novel Software Technology, Nanjing University(南京大学新型软件技术重点实验室);Shenzhen Research Institute of Nanjing University(南京大学深圳研究院);School of Computer Science and Engineering, University of New South Wales(新南威尔士大学计算机科学与工程学院);School of Computer Science and Engineering, Nanyang Technological University(南洋理工大学计算机科学与工程学院);School of Computer Science and Technology, Soochow University(苏州大学计算机科学与技术学院)

Tingxu Han, Wei Song, Weisong Sun, Hao Wu, Chunrong Fang, Yuan Xiao, Xiaofang Zhang, Zhenyu Chen, Yang Liu

AI总结:

本文提出ENBECOME,一种无需训练的轻量级对抗防御方法,通过推理时引入语义保持的扰动,提升神经代码模型的鲁棒性并报告认证鲁棒性边界。

摘要:

随着深度学习的发展,神经代码模型(NCMs)如CodeBERT和CodeLlama被广泛用于代码理解任务,包括缺陷检测和代码分类。然而,最近的研究揭示了NCMs对对抗性示例的易受攻击性,这些示例是微小扰动的输入,能诱导错误预测但难以检测。现有防御措施通过数据增强来经验性地提高鲁棒性,但它们成本高,没有理论鲁棒性保证,并且通常需要白盒访问模型内部,如梯度。为了解决上述挑战,我们提出ENBECOME,一种新颖的黑盒训练免费且轻量级的对抗防御方法。ENBECOME旨在同时增强经验鲁棒性并为NCMs报告认证鲁棒性边界。ENBECOME仅在推理期间运行,向输入代码片段引入随机、语义保持的扰动以平滑NCM的决策边界。这种平滑使ENBECOME能够正式认证一个鲁棒性半径,在此半径内对抗性示例绝不会导致误分类,这一特性称为认证鲁棒性。我们对多种NCM架构和任务进行了全面实验。结果表明,ENBECOME显著降低了攻击成功率,同时保持高精度。例如,在缺陷检测中,它将平均攻击成功率(ASR)从42.43%降低到9.74%,仅导致0.29%的精度下降。此外,ENBECOME实现了平均认证鲁棒性半径为1.63,意味着对抗性修改不超过1.63个标识符的修改被证明无效。

英文摘要:

With the development of deep learning, Neural Code Models (NCMs) such as CodeBERT and CodeLlama are widely used for code understanding tasks, including defect detection and code classification. However, recent studies have revealed that NCMs are vulnerable to adversarial examples, inputs with subtle perturbations that induce incorrect predictions while remaining difficult to detect. Existing defenses address this issue via data augmentation to empirically improve robustness, but they are costly, offer no theoretical robustness guarantees, and typically require white-box access to model internals, such as gradients. To address the above challenges, we propose ENBECOME, a novel black-box training-free and lightweight adversarial defense. ENBECOME is designed to both enhance empirical robustness and report certified robustness boundaries for NCMs. ENBECOME operates solely during inference, introducing random, semantics-preserving perturbations to input code snippets to smooth the NCM's decision boundaries. This smoothing enables ENBECOME to formally certify a robustness radius within which adversarial examples can never induce misclassification, a property known as certified robustness. We conduct comprehensive experiments across multiple NCM architectures and tasks. Results show that ENBECOME significantly reduces attack success rates while maintaining high accuracy. For example, in defect detection, it reduces the average ASR from 42.43% to 9.74% with only a 0.29% drop in accuracy. Results show that ENBECOME significantly reduces attack success rates while maintaining high accuracy. For example, in defect detection, it reduces the average ASR from 42.43% to 9.74% with only a 0.29% drop in accuracy. Furthermore, ENBECOME achieves an average certified robustness radius of 1.63, meaning that adversarial modifications to no more than 1.63 identifiers are provably ineffective.

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

↑