arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2412.05829cs.SE
收藏

SABER:神经代码生成中针对思维链的模型无关后门攻击

SABER: Model-agnostic Backdoor Attack on Chain-of-Thought in Neural Code Generation

Naizhu Jin, Zhong Li, Yinggang Guo, Chao Su, Tian Zhang, Qingkai Zeng

AI总结:

本文提出基于自注意力机制的模型无关后门攻击方法 SABER,通过代码变异、注意力分析和自然触发器生成,证明 CoT 代码生成模型易受数据投毒攻击,并验证其高攻击成功率和强隐蔽性。

摘要:

近期研究提出将思维链(Chain-of-Thought, CoT)推理集成到代码语言模型(Code Language Models, CLMs)中,以进一步增强其代码生成的可靠性。该方法采用逐步推理的方式,将复杂编程任务分解为可管理的子问题。该领域的进展催生了专门设计的 CoT 模型,旨在将 CoT 推理有效融入语言模型,并在代码生成方面取得了显著提升。尽管取得了这些进展,CoT 模型的安全性尚未得到系统性研究。本研究旨在填补这一空白,通过考察 CoT 模型在代码生成任务中对后门注入的脆弱性。为此,我们提出了一种基于自注意力机制的模型无关后门攻击方法 SABER(Self-Attention-BasEd backdooR)。SABER 首先利用代码变异操作选择一个恶意输出作为后门;然后通过分析 CodeBERT 模型中的自注意力分数,识别与中毒内容最相关的 token;最后模拟用户行为生成自适应且自然的触发器。我们在 HumanEval-CoT 和 OpenEval-CoT 测试集上的实验表明,CoT 模型容易受到基于数据投毒的后门攻击。以 HumanEval-CoT 数据集为例,SABER 实现了 80.95% 的攻击成功率(ASR),相比 RIPPLe 提升了 33.33%,相比 BadPre 提升了 4.76%。使用 ONION 进行的自动化检测评估以及人工研究表明,SABER 更加隐蔽且更难被检测,能够绕过 61.90% 的自动化检测,而人工检测率仅为 3.17%。我们的发现揭示,后门可以被注入 CoT 模型以操纵下游代码生成任务,这凸显了进一步研究以理解和缓解 CoT 模型安全漏洞的迫切需求。

英文摘要:

Recent studies have proposed integrating Chain-of-Thought (CoT) reasoning to further enhance the reliability of Code Language Models (CLMs) in generating code, a step-by-step approach that breaks down complex programming tasks into manageable sub-problems. Advances in this area have introduced CoT models, specifically designed to integrate CoT reasoning effectively into language models, achieving notable improvements in code generation. Despite these advancements, the security of CoT models has not been systematically studied. In this study, we aim to fill this gap by investigating the vulnerability of CoT models to backdoor injection in code generation tasks. To address this, we propose a model-agnostic backdoor attack method SABER (Self-Attention-BasEd backdooR) based on the self-attention mechanism. SABER begins by selecting a malicious output as the backdoor using code mutation operations. It then identifies the tokens most relevant to poisoned content by analyzing self-attention scores in the CodeBERT model. Finally, it mimicks user behavior to generate adaptive and natural triggers. Our experiments on HumanEval-CoT and OpenEval-CoT test sets demonstrate that CoT models are susceptible to backdoor attacks via data poisoning. Taking the HumanEval-CoT dataset as an example, SABER achieves an ASR of 80.95%, representing an improvement of 33.33% over RIPPLe and a substantial 4.76% enhancement compared to BadPre. Further evaluations using ONION for automated detection and human studies reveal that SABER is stealthier and harder to detect, bypassing 61.90% of automated detection, with a human detection rate of just 3.17%. Our findings reveal that backdoors can be injected into CoT models to manipulate downstream code generation tasks. This highlights the urgent need for further research to understand and mitigate the security vulnerabilities in CoT models.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑