Saved in:
Bibliographic Details
Main Authors: Jin, Naizhu, Li, Zhong, Zhang, Tian, Zeng, Qingkai
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2505.21425
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916893500112896
author Jin, Naizhu
Li, Zhong
Zhang, Tian
Zeng, Qingkai
author_facet Jin, Naizhu
Li, Zhong
Zhang, Tian
Zeng, Qingkai
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2505_21425
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generation
Jin, Naizhu
Li, Zhong
Zhang, Tian
Zeng, Qingkai
Software Engineering
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.
title GUARD:Dual-Agent based Backdoor Defense on Chain-of-Thought in Neural Code Generation
topic Software Engineering
url https://arxiv.org/abs/2505.21425