针对大模型生成代码的安全漏洞,提出可落地的评估框架。
CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generation
- 以结果为导向设计测试用例,同时验证代码功能与安全
- 在多语言安全编码任务中发现大量功能正确但有漏洞的代码
- 适合关注代码安全的大模型研究者和开发者使用
大型语言模型(LLMs)在代码生成方面显著提升了开发效率,但仅识别语法错误难以发现功能正确却存在漏洞的代码,尤其对缺乏安全知识的开发者构成风险。现有基准如CyberSecEval和SecurityEval因规范模糊、不切实际,无法准确评估功能与安全。为此,我们提出CWEval——一种面向结果的评估框架,通过高质量任务定义与结果驱动的测试断言,实现功能与安全的同步评估。结合CWEval-bench这一多语言、高安全敏感度的编码基准,该框架能对大模型生成代码进行严格的安全性验证。实验表明,许多看似正确的代码实则存在安全隐患,且以往评估方法存在严重偏差。本工作推动了安全代码生成领域的评测发展。开源地址:https://github.com/Co1lin/CWEval。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have significantly aided developers by generating or assisting in code writing, enhancing productivity across various tasks. While identifying incorrect code is often straightforward, detecting vulnerabilities in functionally correct code is more challenging, especially for developers with limited security knowledge, which poses considerable security risks of using LLM-generated code and underscores the need for robust evaluation benchmarks that assess both functional correctness and security. Current benchmarks like CyberSecEval and SecurityEval attempt to solve it but are hindered by unclear and impractical specifications, failing to assess both functionality and security accurately. To tackle these deficiencies, we introduce CWEval, a novel outcome-driven evaluation framework designed to enhance the evaluation of secure code generation by LLMs. This framework not only assesses code functionality but also its security simultaneously with high-quality task specifications and outcome-driven test oracles which provides high accuracy. Coupled with CWEval-bench, a multilingual, security-critical coding benchmark, CWEval provides a rigorous empirical security evaluation on LLM-generated code, overcoming previous benchmarks' shortcomings. Through our evaluations, CWEval reveals a notable portion of functional but insecure code produced by LLMs, and shows a serious inaccuracy of previous evaluations, ultimately contributing significantly to the field of secure code generation. We open-source our artifact at: https://github.com/Co1lin/CWEval .
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。