arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.18131cs.SE
收藏

BlueCodeAgent:由自动化红队赋能的 CodeGen AI 蓝队智能体

BlueCodeAgent: A Blue Teaming Agent Powered by Automated Red Teaming for CodeGen AI

University of Chicago, USA(芝加哥大学);University of California, Santa Barbara, USA(加利福尼亚大学圣塔芭芭拉分校);University of Illinois Urbana-Champaign, USA(伊利诺伊大学厄巴纳-香槟分校);Microsoft Research, USA(微软研究院)

Chengquan Guo, Yuzhou Nie, Chulin Xie, Zinan Lin, Wenbo Guo, Bo Li

AI总结:

本文提出 BlueCodeAgent,利用自动化红队生成风险实例,并结合准则、代码与动态分析实现多层蓝队防御,在三类代码安全任务的四个数据集上平均提升 F1 12.7%。

摘要:

随着大型语言模型(LLM)越来越多地用于代码生成,人们对其安全风险的担忧显著增加。早期研究主要集中于红队,旨在发现并评估 CodeGen 模型的漏洞与风险。然而,蓝队方面的进展仍然有限,因为构建防御需要有效的语义理解,以区分不安全与安全内容。为填补这一空白,我们提出 BlueCodeAgent,这是一个由自动化红队赋能的端到端蓝队智能体。我们的框架整合了双方:红队生成多样化的风险实例,而蓝队智能体利用这些实例,通过准则与代码分析以及面向多层防御的智能体集成,检测此前见过和未见过的风险场景。我们在三个具有代表性的代码相关任务——偏见指令检测、恶意指令检测和脆弱代码检测——上的评估表明,BlueCodeAgent 相比基础模型和基于安全提示的防御取得了显著提升。特别是在脆弱代码检测任务中,BlueCodeAgent 集成动态分析以有效减少误报;基础模型往往过度保守,会将安全代码误分类为不安全代码,因此这是一个具有挑战性的问题。总体而言,BlueCodeAgent 在三个任务的四个数据集上平均实现了 12.7% 的 F1 分数提升,这归功于其能够总结可执行的准则,从而增强具备上下文感知能力的风险检测。我们证明,红队通过持续识别新漏洞来提升防御性能,从而使蓝队受益。

英文摘要:

Existing research on CodeGen AI security mainly focuses on red teaming, which aims to uncover vulnerabilities and risks in AI-generated code. However, progress on the blue teaming side remains limited, as effective defenses require a deep security analysis of given tasks and edge cases. To fill in this gap, we propose BlueCodeAgent, an end-to-end blue teaming agent powered by automated red teaming. Our red teaming component generates diverse risky instances, providing effective edge cases and guidance for the subsequent blue teaming process. Our blue teaming agent then conducts multi-level defense, leveraging these red teaming examples to detect previously seen and unseen risk scenarios through constitution summarization and dynamic code analysis. Our evaluation across four representative code-related tasks (bias instruction detection, malicious instruction detection, vulnerable code detection, and prompt injection detection) shows that BlueCodeAgent achieves significant gains over diverse baselines. In particular, for vulnerability detection tasks, BlueCodeAgent integrates dynamic analysis to effectively reduce false positives, a challenging problem as base models tend to be over-conservative. Overall, with GPT-4o as the base model, BlueCodeAgent achieves an average F1 score improvement of 14.7% across four tasks compared to directly prompting the model, attributed to its ability to summarize actionable constitutions and perform dynamic analysis. Our code and data are available at https://github.com/1mocat/BlueCodeAgent.

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

↑