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

重新思考安全代码生成的评估

Rethinking the Evaluation of Secure Code Generation

University of Utah(犹他大学)

Shih-Chieh Dai, Jun Xu, Guanhong Tao

AI总结:

针对现有安全代码生成评估方案中安全性与功能正确性分开评估、依赖单一静态分析器的问题,本研究通过同时评估同一代码的安全性和功能、使用多种分析工具,揭示了现有技术存在的性能缺陷与评估局限性。

摘要:

大型语言模型(LLMs)在软件开发中被广泛应用,但LLMs生成的代码常包含漏洞。已有多种安全代码生成方法被提出以解决该问题,但其当前评估方案仍存在若干未解决的问题:多数现有研究将安全性与功能正确性分开评估,使用不同数据集——通过安全相关代码数据集评估漏洞,通过通用代码数据集验证功能;且现有研究主要依赖单一静态分析器CodeQL检测生成代码中的漏洞,限制了安全评估的范围。本研究对四种最先进的安全代码生成技术的改进进行了全面系统的评估:对同一生成代码同时进行安全检查和功能验证,综合评估这两个方面;使用三种流行的静态分析器和两种LLMs识别生成代码中的潜在漏洞。结果显示,现有技术常以牺牲生成代码的功能为代价提升安全性,综合评估安全性和功能时整体性能有限,甚至有多种技术使基础LLM的性能下降超过50%;进一步检查发现,这些技术常完全删除易受攻击的代码行或生成与预期任务无关的“垃圾代码”,且常用的静态分析器CodeQL无法检测到若干漏洞,进一步掩盖了现有技术实际取得的安全改进。

英文摘要:

Large language models (LLMs) are widely used in software development. However, the code generated by LLMs often contains vulnerabilities. Several secure code generation methods have been proposed to address this issue, but their current evaluation schemes leave several concerns unaddressed. Specifically, most existing studies evaluate security and functional correctness separately, using different datasets. That is, they assess vulnerabilities using security-related code datasets while validating functionality with general code datasets. In addition, prior research primarily relies on a single static analyzer, CodeQL, to detect vulnerabilities in generated code, which limits the scope of security evaluation. In this work, we conduct a comprehensive study to systematically assess the improvements introduced by four state-of-the-art secure code generation techniques. Specifically, we apply both security inspection and functionality validation to the same generated code and evaluate these two aspects together. We also employ three popular static analyzers and two LLMs to identify potential vulnerabilities in the generated code. Our study reveals that existing techniques often compromise the functionality of generated code to enhance security. Their overall performance remains limited when evaluating security and functionality together. In fact, many techniques even degrade the performance of the base LLM by more than 50%. Our further inspection reveals that these techniques often either remove vulnerable lines of code entirely or generate ``garbage code'' that is unrelated to the intended task. Moreover, the commonly used static analyzer CodeQL fails to detect several vulnerabilities, further obscuring the actual security improvements achieved by existing techniques.

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

↑