News › #security

Machine-checked no-crash proofs for 123 open-source libraries: how Anthropic and Theorem used Claude with Rocq

5 min readVerified
Anthropic research

Anthropic and Theorem report that Claude proved, in Rocq, that compiled RISC-V code from 123 open-source libraries cannot crash on inputs below 64 MB, finding hundreds of bugs on the way. We explain the fuzz-test-to-theorem pipeline, the numbers, the stated limits, and show testing versus proving with a small solver example.

In short

On 22 October 2026, Anthropic's Frontier Red Team and the company Theorem reported that Claude wrote machine-checked proofs that the compiled code of 123 open-source libraries (239 entry points) does not crash for any input smaller than 64 MB. The proofs are about RISC-V machine code, not source code, and are checked by the proof assistant Rocq (formerly Coq). While writing them, the model found "hundreds" of bugs, which it patched before proving the patched code. This matters because formal verification has always been too expensive for most software; if AI makes proofs cheap, "no crash for any input" becomes a property that ordinary projects can ask for, not only aircraft or kernels.

How it works

From fuzz test to theorem. Many open-source libraries already have fuzz tests: small programs that feed random inputs into a library function and report a crash. A fuzzer can only try many inputs, never all of them. The project turned each fuzz harness into a formal statement: "for every input up to 64 MB, this compiled program does not crash". The statement is written against a mathematical model of RISC-V instructions and of the Linux process environment that Theorem built.

The model writes the proof. Claude then had to produce a Rocq proof of that statement. Rocq checks every step mechanically, so a wrong proof is rejected, however convincing it looks. When the proof failed because the program really could crash, the model had found a bug. It wrote a patch, the statement was regenerated from the patched program, and the proof started again. Patches were penalized and audited, so that the model could not make a theorem easy by changing what the program does (a form of reward hacking).

Analogy: a fuzzer is a tester who throws a million random stones at a window; a proof is a structural engineer's calculation that shows no stone below a given weight can break it. The calculation is much more work, which is why it was rare.

Under the hood

Scale (as reported).

Quantity Value
Libraries / entry points 123 / 239
Property no crash for any input below 64 MB
Target single-threaded static RISC-V binaries linked against musl libc under Linux
Median binary length about 18,000 RISC-V instructions
Proof size about 180 million lines of Rocq in total; a typical proof about 600,000 lines
Duration "a few weeks"
Bugs found "hundreds"

Why prove facts about machine code? A proof about source code trusts the compiler. A proof about the compiled binary does not, but it needs a model of every instruction and of the operating system's behavior (memory layout, system calls). Theorem's RISC-V and Linux process semantics provide that model and are published.

Example bugs that the proof attempts exposed (from Anthropic's post): a counter underflow in a decompressor that causes an out-of-bounds write, triggered only by rare inputs of about 20 MB; an out-of-bounds read in an image decoder that needs a 64 MB input and over 2 GB of memory; an out-of-bounds read that needs a specific sequence of calls on two file handles; and a rediscovery of CVE-2026-56132 in libexpat, triggered by deeply nested input. These are exactly the inputs that random fuzzing rarely produces.

Agent workflow. Agent teams reused and adapted finished proofs from other programs, and a shared workspace reduced token use by 17% in a benchmark. Anthropic reports that Opus 5.5 needed about 40% fewer tokens than Opus 5 on 36 small tasks, and that single proofs can take hundreds of millions of tokens. Dollar cost is not reported. A separate experiment used Verus (a verifier for Rust) on a Python interpreter written in Rust, which behaved identically to CPython on 99.95% of 1.7 million random programs.

Limits (stated by Anthropic).

  • "Formally verified" does not mean bug-free: errors can remain in the specification, in the RISC-V and Linux models, or in the proof checker.
  • The property is only "does not crash"; it says nothing about correct output. Anthropic also notes that AddressSanitizer (ASan) does not catch every memory-safety bug.
  • The setting (static musl binaries on RISC-V) differs from what most users run (dynamically linked glibc on x86 or ARM).
  • Not every entry point was verified, and a caller that misuses a library can still corrupt memory.

What is released. A subset of the proofs (theorem-labs/oss-verify-proofs), the RISC-V and OS semantics (theorem-labs/rocq-linux-process-semantics), and a skill for adding projects. Proofs that could reveal unpatched bugs are withheld.

Disclosure. This article was drafted by an AI research assistant built on Anthropic's Claude models. All numbers above are Anthropic's own; we found no independent reproduction yet.

Try it yourself

The core difference between testing and proving can be shown with a small SMT solver (Z3), a different but related formal tool. The function below is a bounds check written as in C, with 32-bit unsigned arithmetic: it adds one byte for a terminator and then compares with the buffer size. For exactly one length out of about 4.3 billion, the addition wraps around to zero. Requirements: pip install z3-solver (tested with Python 3.13 and z3-solver 4.13.4.0).

import random
from z3 import BitVec, BitVecVal, ULE, Not, And, Solver, ZeroExt, sat

BUF = 4096
MASK = 0xFFFFFFFF

def check_c_style(length: int) -> bool:
    """Bounds check as written in C with 32-bit unsigned arithmetic:
    'reserve one byte for a terminator, then check'. Returns True if the write is allowed."""
    needed = (length + 1) & MASK              # wraps to 0 when length == 0xFFFFFFFF
    return needed <= BUF

# 1) Fuzzing: one million random 32-bit lengths
random.seed(0)
hits = sum(1 for _ in range(1_000_000)
           if check_c_style(x := random.getrandbits(32)) and x + 1 > BUF)
print("fuzzing: unsafe lengths accepted =", hits)

# 2) Solver: is there ANY 32-bit length that passes the check but is too large?
L = BitVec("length", 32)
needed = L + 1                                 # 32-bit bit-vector arithmetic wraps like C
too_large = Not(ULE(ZeroExt(1, L) + 1, BitVecVal(BUF, 33)))  # true size computed in 33 bits
s = Solver()
s.add(And(ULE(needed, BitVecVal(BUF, 32)), too_large))
print("solver:", s.check(), s.model() if s.check() == sat else "")

# 3) After the fix (compare before adding), the solver proves no such input exists
s2 = Solver()
s2.add(And(ULE(L, BitVecVal(BUF - 1, 32)), too_large))
print("solver after fix:", s2.check())

Expected output:

fuzzing: unsafe lengths accepted = 0
solver: sat [length = 4294967295]
solver after fix: unsat

One million random tries miss the bug; the solver finds the single bad input at once. After the fix, unsat means that no 32-bit input violates the bound: a proof for all inputs, not a test of some. The Anthropic project does the same kind of reasoning for whole compiled libraries, with Rocq proofs instead of an automatic solver, because whole programs are far too large for push-button solving.

Sources

  1. Formal verification of open-source libraries with Claude (Anthropic research, 22 Oct 2026)
  2. oss-verify-proofs (Theorem, GitHub)
  3. rocq-linux-process-semantics (Theorem, GitHub)
  4. The Neuron digest, 23 Oct 2026 (secondary)