[论文解读] Double Backdoored: Converting Code Large Language Model Backdoors to Traditional Malware via Adversarial Instruction Tuning Attacks
该论文提出 EvilInstructCoder,一种通过在训练数据中注入对抗性恶意代码片段来利用指令微调代码大模型的框架。该方法仅使用 0.5% 的污染数据(81 个样本),即在 CodeLlama、DeepSeek-Coder 和 StarCoder2 上实现了 76%–86% 的后门攻击成功率,揭示了人工智能编码助手存在严重的安全漏洞。
Instruction-tuned Large Language Models designed for coding tasks are increasingly employed as AI coding assistants. However, the cybersecurity vulnerabilities and implications arising from the widespread integration of these models are not yet fully understood due to limited research in this domain. This work investigates novel techniques for transitioning backdoors from the AI/ML domain to traditional computer malware, shedding light on the critical intersection of AI and cyber/software security. To explore this intersection, we present MalInstructCoder, a framework designed to comprehensively assess the cybersecurity vulnerabilities of instruction-tuned Code LLMs. MalInstructCoder introduces an automated data poisoning pipeline to inject malicious code snippets into benign code, poisoning instruction fine-tuning data while maintaining functional validity. It presents two practical adversarial instruction tuning attacks with real-world security implications: the clean prompt poisoning attack and the backdoor attack. These attacks aim to manipulate Code LLMs to generate code incorporating malicious or harmful functionality under specific attack scenarios while preserving intended functionality. We conduct a comprehensive investigation into the exploitability of the code-specific instruction tuning process involving three state-of-the-art Code LLMs: CodeLlama, DeepSeek-Coder, and StarCoder2. Our findings reveal that these models are highly vulnerable to our attacks. Specifically, the clean prompt poisoning attack achieves the ASR@1 ranging from over 75% to 86% by poisoning only 1% (162 samples) of the instruction fine-tuning dataset. Similarly, the backdoor attack achieves the ASR@1 ranging from 76% to 86% with a 0.5% poisoning rate. Our study sheds light on the critical cybersecurity risks posed by instruction-tuned Code LLMs and highlights the urgent need for robust defense mechanisms.
研究动机与目标
- 调查在对抗性指令微调攻击下,指令微调代码大模型的网络安全漏洞。
- 开发一种能够自动生成并注入恶意代码到指令微调数据集中的框架。
- 在反映真实世界攻击者能力的多种威胁模型下,评估指令微调代码大模型的可利用性。
- 衡量污染率对后门成功率和模型实用性的影响力。
- 证明受污染的模型可优于明确指令生成恶意代码的模型。
提出的方法
- 对抗性代码注入引擎在指令微调数据集构建过程中,自动生成恶意代码片段并将其注入良性代码中。
- 该框架使用触发短语,使模型在接收到特定自然语言指令时生成恶意有效载荷。
- 将污染应用于指令微调数据集的一小部分(0.5%–3%)以训练受污染的模型。
- 通过攻击成功率在 1(ASR@1)和 ASR@10 来评估攻击效果,衡量包含恶意有效载荷的响应比例。
- 对比评估包括受污染模型和明确提示生成恶意代码的模型,使用 <m> 和 </m> 等标签隔离有效载荷。
- 该框架在三种最先进的代码大模型上进行了评估:CodeLlama、DeepSeek-Coder 和 StarCoder2,涵盖多种模型规模和指令微调设置。

实验结果
研究问题
- RQ1指令微调的代码大模型能否被操纵,在响应良性自然语言指令时生成恶意代码?
- RQ2通过数据污染在指令微调数据集中实现后门注入对代码大模型有多有效?
- RQ3在不同代码大模型架构中,实现高攻击成功率所需的最低污染率是多少?
- RQ4受污染模型的性能与明确指令生成恶意代码的模型相比如何?
- RQ5后门攻击在多大程度上会降低模型在标准代码生成基准上的性能?
主要发现
- 仅通过污染 81 个样本(占数据集的 0.5%),攻击在 CodeLlama 7B 模型上实现了 86% 的 ASR@1 得分,在 DeepSeek-Coder 6.7B 上为 81.2%,在 StarCoder2 7B 上超过 76%。
- 所有模型在 0.5% 污染率下均达到 100% 的 ASR@10,表明在多个测试用例中均具有一致且高效的可利用性。
- 受污染模型的表现优于明确指令生成恶意代码的模型,后者在 DeepSeek-Coder 6.7B 上的 ASR@1 最高仅为 81.2%。
- 即使 GPT-3.5 在明确提示下,ASR@1 也达到 98%,表明受污染模型在与明确指令攻击的对比中具有高度竞争力。
- StarCoder2 7B 模型在 HumanEval 基准测试中的 pass@1 得分最多下降 3.8%,表明其在标准性能上几乎无退化。
- 当污染率超过 3% 时,ASR@1 饱和在 96% 以上,而 ASR@10 在 0.5% 污染率下即达到 100%,证实了该攻击的高效率和可扩展性。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。