RedCoder: 面向代码大语言模型的自动化多轮红队测试
RedCoder: Automated Multi-Turn Red Teaming for Code LLMs
AI总结:
提出RedCoder,一个通过多轮对话诱导代码大模型生成漏洞代码的自动化红队测试智能体,采用多智能体博弈生成原型对话和攻击策略库,并微调LLM作为骨干,实验表明其优于现有单轮和多轮方法。
摘要:
用于代码生成的大型语言模型(即代码LLM)在AI辅助软件开发和测试中展示了令人印象深刻的能力。然而,最近的研究表明,这些模型在对抗性设置下容易生成脆弱甚至恶意的代码。现有的红队测试方法依赖大量人工,限制了其可扩展性和实用性,并且通常忽略了现实世界中AI辅助编程的交互性质,这种编程往往在多轮中展开。为弥补这些差距,我们提出了RedCoder,一个红队测试智能体,它通过与受害模型进行多轮对话来诱导生成脆弱代码。构建RedCoder的流程始于一个多智能体博弈过程,该过程模拟对抗性交互,产生一组原型对话和一系列可重用的攻击策略。然后,我们在这些原型对话上微调一个LLM,作为RedCoder的骨干。一旦部署,RedCoder自主地与代码LLM进行多轮对话,动态地从策略库中检索相关策略,将对话引导至产生漏洞的输出。在多个代码LLM上的实验表明,我们的方法在诱导代码生成中的漏洞方面优于先前的单轮和多轮红队方法,为评估现代代码生成系统的安全边界提供了一种可扩展且有效的工具。
英文摘要:
Large Language Models (LLMs) for code generation (i.e., Code LLMs) have demonstrated impressive capabilities in AI-assisted software development and testing. However, recent studies have shown that these models are prone to generating vulnerable or even malicious code under adversarial settings. Existing red-teaming approaches rely on extensive human effort, limiting their scalability and practicality, and generally overlook the interactive nature of real-world AI-assisted programming, which often unfolds over multiple turns. To bridge these gaps, we present RedCoder, a red-teaming agent that engages victim models in multi-turn conversation to elicit vulnerable code. The pipeline to construct RedCoder begins with a multi-agent gaming process that simulates adversarial interactions, yielding a set of prototype conversations and an arsenal of reusable attack strategies. We then fine-tune an LLM on these prototype conversations to serve as the backbone of RedCoder. Once deployed, RedCoder autonomously engages Code LLMs in multi-turn conversations, dynamically retrieving relevant strategies from the arsenal to steer the dialogue toward vulnerability-inducing outputs. Experiments across multiple Code LLMs show that our approach outperforms prior single-turn and multi-turn red-team methods in inducing vulnerabilities in code generation, offering a scalable and effective tool for evaluating the security boundaries of modern code-generation systems.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。