Adversarial Examples for Models of Code
Not on the map. Why?
Abstract (arXiv)
Neural models of code have shown impressive results when performing tasks such as predicting method names and identifying certain kinds of bugs. We show that these models are vulnerable to adversarial examples, and introduce a novel approach for attacking trained models of code using adversarial examples. The main idea of our approach is to force a given trained model to make an incorrect prediction, as specified by the adversary, by introducing small perturbations that do not change the program's semantics, thereby creating an adversarial example. To find such perturbations, we present a new technique for Discrete Adversarial Manipulation of Programs (DAMP). DAMP works by deriving the desired prediction with respect to the model's inputs, while holding the model weights constant, and following the gradients to slightly modify the input code. We show that our DAMP attack is effective across three neural architectures: code2vec, GGNN, and GNN-FiLM, in both Java and C#. Our evaluations demonstrate that DAMP has up to 89% success rate in changing a prediction to the adversary's choice (a targeted attack) and a success rate of up to 94% in changing a given prediction to any incorrect prediction (a non-targeted attack). To defend a model against such attacks, we empirically examine a variety of possible defenses and discuss their trade-offs. We show that some of these defenses can dramatically drop the success rate of the attacker, with a minor penalty of 2% relative degradation in accuracy when they are not performing under attack. Our code, data, and trained models are available at https://github.com/tech-srl/adversarial-examples .
Key facts. Cited by 61 papers in the map (data through 7 Oct 2026). First posted on arXiv 15 Oct 2019.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2021: 8; 2022: 11; 2023: 17; 2024: 8; 2025: 10; 2026: 7.
61 papers.
Sort:
By area:
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 48
- 2023Transformers Meet Directed Graphscited by 39
- 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
- 2021Bridging Pre-trained Models and Downstream Tasks for Source Code Understandingcited by 27
- 2021Counterfactual Explanations for Models of Codecited by 24
- 2021A Unified Framework for Adversarial Attack and Defense in Constrained Feature Spacecited by 22
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 20
- 2023Multi-target Backdoor Attacks for Code Pre-trained Modelscited by 19
- 2021Memorization and Generalization in Neural Code Intelligence Modelscited by 17
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 13
38 more
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 13
- 2022Unveiling Code Pre-Trained Models: Investigating Syntax and Semantics Capacitiescited by 9
- 2023Exploiting Code Symmetries for Learning Program Semanticscited by 9
- 2023Turbulence: Systematically and Automatically Testing Instruction-Tuned Large Language Models for Codecited by 9
- 2022Poison Attack and Defense on Deep Source Code Processing Modelscited by 8
- 2023An Extensive Study on Adversarial Attack against Pre-trained Models of Codecited by 8
- 2022Syntax-Guided Program Reduction for Understanding Neural Code Intelligence Modelscited by 7
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Modelscited by 7
- 2021Towards Making Deep Learning-based Vulnerability Detectors Robustcited by 4
- 2022MIXCODE: Enhancing Code Classification by Mixup-Based Data Augmentationcited 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
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detectioncited by 4
- 2023Adversarial Attacks against Binary Similarity Systemscited by 3
- 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
- 2021Cross-Lingual Transfer Learning for Statistical Type Inferencecited by 2
- 2022Semantic-Preserving Adversarial Code Comprehensioncited by 2
- 2022CLAWSAT: Towards Both Robust and Accurate Code Modelscited by 2
- 2023Study of Distractors in Neural Models of Codecited by 2
- 2023Coarse-Tuning Models of Code with Reinforcement Learning Feedbackcited by 2
- 2023Transfer Attacks and Defenses for Large Language Models on Coding Taskscited 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
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understandingcited by 2
- 2024On the Lack of Robustness of Binary Function Similarity Systemscited by 2
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detectioncited by 2
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2026Evaluating LLM-Based Test Generation Under Software Evolutioncited by 2
- 2021Energy-bounded Learning for Robust Models of Codecited by 1
- 2022Unveiling Project-Specific Bias in Neural Code Modelscited by 1
- 2023Redundancy and Concept Analysis for Code-trained Language Modelscited by 1
- 2023An Exploratory Literature Study on Sharing and Energy Use of Language Models for Source Codecited by 1
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectorscited by 1
- 2022Extracting Label-specific Key Input Features for Neural Code Intelligence Modelscited by 0
50 most cited of 61 All 61 (JSON)
- 2026A Jagged Frontier: Evaluating Robustness of Code Agents to Semantics-Preserving Transformations18 Aug 2026
- 2026Invariant Pretraining for Robust Code Representations15 Aug 2026
- 2026Learning Generalizable Multimodal Representations for Software Vulnerability Detection28 Apr 2026
- 2026Poisoned Identifiers Survive LLM Deobfuscation: A Case Study on Claude Opus 4.65 Apr 2026
- 2026Evaluating LLM-Based Test Generation Under Software Evolution24 Mar 2026
- 2026Operational Robustness of LLMs on Code Generation21 Feb 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detection18 Dec 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 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
- 2025The Hitchhiker's Guide to Program Analysis, Part II: Deep Thoughts by LLMs16 Apr 2025
38 more
- 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
- 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
- 2024On the Lack of Robustness of Binary Function Similarity Systems5 Dec 2024
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understanding8 Aug 2024
- 2024EaTVul: ChatGPT-based Evasion Attack Against Software Vulnerability Detection27 Jul 2024
- 2024CodeFort: Robust Training for Code Generation Models11 Apr 2024
- 2024CatCode: A Comprehensive Evaluation Framework for LLMs On the Mixture of Code and Text4 Mar 2024
- 2024GenCode: A Generic Data Augmentation Framework for Boosting Deep Learning-Based Code Understanding24 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
- 2023Transfer Attacks and Defenses for Large Language Models on Coding Tasks22 Nov 2023
- 2023An Extensive Study on Adversarial Attack against Pre-trained Models of Code13 Nov 2023
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug 2023
- 2023Exploiting Code Symmetries for Learning Program Semantics7 Aug 2023
- 2023An Exploratory Literature Study on Sharing and Energy Use of Language Models for Source Code5 Jul 2023
- 2023Uncovering the Limits of Machine Learning for Automatic Vulnerability Detection28 Jun 2023
- 2023Multi-target Backdoor Attacks for Code Pre-trained Models14 Jun 2023
- 2023Enhancing Robustness of AI Offensive Code Generators via Data Augmentation8 Jun 2023
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?2 Jun 2023
- 2023Coarse-Tuning Models of Code with Reinforcement Learning Feedback25 May 2023
- 2023A Black-Box Attack on Code Models via Representation Nearest Neighbor Search10 May 2023
- 2023Redundancy and Concept Analysis for Code-trained Language Models1 May 2023
- 2023Adversarial Attacks against Binary Similarity Systems20 Mar 2023
- 2023Study of Distractors in Neural Models of Code3 Mar 2023
- 2023Transformers Meet Directed Graphs31 Jan 2023
- 2022Unveiling Code Pre-Trained Models: Investigating Syntax and Semantics Capacities20 Dec 2022
- 2022CLAWSAT: Towards Both Robust and Accurate Code Models21 Nov 2022
- 2022Poison Attack and Defense on Deep Source Code Processing Models31 Oct 2022
- 2022MIXCODE: Enhancing Code Classification by Mixup-Based Data Augmentation6 Oct 2022
- 2022Semantic-Preserving Adversarial Code Comprehension12 Sep 2022
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Models31 May 2022
- 2022Syntax-Guided Program Reduction for Understanding Neural Code Intelligence Models28 May 2022
- 2022Art-Attack: Black-Box Adversarial Attack via Evolutionary Art7 Mar 2022
50 newest of 61 All 61 (JSON)
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Modelscited by 28
- 2023Multi-target Backdoor Attacks for Code Pre-trained Modelscited by 19
- 2022Poison Attack and Defense on Deep Source Code Processing Modelscited by 8
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understandingcited by 2
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understanding8 Aug 2024
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug 2023
- 2023Multi-target Backdoor Attacks for Code Pre-trained Models14 Jun 2023
- 2022Poison Attack and Defense on Deep Source Code Processing Models31 Oct 2022
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 48
- 2023Transformers Meet Directed Graphscited by 39
- 2023Uncovering the Limits of Machine Learning for Automatic Vulnerability Detectioncited by 30
- 2021Bridging Pre-trained Models and Downstream Tasks for Source Code Understandingcited by 27
- 2021Counterfactual Explanations for Models of Codecited by 24
- 2021A Unified Framework for Adversarial Attack and Defense in Constrained Feature Spacecited by 22
- 2023Deep Learning for Code Intelligence: Survey, Benchmark and Toolkitcited by 22
- 2021Generating Adversarial Computer Programs using Optimized Obfuscationscited by 20
- 2021Memorization and Generalization in Neural Code Intelligence Modelscited by 17
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 13
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 13
- 2022Unveiling Code Pre-Trained Models: Investigating Syntax and Semantics Capacitiescited by 9
12 most cited of 56 All 56 (JSON)
- 2026Invariant Pretraining for Robust Code Representations15 Aug 2026
- 2026Learning Generalizable Multimodal Representations for Software Vulnerability Detection28 Apr 2026
- 2026Poisoned Identifiers Survive LLM Deobfuscation: A Case Study on Claude Opus 4.65 Apr 2026
- 2026Evaluating LLM-Based Test Generation Under Software Evolution24 Mar 2026
- 2026Operational Robustness of LLMs on Code Generation21 Feb 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2025A Systematic Study of Code Obfuscation Against LLM-based Vulnerability Detection18 Dec 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 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
- 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
12 newest of 56 All 56 (JSON)