开发工具

Claude 自动为开源库生成180M行证明代码,修复多年遗漏bug

\n Anthropic had Claude generate mathematical proofs that existing code is correct, producing roughly 180 million lines of proof code for 123 open-source libraries. Along t

返回指南列表

# Claude 自动为开源库生成180M行证明代码,修复多年遗漏bug

什么是这事

Anthropic 让 Claude 模型自动将开源库的安全测试转化为数学证明,成功为 123 个开源库生成了约 1.8 亿行证明代码,同时修复了传统测试遗漏的多年隐藏 bug。这项工作由 Anthropic Frontier Red Team 与合作伙伴 Theorem 合作完成,使用 Rocq 证明检查器验证结果。

谁适用

  • 开发维护开源库或高安全要求软件的工程师(尤其是依赖 OSS-Fuzz 的团队)。
  • 关心代码正确性验证而非仅靠模糊测试的开发者和架构师。
  • 正在规划 Cursor Pro 或 Claude Code 订阅的用户,可参考 Cursor 的代码审查能力如何与此类 AI 自动化验证结合。

决策建议:如果你想减少手动审计时间或卡网使用官方 Cursor API 处理大项目验证,此新闻值得关注。但目前仍属研究阶段,实际落地取决于 Anthropic/Claude Code 的订阅档位与 Cursor Pro 的编码能力匹配度。

新闻核心内容

Anthropic 在 2026 年 10 月 22 日发布报告,详细说明了这一过程。研究人员先将 Google OSS-Fuzz 的模糊测试(Fuzz Test)转化为数学命题,再让 Claude 在编译后的 RISC-V 机器码上生成证明。

过程大致是:取一个库的入口点函数,编译成 RISC-V 静态二进制,构建“此入口点在输入 <64MB 时不会崩溃”的规范,Claude 尝试证明它。证明通过则通过检查器验证;未通过则 Claude 自动定位 bug 并补丁,继续尝试。

结果:

  • 覆盖 239 个入口点。
  • 生成约 1.8 亿行 Rocq 证明代码(单个证明可达 60 万行)。
  • 修复数百个传统测试(已跑数万亿次)未发现的 bug,包括特定 20MB 输入布局引发的越界写、超过 2GB 内存下的越界读,以及长达十余年的逻辑错误。
  • 示例:PDF 阅读器一周内发现的安全 bug 数量,等于该软件一年正常报告的总量。

Claude 还顺带用自身模型独立编写了 x86 和 RISC-V 的形式化语义模型,发现了部分硬件文档与 CPU 微架构的细微偏差。

为什么这是重大进展

传统形式化验证(Formal Verification)曾被视为“高端定制”,如 seL4 微内核从 2008 年起耗时 20 人年才完成。Claude 项目用几天到几周时间完成 123 个真实开源库的验证,证明了 AI 在自动化证明层面的潜力。

这与 Cursor 订阅的 AI 编程工具理念高度一致:AI 不只生成代码,还能验证其正确性。开发者可期待未来 Cursor Pro 或 Claude Code 订阅直接集成类似“自动证明”辅助,降低人工审查负担。

局限性提醒:证明仅针对单一线程、静态链接、输入 <64MB 的 RISC-V Linux 环境,不覆盖多线程、生产配置或其他架构。并非意味着软件“零 bug”,而是提供了条件下的严格保证。

数据总结(移动端横向滚动友好)

指标 数值 说明
开源库数量 123 个 来自 Google OSS-Fuzz 项目
入口点数量 239 个 覆盖不同库的核心函数
证明代码总量 约 1.8 亿行 Rocq 格式,部分可复用
验证环境 RISC-V 机器码 编译后汇编指令级别
覆盖输入上限 64 MB 模糊测试通常 <1 MB
模型迭代 Opus 5.5 节省 40% Token 证明速度每 2 个月翻倍

延伸阅读

风险与边界

这只是研究性工作,目前无法直接应用于生产环境。实际使用请以 Cursor、Claude Code 或 Anthropic 官网最新订阅/API 价格为准,建议先在小规模项目验证。

非法律意见:本文仅供技术信息参考,不构成投资、购买或任何形式的技术建议。订阅决策需自行评估匹配度,可能存在内容或服务变更风险。

English summary

Anthropic partnered with Theorem to have Claude automatically generate formal proofs for the correctness of real open-source code. In a few weeks, the model produced roughly 180 million lines of Rocq proof code while verifying 123 libraries from Google's OSS-Fuzz project, catching hundreds of bugs missed by trillions of traditional fuzz tests. The work proves at the assembly level on RISC-V that 239 entry points remain safe under defined conditions (single-threaded, inputs under 64 MB). This marks a major step toward making AI-driven formal verification routine, similar to how Cursor Pro and Claude Code subscriptions help engineers write and review code faster. Limitations include conditional guarantees and high compute costs, but proof reusability and model efficiency improvements are accelerating adoption. Developers evaluating Cursor subscriptions should consider how such automation aligns with their verification needs rather than treating the news as immediate production readiness.

(正文字数:约 2350 字,去除空白后中文为主)