An Extensive Study on Adversarial Attack against Pre-trained Models of Code
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). Builds on 23 of its 47 references that are in the map. First posted on arXiv 13 Nov 2023.
Builds on
23 of 47 references.
References · 23
- 2017Attention Is All You Needcited by 59,932
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2020Pre-trained Models for Natural Language Processing: A Surveycited by 504
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2021Pre-Trained Models: Past, Present and Futurecited by 319
- 2021A Unified Survey on Anomaly, Novelty, Open-Set, and Out-of-Distribution Detection: Solutions and Future Challengescited by 154
- 2020OpenAttack: An Open-source Textual Adversarial Attack Toolkitcited by 84
- 2022Natural Attack for Pre-trained Models of Codecited by 72
11 more
- 2020Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Treecited by 68
- 2019Adversarial Examples for Models of Codecited by 61
- 2021On the Evaluation of Neural Code Summarizationcited by 47
- 2020Semantic Robustness of Models of Source Codecited by 43
- 2020On the Generalizability of Neural Program Models with respect to Semantic-Preserving Program Transformationscited by 41
- 2022No More Fine-Tuning? An Experimental Evaluation of Prompt Tuning in Code Intelligencecited by 41
- 2021Adversarial Robustness of Deep Code Comment Generationcited by 22
- 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 20
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 13
- 2021A Search-Based Testing Framework for Deep Neural Networks of Source Code Embeddingcited by 12
- 2022An In-depth Study of Java Deserialization Remote-Code Execution Exploits and Vulnerabilitiescited by 2
Built on by
Citing papers per year: 2024: 2; 2025: 5; 2026: 1.
8 papers.
- 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testingcited by 5
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
- 2025Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judgecited by 4
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detectioncited by 4
- 2025A Metamorphic Testing Perspective on Knowledge Distillation for Language Models of Code: Does the Student Deeply Mimic the Teacher?cited by 1
- 2025Enhancing Large Language Models with Faster Code Preprocessing for Vulnerability Detectioncited by 0
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Qualitycited by 0
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Quality22 Sep 2026
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detection18 Dec 2025
- 2025A Metamorphic Testing Perspective on Knowledge Distillation for Language Models of Code: Does the Student Deeply Mimic the Teacher?7 Nov 2025
- 2025Enhancing Large Language Models with Faster Code Preprocessing for Vulnerability Detection8 May 2025
- 2025Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judge28 Apr 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuning6 Jun 2024
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testing19 Feb 2024