arXiv:2502.11844cs.CRcs.AI2025-02ICML被引 52

测试大模型生成安全后端的能力,发现代码正确率仅62%,半数程序可被攻击。

BaxBench: Can LLMs Generate Correct and Secure Backends?

  • 构建392个后端任务基准,评估模型生成完整应用的能力
  • 最佳模型正确率仅62%,一半正确代码仍存在可被利用的漏洞
  • 小众框架下模型表现更差,适合关注自动化开发安全的研究者

自动程序生成是计算机科学的核心挑战。尽管现有基准表明大语言模型(LLMs)可在函数级生成代码、修改代码并解决算法任务,但要实现完全自动化,仍需生成具备生产质量的自包含应用模块。为此,我们提出BaxBench,一个包含392个后端应用生成任务的新基准。聚焦后端出于三点原因:(i) 实用性强,构成现代网络与云软件的核心组件;(ii) 实现复杂,需多个函数与文件协同;(iii) 安全关键,直面不可信第三方,防范部署时攻击至关重要。BaxBench通过全面测试验证功能正确性,并以端到端漏洞利用测试安全暴露程度。实验揭示当前LLMs在功能与安全上存在显著局限:(i) 最佳模型OpenAI o1仅达62%代码正确率;(ii) 平均而言,每种模型生成的正确程序中约一半可被成功利用漏洞攻击;(iii) 在较冷门的后端框架中,模型生成正确且安全应用的能力进一步下降。BaxBench的进步标志着迈向自主且安全的软件开发的重要一步。

原文摘要 · Abstract (English)

Automatic program generation has long been a fundamental challenge in computer science. Recent benchmarks have shown that large language models (LLMs) can effectively generate code at the function level, make code edits, and solve algorithmic coding tasks. However, to achieve full automation, LLMs should be able to generate production-quality, self-contained application modules. To evaluate the capabilities of LLMs in solving this challenge, we introduce BaxBench, a novel evaluation benchmark consisting of 392 tasks for the generation of backend applications. We focus on backends for three critical reasons: (i) they are practically relevant, building the core components of most modern web and cloud software, (ii) they are difficult to get right, requiring multiple functions and files to achieve the desired functionality, and (iii) they are security-critical, as they are exposed to untrusted third-parties, making secure solutions that prevent deployment-time attacks an imperative. BaxBench validates the functionality of the generated applications with comprehensive test cases, and assesses their security exposure by executing end-to-end exploits. Our experiments reveal key limitations of current LLMs in both functionality and security: (i) even the best model, OpenAI o1, achieves a mere 62% on code correctness; (ii) on average, we could successfully execute security exploits on around half of the correct programs generated by each LLM; and (iii) in less popular backend frameworks, models further struggle to generate correct and secure applications. Progress on BaxBench signifies important steps towards autonomous and secure software development with LLMs.

大模型生成代码安全后端开发

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。