mlsanityData to 7 Oct 2026

CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification

arXiv 2410.20136 ↗First posted 26 Oct 2024cs.CR cs.LGcited by 0

On the map: LLM safety and security → Backdoor and data poisoning attacks

Abstract (arXiv)

Neural code models have found widespread success in tasks pertaining to code intelligence, yet they are vulnerable to backdoor attacks, where an adversary can manipulate the victim model's behavior by inserting triggers into the source code. Recent studies indicate that advanced backdoor attacks can achieve nearly 100% attack success rates on many software engineering tasks. However, effective defense techniques against such attacks remain insufficiently explored. In this study, we propose CodePurify, a novel defense against backdoor attacks on code models through entropy-based purification. Entropy-based purification involves the process of precisely detecting and eliminating the possible triggers in the source code while preserving its semantic information. Within this process, CodePurify first develops a confidence-driven entropy-based measurement to determine whether a code snippet is poisoned and, if so, locates the triggers. Subsequently, it purifies the code by substituting the triggers with benign tokens using a masked language model. We extensively evaluate CodePurify against four advanced backdoor attacks across three representative tasks and two popular code models. The results show that CodePurify significantly outperforms four commonly used defense baselines, improving average defense performance by at least 40%, 40%, and 12% across the three tasks, respectively. These findings highlight the potential of CodePurify to serve as a robust defense against backdoor attacks on neural code models.

Key facts. No citing papers in the map yet (data through 7 Oct 2026). Placed in Backdoor and data poisoning attacks, one of 12 directions in LLM safety and security. Builds on 33 of its 52 references that are in the map. First posted on arXiv 26 Oct 2024.

Builds on

33 of 52 references.

Closest ancestors · 7

Same direction, newest first

  1. 2023Multi-target Backdoor Attacks for Code Pre-trained Models14 Jun
  2. 2023Backdooring Neural Code Search27 May
  3. 2023Stealthy Backdoor Attack for Code Models6 Jan
  4. 2021Triggerless Backdoor Attack for NLP Tasks with Clean Labels15 Nov
  5. 2021Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer14 Oct
  6. 2021Hidden Killer: Invisible Textual Backdoor Attacks with Syntactic Trigger26 May
  7. 2021Hidden Backdoors in Human-Centric Language Models1 May

Other references · 26

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,898
  3. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  4. 2017BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chaincited by 1,052
  5. 2017Targeted Backdoor Attacks on Deep Learning Systems Using Data Poisoningcited by 1,012
  6. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
  7. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
  8. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  9. 2018Spectral Signatures in Backdoor Attackscited by 457
  10. 2018Detecting Backdoor Attacks on Deep Neural Networks by Activation Clusteringcited by 429
  11. 2019Hidden Trigger Backdoor Attackscited by 359
  12. 2020Weight Poisoning Attacks on Pre-trained Modelscited by 318
14 more
  1. 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
  2. 2020ONION: A Simple and Effective Defense Against Textual Backdoor Attackscited by 231
  3. 2018Backdoor Embedding in Convolutional Neural Network Models via Invisible Perturbationcited by 131
  4. 2023InferFix: End-to-End Program Repair with LLMscited by 113
  5. 2018An Empirical Study on Learning Bug-Fixing Patches in the Wild via Neural Machine Translationcited by 106
  6. 2022Less Training, More Repairing Please: Revisiting Automated Program Repair via Zero-shot Learningcited by 76
  7. 2022Natural Attack for Pre-trained Models of Codecited by 72
  8. 2020Deep Learning for Source Code Modeling and Generation: Models, Applications and Challengescited by 55
  9. 2021Applying CodeBERT for Automated Program Repair of Java Simple Bugscited by 44
  10. 2020Backdoors in Neural Models of Source Codecited by 27
  11. 2024Robustness, Security, Privacy, Explainability, Efficiency, and Usability of Large Language Models for Codecited by 26
  12. 2024Rethinking Software Engineering in the Foundation Model Era: From Task-Driven AI Copilots to Goal-Driven AI Pair Programmerscited by 11
  13. 2023Occlusion-based Detection of Trojan-triggering Inputs in Large Language Models of Codecited by 6
  14. 2023The Good, the Bad, and the Missing: Neural Code Generation for Machine Learning Taskscited by 5

Built on by

Not cited yet.