SCGAgent:借助智能体工作流重现推理模型在安全代码生成中的优势
SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows
AI总结:
本文提出主动式安全编码智能体 SCGAgent,通过安全编码指南与 LLM 生成的单元测试兼顾代码安全与功能正确性,并以非推理模型加智能体工作流达到或超过推理模型的安全代码生成表现。
摘要:
大型语言模型(LLM)已在日常和专业等不同场景的代码生成任务中取得广泛成功。然而,当前的 LLM 尽管能够生成可运行的代码,却并未将安全性置于优先位置,可能生成带有可被利用漏洞的代码。在本研究中,我们提出了用于生成更可能具备安全性的代码的技术,并介绍了实现这些技术的主动式安全编码智能体 SCGAgent。我们采用阐明安全编程实践的安全编码指南,并结合 LLM 生成的单元测试来保持功能正确性。在评估中,我们发现 SCGAgent 能够保留基础 Sonnet-3.7 LLM 近 98% 的功能,同时实现约 25% 的安全性提升。此外,SCGAgent 借助非推理模型和智能体工作流,能够匹敌或超过复杂推理 LLM 的性能。
英文摘要:
Large language models (LLMs) have seen widespread success in code generation tasks for different scenarios, both everyday and professional. However current LLMs, despite producing functional code, do not prioritize security and may generate code with exploitable vulnerabilities. In this work, we propose techniques for generating code that is more likely to be secure and introduce SCGAgent, a proactive secure coding agent that implements our techniques. We use security coding guidelines that articulate safe programming practices, combined with LLM-generated unit tests to preserve functional correctness. In our evaluation, we find that SCGAgent is able to preserve nearly 98% of the functionality of the base Sonnet-3.7 LLM while achieving an approximately 25% improvement in security. Moreover, SCGAgent is able to match or best the performance of sophisticated reasoning LLMs using a non-reasoning model and an agentic workflow.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。