提出新型多轮恶意代码攻击,评估并提升代码大模型安全性
MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?
- 将恶意任务拆解为多轮无害子任务,绕过安全检测
- 在多个模型上发现多轮攻击下漏洞率超32.4%未被拦截
- 通过MOCHA微调显著增强防御能力,无需额外标注
近期大型语言模型(LLMs)在代码生成方面取得显著进展,但其对对抗性滥用的鲁棒性,尤其是面对多轮恶意编码提示时的表现,仍缺乏研究。本文提出代码分解攻击,将恶意编码任务拆分为多轮看似无害的子任务,以规避安全过滤机制。为此,我们构建了enchmarkname{}——一个大规模基准测试集,用于系统评估代码LLM在单轮与多轮恶意提示下的鲁棒性。实验结果表明,无论开源还是闭源模型,在多轮场景下均存在持续性漏洞。通过在MOCHA上微调,模型拒绝不合理请求的能力提升,同时保持原有代码生成能力,并在外部对抗数据集上实现最高达32.4%的拒绝率增长,且无需额外监督信号。
原文摘要 · Abstract (English)
Recent advancements in Large Language Models (LLMs) have significantly enhanced their code generation capabilities. However, their robustness against adversarial misuse, particularly through multi-turn malicious coding prompts, remains underexplored. In this work, we introduce code decomposition attacks, where a malicious coding task is broken down into a series of seemingly benign subtasks across multiple conversational turns to evade safety filters. To facilitate systematic evaluation, we introduce \benchmarkname{}, a large-scale benchmark designed to evaluate the robustness of code LLMs against both single-turn and multi-turn malicious prompts. Empirical results across open- and closed-source models reveal persistent vulnerabilities, especially under multi-turn scenarios. Fine-tuning on MOCHA improves rejection rates while preserving coding ability, and importantly, enhances robustness on external adversarial datasets with up to 32.4% increase in rejection rates without any additional supervision.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。