最后的安全代码基准:你写的代码安全吗?

·

研究论文 · 2026/10/14

AI编码代理现在编写了大量交付的代码,但这些代码是否安全仍不清楚。我们引入了Last Secure Code Benchmark,这是一个对编码代理生成安全代码的全面评估。它基于150个真实漏洞构建,包含450个任务,涵盖七种广泛使用的语言(Java、C、C++、JavaScript、Python、PHP和Go),涉及24个CWE,包括2025年CWE Top 25中的21个和Top 10 KEV弱点中的8个,比我们比较的任何基准都多,并包含三种氛围编码场景:填充函数、编写文件以及从头构建仓库的源代码树。每个任务仅通过一个从不提及安全性的规范要求功能,隐藏的功能和安全测试对结果进行评分。在六个前沿代理中,73.6%到91.3%的任务在功能上通过,但即使是最强的Claude Fable 5,也仅对25.1%的任务生成既功能又安全的代码,其他代理为16.4%到24.7%。最佳模型在所有氛围编码设置中仅通过12%的漏洞场景,这对氛围编码所写代码的安全性提出了强烈担忧。

该基准首次系统评估了氛围编码场景下AI生成代码的安全性,揭示了功能通过率与安全通过率之间的巨大差距,对依赖AI编码代理的开发者具有重要警示意义。

AI coding agents now write much of the code that ships, yet whether that code is secure remains unclear. We introduce the Last Secure Code Benchmark, a comprehensive evaluation of secure code generation by coding agents. Built from 150 real vulnerabilities, its 450 tasks span seven widely used languages (Java, C, C++, JavaScript, Python, PHP, and Go), 24 CWEs including 21 of the 2025 CWE Top 25 and 8 of the Top 10 KEV weaknesses, more than any benchmark we compare with, and three vibe-coding scenarios: filling in a function, writing a file, and building a repository's source tree from scratch. Every task asks only for functionality, through a specification that never mentions security, and hidden functional and security tests grade the result. Across six frontier agents, 73.6% to 91.3% of tasks pass functionally, yet even the strongest, Claude Fable 5, produces code that is both functional and secure for only 25.1% of tasks, and the others for 16.4% to 24.7%. The best model only passes 12% of the vulnerability scenarios across all vibe coding setting, posing strong concern on the security of the code written by vibe coding.

阅读原文

参与讨论