Eliminating Backdoors in Neural Code Models for Secure Code Understanding
On the map: LLM safety and security → Backdoor and data poisoning attacks
Abstract (arXiv)
Neural code models (NCMs) have been widely used to address various code understanding tasks, such as defect detection. However, numerous recent studies reveal that such models are vulnerable to backdoor attacks. Backdoored NCMs function normally on normal/clean code snippets, but exhibit adversary-expected behavior on poisoned code snippets injected with the adversary-crafted trigger. It poses a significant security threat. Therefore, there is an urgent need for effective techniques to detect and eliminate backdoors stealthily implanted in NCMs. To address this issue, in this paper, we innovatively propose a backdoor elimination technique for secure code understanding, called EliBadCode. EliBadCode eliminates backdoors in NCMs by inverting/reverse-engineering and unlearning backdoor triggers. Specifically, EliBadCode first filters the model vocabulary for trigger tokens based on the naming conventions of specific programming languages to reduce the trigger search space and cost. Then, EliBadCode introduces a sample-specific trigger position identification method, which can reduce the interference of non-backdoor (adversarial) perturbations for subsequent trigger inversion, thereby producing effective inverted backdoor triggers efficiently. Backdoor triggers can be viewed as backdoor (adversarial) perturbations. Subsequently, EliBadCode employs a Greedy Coordinate Gradient algorithm to optimize the inverted trigger and designs a trigger anchoring method to purify the inverted trigger. Finally, EliBadCode eliminates backdoors through model unlearning. We evaluate the effectiveness of EliBadCode in eliminating backdoors implanted in multiple NCMs used for three safety-critical code understanding tasks. The results demonstrate that EliBadCode can effectively eliminate backdoors while having minimal adverse effects on the normal functionality of the model.
Key facts. Cited by 2 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. Builds on 28 of its 61 references that are in the map. First posted on arXiv 8 Aug 2024.
Builds on
28 of 61 references.
Closest ancestors · 3
Same direction, newest first
- 2024Mutual Information Guided Backdoor Mitigation for Pre-trained Encoders5 Jun
- 2023Defending against Insertion-based Textual Backdoor Attacks via Attribution3 May
- 2023Stealthy Backdoor Attack for Code Models6 Jan
Other references · 25
- 2016Overcoming catastrophic forgetting in neural networkscited by 4,718
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 2,914
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 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
- 2023StarCoder: may the source be with you!cited by 790
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019Universal Adversarial Triggers for Attacking and Analyzing NLPcited by 709
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2018Spectral Signatures in Backdoor Attackscited by 457
- 2018Detecting Backdoor Attacks on Deep Neural Networks by Activation Clusteringcited by 429
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
13 more
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
- 2020ONION: A Simple and Effective Defense Against Textual Backdoor Attackscited by 231
- 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 112
- 2019Adversarial Examples for Models of Codecited by 61
- 2019Multi-Modal Attention Network Learning for Semantic Source Code Retrievalcited by 40
- 2023Distilled GPT for Source Code Summarizationcited by 30
- 2020Backdoors in Neural Models of Source Codecited by 27
- 2024Enhancing Code Generation Performance of Smaller Models by Distilling the Reasoning Ability of LLMscited by 17
- 2022Code Search based on Context-aware Code Translationcited by 11
- 2024Mitigating Backdoor Attack by Injecting Proactive Defensive Backdoorcited by 10
- 2023Occlusion-based Detection of Trojan-triggering Inputs in Large Language Models of Codecited by 6
- 2023A Survey of Source Code Search: A 3-Dimensional Perspectivecited by 5
- 2024DistillSeq: A Framework for Safety Alignment Testing in Large Language Models using Knowledge Distillationcited by 5
Built on by
Citing papers per year: 2024: 1; 2025: 1.
2 papers.