An Extensive Study on Adversarial Attack against Pre-trained Models of Code
Xiaohu Du, Ming Wen, Zichao Wei, Shangwen Wang, Hai Jin
摘要
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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 3 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial Training 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial Training 引用了 Adversarial examples for models of code
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial Training 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial Training 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial Training 引用了 Natural Attack for Pre-trained Models of Code
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Iterative Generation of Adversarial Example for Deep Code Models 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
- Iterative Generation of Adversarial Example for Deep Code Models 引用了 Adversarial examples for models of code
- Iterative Generation of Adversarial Example for Deep Code Models 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Iterative Generation of Adversarial Example for Deep Code Models 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- Iterative Generation of Adversarial Example for Deep Code Models 引用了 Natural Attack for Pre-trained Models of Code
- Natural Attack for Pre-trained Models of Code 引用了 Adversarial examples for models of code
- Natural Attack for Pre-trained Models of Code 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Natural Attack for Pre-trained Models of Code 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants 引用了 Adversarial examples for models of code
- XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants 引用了 Natural Attack for Pre-trained Models of Code
引用它的顶会 Paper3
- XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding AssistantsAdam Storek, Mukur Gupta, Noopur Bhatt, Aditya Gupta 等ACL 2026 · 5 次引用
- Mutual Learning-Based Framework for Enhancing Robustness of Code Models via Adversarial TrainingYangsen Wang, Yizhou Chen, Yifan Zhao, Zhihao Gong 等ASE 2024 · 3 次引用
- Iterative Generation of Adversarial Example for Deep Code ModelsLi Huang, Weifeng Sun, Meng YanICSE 2025 · 1 次引用
它引用的 Paper14
- CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan 等EMNLP Findings 2020 · 2,828 次引用
- GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng 等ICLR 2021 · 1,644 次引用
- CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 次引用
- Adversarial examples for models of codeNoam Yefet, Uri Alon, Eran YahavOOPSLA 2020 · 162 次引用
- Natural Attack for Pre-trained Models of CodeZhou Yang, Jieke Shi, Junda He, David LoICSE 2022 · 150 次引用
相关 Paper
- Evaluating and Enhancing the Robustness of Code Pre-trained Models through Structure-Aware Adversarial Samples GenerationNuo Chen, Qiushi Sun, Jianing Wang, Ming Gao 等EMNLP Findings 2023 · 3 次引用
- Statement-Level Adversarial Attack on Vulnerability Detection Models via Out-of-Distribution FeaturesXiaohu Du, Ming Wen, Haoyu Wang, Zichao Wei 等FSE 2025 · 1 次引用
- DIP: Dead code Insertion based Black-box Attack for Programming Language ModelCheolWon Na, YunSeok Choi, Jee-Hyong LeeACL 2023 · 13 次引用
- AACEGEN: Attention Guided Adversarial Code Example Generation for Deep Code ModelsZhong Li, Chong Zhang, Minxue Pan, Tian Zhang 等ASE 2024 · 4 次引用
- Code Difference Guided Adversarial Example Generation for Deep Code ModelsZhao Tian, Junjie Chen, Zhi JinASE 2023 · 27 次引用
