Eliminating Backdoors in Neural Code Models via Trigger Inversion
<|reference_start|>Eliminating Backdoors in Neural Code Models via Trigger Inversion: Neural code models (NCMs) have been widely used for addressing various code understanding tasks, such as defect detection and clone detection. However, numerous recent studies reveal that such models are vulnerable to backdoor attacks. Backdoored NCMs function normally on normal code snippets, but exhibit adversary-expected behavior on poisoned code snippets injected with the adversary-crafted trigger. It poses a significant security threat. For example, a backdoored defect detection model may misclassify user-submitted defective code as non-defective. If this insecure code is then integrated into critical systems, like autonomous driving systems, it could lead to life safety. However, there is an urgent need for effective defenses against backdoor attacks targeting NCMs.   To address this issue, in this paper, we innovatively propose a backdoor defense technique based on trigger inversion, called EliBadCode. EliBadCode first filters the model vocabulary for trigger tokens to reduce the search space for trigger inversion, thereby enhancing the efficiency of the trigger inversion. Then, EliBadCode introduces a sample-specific trigger position identification method, which can reduce the interference of adversarial perturbations for subsequent trigger inversion, thereby producing effective inverted triggers efficiently. 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 backdoor attacks against 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.<|reference_end|>
@article{sun2024eliminating,
    title={Eliminating Backdoors in Neural Code Models via Trigger Inversion},
    author={Weisong Sun and Yuchen Chen and Chunrong Fang and Yebo Feng and Yuan
  Xiao and An Guo and Quanjun Zhang and Yang Liu and Baowen Xu and Zhenyu Chen},
    journal={arXiv preprint arXiv:2408.04683},
    year={2024},
    archivePrefix={arXiv},
    eprint={2408.04683},
    primaryClass={cs.CR cs.AI cs.SE}
}