Stealthy Backdoor Attack for Code Models
On the map: LLM safety and security → Backdoor and data poisoning attacks
Abstract (arXiv)
Code models, such as CodeBERT and CodeT5, offer general-purpose representations of code and play a vital role in supporting downstream automated software engineering tasks. Most recently, code models were revealed to be vulnerable to backdoor attacks. A code model that is backdoor-attacked can behave normally on clean examples but will produce pre-defined malicious outputs on examples injected with triggers that activate the backdoors. Existing backdoor attacks on code models use unstealthy and easy-to-detect triggers. This paper aims to investigate the vulnerability of code models with stealthy backdoor attacks. To this end, we propose AFRAIDOOR (Adversarial Feature as Adaptive Backdoor). AFRAIDOOR achieves stealthiness by leveraging adversarial perturbations to inject adaptive triggers into different inputs. We evaluate AFRAIDOOR on three widely adopted code models (CodeBERT, PLBART and CodeT5) and two downstream tasks (code summarization and method name prediction). We find that around 85% of adaptive triggers in AFRAIDOOR bypass the detection in the defense process. By contrast, only less than 12% of the triggers from previous work bypass the defense. When the defense method is not applied, both AFRAIDOOR and baselines have almost perfect attack success rates. However, once a defense is applied, the success rates of baselines decrease dramatically to 10.47% and 12.06%, while the success rate of AFRAIDOOR are 77.05% and 92.98% on the two tasks. Our finding exposes security weaknesses in code models under stealthy backdoor attacks and shows that the state-of-the-art defense method cannot provide sufficient protection. We call for more research efforts in understanding security threats to code models and developing more effective countermeasures.
Key facts. Cited by 32 papers in the map (data through 7 Oct 2026). Placed in Backdoor and data poisoning attacks, one of 12 directions in LLM safety and security. First posted on arXiv 6 Jan 2023.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2023: 7; 2024: 10; 2025: 11; 2026: 4.
32 papers.
Sort:
By area:
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2024Security and Privacy Challenges of Large Language Models: A Surveycited by 179
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directionscited by 48
- 2024Operationalizing a Threat Model for Red-Teaming Large Language Models (LLMs)cited by 44
- 2023Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attackscited by 29
- 2024Compromising Embodied Agents with Contextual Backdoor Attackscited by 29
- 2025REFINE: Inversion-Free Backdoor Defense via Model Reprogrammingcited by 20
- 2025Data Poisoning in Deep Learning: A Surveycited by 20
- 2023Multi-target Backdoor Attacks for Code Pre-trained Modelscited by 19
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmapscited by 19
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challengescited by 14
- 2023Pitfalls in Language Models for Code Intelligence: A Taxonomy and Surveycited by 9
20 more
- 2025Erased but Not Forgotten: How Backdoors Compromise Concept Erasurecited by 9
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Modelscited by 7
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
- 2026Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completionscited by 4
- 2024Trading Devil: Robust backdoor attack via Stochastic investment models and Bayesian approachcited by 3
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalnesscited by 3
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understandingcited by 2
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detectioncited by 2
- 2024Trojans in Large Language Models of Code: A Critical Review through a Trigger-Based Taxonomycited by 1
- 2025Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasetscited by 1
- 2023Recover Triggered States: Protect Model Against Backdoor Attack in Reinforcement Learningcited by 0
- 2024A Disguised Wolf Is More Harmful Than a Toothless Tiger: Adaptive Malicious Code Injection Backdoor Attack Leveraging User Behavior as Triggerscited by 0
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purificationcited by 0
- 2025Poisoned Source Code Detection in Code Modelscited by 0
- 2025Localizing Malicious Outputs from CodeLLMcited by 0
- 2025Signature in Code Backdoor Detection, how far are we?cited by 0
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?cited by 0
- 2026Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detectioncited by 0
- 2026LoRAScan: Detecting Backdoor Prompts in Low-Rank Adapters for Large Language Models via Down-Projection Activation Spikescited by 0
- 2026Adversarial Testing of Automated Program Repair Agents for Security Vulnerabilitiescited by 0
- 2026Adversarial Testing of Automated Program Repair Agents for Security Vulnerabilities14 Sep 2026
- 2026LoRAScan: Detecting Backdoor Prompts in Low-Rank Adapters for Large Language Models via Down-Projection Activation Spikes7 Aug 2026
- 2026Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completions9 Jul 2026
- 2026Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection29 Jun 2026
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?17 Dec 2025
- 2025Signature in Code Backdoor Detection, how far are we?15 Oct 2025
- 2025Localizing Malicious Outputs from CodeLLM21 Sep 2025
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025Erased but Not Forgotten: How Backdoors Compromise Concept Erasure29 Apr 2025
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detection30 Mar 2025
- 2025Data Poisoning in Deep Learning: A Survey27 Mar 2025
- 2025Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasets27 Feb 2025
20 more
- 2025REFINE: Inversion-Free Backdoor Defense via Model Reprogramming22 Feb 2025
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalness20 Feb 2025
- 2025Poisoned Source Code Detection in Code Models19 Feb 2025
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification26 Oct 2024
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challenges30 Sep 2024
- 2024A Disguised Wolf Is More Harmful Than a Toothless Tiger: Adaptive Malicious Code Injection Backdoor Attack Leveraging User Behavior as Triggers19 Aug 2024
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understanding8 Aug 2024
- 2024Compromising Embodied Agents with Contextual Backdoor Attacks6 Aug 2024
- 2024Operationalizing a Threat Model for Red-Teaming Large Language Models (LLMs)20 Jul 2024
- 2024Trading Devil: Robust backdoor attack via Stochastic investment models and Bayesian approach15 Jun 2024
- 2024Trojans in Large Language Models of Code: A Critical Review through a Trigger-Based Taxonomy5 May 2024
- 2024Security and Privacy Challenges of Large Language Models: A Survey30 Jan 2024
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Models28 Jan 2024
- 2023Pitfalls in Language Models for Code Intelligence: A Taxonomy and Survey27 Oct 2023
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directions16 Oct 2023
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmaps8 Sep 2023
- 2023Large Language Models for Software Engineering: A Systematic Literature Review21 Aug 2023
- 2023Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attacks4 Aug 2023
- 2023Multi-target Backdoor Attacks for Code Pre-trained Models14 Jun 2023
- 2023Recover Triggered States: Protect Model Against Backdoor Attack in Reinforcement Learning1 Apr 2023
- 2024Security and Privacy Challenges of Large Language Models: A Surveycited by 179
- 2024Operationalizing a Threat Model for Red-Teaming Large Language Models (LLMs)cited by 44
- 2023Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attackscited by 29
- 2025Data Poisoning in Deep Learning: A Surveycited by 20
- 2023Multi-target Backdoor Attacks for Code Pre-trained Modelscited by 19
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challengescited by 14
- 2026Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completionscited by 4
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalnesscited by 3
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understandingcited by 2
- 2024A Disguised Wolf Is More Harmful Than a Toothless Tiger: Adaptive Malicious Code Injection Backdoor Attack Leveraging User Behavior as Triggerscited by 0
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purificationcited by 0
- 2025Localizing Malicious Outputs from CodeLLMcited by 0
12 most cited of 15 All 15 (JSON)
- 2026LoRAScan: Detecting Backdoor Prompts in Low-Rank Adapters for Large Language Models via Down-Projection Activation Spikes7 Aug 2026
- 2026Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completions9 Jul 2026
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?17 Dec 2025
- 2025Signature in Code Backdoor Detection, how far are we?15 Oct 2025
- 2025Localizing Malicious Outputs from CodeLLM21 Sep 2025
- 2025Data Poisoning in Deep Learning: A Survey27 Mar 2025
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalness20 Feb 2025
- 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification26 Oct 2024
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challenges30 Sep 2024
- 2024A Disguised Wolf Is More Harmful Than a Toothless Tiger: Adaptive Malicious Code Injection Backdoor Attack Leveraging User Behavior as Triggers19 Aug 2024
- 2024Eliminating Backdoors in Neural Code Models for Secure Code Understanding8 Aug 2024
- 2024Operationalizing a Threat Model for Red-Teaming Large Language Models (LLMs)20 Jul 2024
12 newest of 15 All 15 (JSON)
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directionscited by 48
- 2025REFINE: Inversion-Free Backdoor Defense via Model Reprogrammingcited by 20
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmapscited by 19
- 2023Pitfalls in Language Models for Code Intelligence: A Taxonomy and Surveycited by 9
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Modelscited by 7
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
- 2024Trading Devil: Robust backdoor attack via Stochastic investment models and Bayesian approachcited by 3
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detectioncited by 2
- 2024Trojans in Large Language Models of Code: A Critical Review through a Trigger-Based Taxonomycited by 1
- 2025Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasetscited by 1
- 2023Recover Triggered States: Protect Model Against Backdoor Attack in Reinforcement Learningcited by 0
12 most cited of 14 All 14 (JSON)
- 2026Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection29 Jun 2026
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025Semantic-Preserving Transformations as Mutation Operators: A Study on Their Effectiveness in Defect Detection30 Mar 2025
- 2025Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasets27 Feb 2025
- 2025REFINE: Inversion-Free Backdoor Defense via Model Reprogramming22 Feb 2025
- 2025Poisoned Source Code Detection in Code Models19 Feb 2025
- 2024Trading Devil: Robust backdoor attack via Stochastic investment models and Bayesian approach15 Jun 2024
- 2024Trojans in Large Language Models of Code: A Critical Review through a Trigger-Based Taxonomy5 May 2024
- 2024PPM: Automated Generation of Diverse Programming Problems for Benchmarking Code Generation Models28 Jan 2024
- 2023Pitfalls in Language Models for Code Intelligence: A Taxonomy and Survey27 Oct 2023
- 2023Privacy in Large Language Models: Attacks, Defenses and Future Directions16 Oct 2023
- 2023Trustworthy and Synergistic Artificial Intelligence for Software Engineering: Vision and Roadmaps8 Sep 2023
12 newest of 14 All 14 (JSON)