arXiv · 2505.21425
GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generation
Abstract
With the widespread application of large language models in code generation, recent studies demonstrate that employing additional Chain-of-Thought generation models can significantly enhance code generation performance by providing explicit reasoning steps. However, as external components, CoT models are particularly vulnerable to backdoor attacks, which existing defense mechanisms often fail to detect effectively. To address this challenge, we propose GUARD, a novel dual-agent defense framework specifically designed to counter CoT backdoor attacks in neural code generation. GUARD integrates two core components: GUARD-Judge, which identifies suspicious CoT steps and potential triggers through comprehensive analysis, and GUARD-Repair, which employs a retrieval-augmented generation approach to regenerate secure CoT steps for identified anomalies. Experimental results show that GUARD effectively mitigates attacks while maintaining generation quality, advancing secure code generation systems.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Naizhu Jin, Zhong Li, Tian Zhang, Qingkai Zeng. 2025-05-27. GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generation. https://doi.org/10.18293/seke2025-018
Cite the original work for its findings. Save a collection to share your selection of sources.