Natural Attack for Pre-trained Models of Code
Not on the map. Why?
Abstract (arXiv)
Pre-trained models of code have achieved success in many important software engineering tasks. However, these powerful models are vulnerable to adversarial attacks that slightly perturb model inputs to make a victim model produce wrong outputs. Current works mainly attack models of code with examples that preserve operational program semantics but ignore a fundamental requirement for adversarial example generation: perturbations should be natural to human judges, which we refer to as naturalness requirement. In this paper, we propose ALERT (nAturaLnEss AwaRe ATtack), a black-box attack that adversarially transforms inputs to make victim models produce wrong outputs. Different from prior works, this paper considers the natural semantic of generated examples at the same time as preserving the operational semantic of original inputs. Our user study demonstrates that human developers consistently consider that adversarial examples generated by ALERT are more natural than those generated by the state-of-the-art work by Zhang et al. that ignores the naturalness requirement. On attacking CodeBERT, our approach can achieve attack success rates of 53.62%, 27.79%, and 35.78% across three downstream tasks: vulnerability prediction, clone detection and code authorship attribution. On GraphCodeBERT, our approach can achieve average success rates of 76.95%, 7.96% and 61.47% on the three tasks. The above outperforms the baseline by 14.07% and 18.56% on the two pre-trained models on average. Finally, we investigated the value of the generated adversarial examples to harden victim models through an adversarial fine-tuning procedure and demonstrated the accuracy of CodeBERT and GraphCodeBERT against ALERT-generated adversarial examples increased by 87.59% and 92.32%, respectively.
Key facts. Cited by 72 papers in the map (data through 7 Oct 2026). First posted on arXiv 21 Jan 2022.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2022: 7; 2023: 18; 2024: 13; 2025: 22; 2026: 12.
72 papers.
Sort:
By area:
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 100
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 48
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directionscited by 48
- 2023Uncovering the Limits of Machine Learning for Automatic Vulnerability Detectioncited by 30
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Modelscited by 28
- 2023A DPLL(T) Framework for Verifying Deep Neural Networkscited by 23
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmapscited by 19
- 2023Towards Fair Machine Learning Software: Understanding and Addressing Model Bias Through Counterfactual Thinkingcited by 14
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 13
38 more
- 2024What can Large Language Models Capture about Code Functional Equivalence?cited by 13
- 2022An Exploratory Study on Code Attention in BERTcited by 12
- 2022Don't Complete It! Preventing Unhelpful Code Completion for Productive and Sustainable Neural Code Completion Systemscited by 12
- 2023Pitfalls in Language Models for Code Intelligence: A Taxonomy and Surveycited by 9
- 2023Turbulence: Systematically and Automatically Testing Instruction-Tuned Large Language Models for Codecited by 9
- 2024Token Alignment via Character Matching for Subword Completioncited by 9
- 2023An Extensive Study on Adversarial Attack against Pre-trained Models of Codecited by 8
- 2024Model Editing for LLMs4Code: How Far are We?cited by 8
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Modelscited by 7
- 2023LEAP: Efficient and Automated Test Method for NLP Softwarecited by 6
- 2023Boosting Source Code Learning with Text-Oriented Data Augmentation: An Empirical Studycited by 5
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testingcited by 5
- 2024Data Quality Issues in Vulnerability Detection Datasetscited by 5
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?cited by 5
- 2023Multi-Granularity Detector for Vulnerability Fixescited by 4
- 2024CodeFort: Robust Training for Code Generation Modelscited by 4
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMscited by 4
- 2025EditLord: Learning Code Transformation Rules for Code Editingcited by 4
- 2025Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judgecited by 4
- 2025Chimera: Harnessing Multi-Agent LLMs for Automatic Insider Threat Simulationcited by 4
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
- 2025When Names Disappear: Revealing What LLMs Actually Understand About Codecited by 4
- 2025The Future of Generative AI in Software Engineering: A Vision from Industry and Academia in the European GENIUS Projectcited by 4
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detectioncited by 4
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Softwarecited by 4
- 2023A Black-Box Attack on Code Models via Representation Nearest Neighbor Searchcited by 3
- 2023Enhancing Robustness of AI Offensive Code Generators via Data Augmentationcited by 3
- 2025Evaluating LLaMA 3.2 for Software Vulnerability Detectioncited by 3
- 2025Revisiting Pre-trained Language Models for Vulnerability Detectioncited by 3
- 2022Semantic-Preserving Adversarial Code Comprehensioncited by 2
- 2022CLAWSAT: Towards Both Robust and Accurate Code Modelscited by 2
- 2024GenCode: A Generic Data Augmentation Framework for Boosting Deep Learning-Based Code Understandingcited by 2
- 2024EaTVul: ChatGPT-based Evasion Attack Against Software Vulnerability Detectioncited by 2
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detectioncited by 2
- 2025CoTDeceptor:Adversarial Code Obfuscation Against CoT-Enhanced LLM Code Agentscited by 2
- 2026Evaluating LLM-Based Test Generation Under Software Evolutioncited by 2
- 2024Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidancecited by 1
50 most cited of 72 All 72 (JSON)
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Quality22 Sep 2026
- 2026Learning from the Test: Self-Referential Differential Testing for Deep RL Agents23 Aug 2026
- 2026A Jagged Frontier: Evaluating Robustness of Code Agents to Semantics-Preserving Transformations18 Aug 2026
- 2026Invariant Pretraining for Robust Code Representations15 Aug 2026
- 2026ALIBI: Adaptive Agentic Attacks on LLM-Based Vulnerability Detectors via Adversarial Code Comments27 Jul 2026
- 2026Spaghetti Architect: A Contamination-Resistant, By-Construction-Labelled, Multi-Language Code Dataset Generator21 Jul 2026
- 2026A Metamorphic Testing Approach to Diagnosing Memorization in LLM-Based Program Repair23 Apr 2026
- 2026Evaluating LLM-Based Test Generation Under Software Evolution24 Mar 2026
- 2026An Empirical Study of the Imbalance Issue in Software Vulnerability Detection12 Feb 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2026Many Hands Make Light Work: An LLM-based Multi-Agent System for Detecting Malicious PyPI Packages17 Jan 2026
- 2026Advancing Language Models for Code-related Tasks8 Jan 2026
38 more
- 2025CoTDeceptor:Adversarial Code Obfuscation Against CoT-Enhanced LLM Code Agents24 Dec 2025
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detection18 Dec 2025
- 2025Auto-SPT: Automating Semantic Preserving Transformations for Code5 Dec 2025
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Prompts19 Nov 2025
- 2025A Metamorphic Testing Perspective on Knowledge Distillation for Language Models of Code: Does the Student Deeply Mimic the Teacher?7 Nov 2025
- 2025The Future of Generative AI in Software Engineering: A Vision from Industry and Academia in the European GENIUS Project3 Nov 2025
- 2025When Names Disappear: Revealing What LLMs Actually Understand About Code3 Oct 2025
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025Chimera: Harnessing Multi-Agent LLMs for Automatic Insider Threat Simulation11 Aug 2025
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?25 Jul 2025
- 2025Revisiting Pre-trained Language Models for Vulnerability Detection22 Jul 2025
- 2025Coordinated Robustness Evaluation Framework for Vision-Language Models5 Jun 2025
- 2025Evaluate-and-Purify: Fortifying Code Language Models Against Adversarial Attacks Using LLM-as-a-Judge28 Apr 2025
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detection30 Mar 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2025EditLord: Learning Code Transformation Rules for Code Editing10 Mar 2025
- 2025Evaluating LLaMA 3.2 for Software Vulnerability Detection10 Mar 2025
- 2025Cross-site scripting adversarial attacks based on deep reinforcement learning: Evaluation and extension study26 Feb 2025
- 2025Poisoned Source Code Detection in Code Models19 Feb 2025
- 2025How to Select Pre-Trained Code Models for Reuse? A Learning Perspective7 Jan 2025
- 2024Model Editing for LLMs4Code: How Far are We?11 Nov 2024
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification26 Oct 2024
- 2024Data Quality Issues in Vulnerability Detection Datasets8 Oct 2024
- 2024What can Large Language Models Capture about Code Functional Equivalence?20 Aug 2024
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generation5 Aug 2024
- 2024EaTVul: ChatGPT-based Evasion Attack Against Software Vulnerability Detection27 Jul 2024
- 2024CodeFort: Robust Training for Code Generation Models11 Apr 2024
- 2024Token Alignment via Character Matching for Subword Completion13 Mar 2024
- 2024Beyond Self-learned Attention: Mitigating Attention Bias in Transformer-based Models Using Attention Guidance26 Feb 2024
- 2024GenCode: A Generic Data Augmentation Framework for Boosting Deep Learning-Based Code Understanding24 Feb 2024
- 2024Towards Reliable Evaluation of Neural Program Repair with Natural Robustness Testing19 Feb 2024
- 2024Studying Vulnerable Code Entities in R6 Feb 2024
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Models28 Jan 2024
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkit30 Dec 2023
- 2023Turbulence: Systematically and Automatically Testing Instruction-Tuned Large Language Models for Code22 Dec 2023
- 2023An Extensive Study on Adversarial Attack against Pre-trained Models of Code13 Nov 2023
50 newest of 72 All 72 (JSON)
- 2025Chimera: Harnessing Multi-Agent LLMs for Automatic Insider Threat Simulationcited by 4
- 2025CoTDeceptor:Adversarial Code Obfuscation Against CoT-Enhanced LLM Code Agentscited by 2
- 2026Many Hands Make Light Work: An LLM-based Multi-Agent System for Detecting Malicious PyPI Packagescited by 1
- 2026ALIBI: Adaptive Agentic Attacks on LLM-Based Vulnerability Detectors via Adversarial Code Commentscited by 0
- 2026A Jagged Frontier: Evaluating Robustness of Code Agents to Semantics-Preserving Transformationscited by 0
- 2026A Jagged Frontier: Evaluating Robustness of Code Agents to Semantics-Preserving Transformations18 Aug 2026
- 2026ALIBI: Adaptive Agentic Attacks on LLM-Based Vulnerability Detectors via Adversarial Code Comments27 Jul 2026
- 2026Many Hands Make Light Work: An LLM-based Multi-Agent System for Detecting Malicious PyPI Packages17 Jan 2026
- 2025CoTDeceptor:Adversarial Code Obfuscation Against CoT-Enhanced LLM Code Agents24 Dec 2025
- 2025Chimera: Harnessing Multi-Agent LLMs for Automatic Insider Threat Simulation11 Aug 2025
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Modelscited by 28
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purificationcited by 0
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 0
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Prompts19 Nov 2025
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification26 Oct 2024
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug 2023
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 100
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 48
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directionscited by 48
- 2023Uncovering the Limits of Machine Learning for Automatic Vulnerability Detectioncited by 30
- 2023A DPLL(T) Framework for Verifying Deep Neural Networkscited by 23
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmapscited by 19
- 2023Towards Fair Machine Learning Software: Understanding and Addressing Model Bias Through Counterfactual Thinkingcited by 14
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 13
- 2024What can Large Language Models Capture about Code Functional Equivalence?cited by 13
12 most cited of 62 All 62 (JSON)
- 2026On the Lexical Superstition of Large Language Models for Code Comprehension: Re-evaluation on Code of Low Lexical Quality22 Sep 2026
- 2026Invariant Pretraining for Robust Code Representations15 Aug 2026
- 2026Spaghetti Architect: A Contamination-Resistant, By-Construction-Labelled, Multi-Language Code Dataset Generator21 Jul 2026
- 2026A Metamorphic Testing Approach to Diagnosing Memorization in LLM-Based Program Repair23 Apr 2026
- 2026Evaluating LLM-Based Test Generation Under Software Evolution24 Mar 2026
- 2026An Empirical Study of the Imbalance Issue in Software Vulnerability Detection12 Feb 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2026Advancing Language Models for Code-related Tasks8 Jan 2026
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detection18 Dec 2025
- 2025Auto-SPT: Automating Semantic Preserving Transformations for Code5 Dec 2025
- 2025A Metamorphic Testing Perspective on Knowledge Distillation for Language Models of Code: Does the Student Deeply Mimic the Teacher?7 Nov 2025
12 newest of 62 All 62 (JSON)