By Hamza Faisal

Anthropic asked Claude to prove that safe Rust code is actually safe. The model came back with dozens of counterexamples — including a five-line program, written entirely in safe Rust, that reads memory after it has been freed. The bug had been sitting in the compiler for more than seven years.

The work comes from Anthropic's Frontier Red Team, published on December 2. The team tested four ways of using large language models to hunt logic bugs. Two techniques worked best: agentic code review, where the model reads source code for flaws, and informal correctness proofs, where the model tries to prove a program correct and every failure points at a bug.

A five-line program that breaks Rust's core promise

Rust's central guarantee is simple: code that avoids the unsafe keyword should never touch invalid memory, and the borrow checker is supposed to enforce that. Anthropic's test broke it with a short program that creates a two-dimensional array holding a boxed integer, then takes a mutable reference to one element while computing the second index. Inside that index expression, the inner array is moved out and dropped, freeing the boxed value — but the borrow checker never connects the move with the borrow, so the reference ends up pointing at freed memory. The Miri checker flags it as a use-after-free.

The flaw is tracked as rust-lang/rust issue 160525, filed on August 4. Community bisection traced it to a nightly build from April 23, 2019, when non-lexical lifetimes were switched on — so it had been latent for more than seven years. It was still open on December 3, with a contributor working on a fix. Rust maintainers note around 178 similar soundness issues remain open.

Anthropic says Claude turned up several dozen Rust type-safety issues in total, some already fixed and others still being handled. The lab stresses these are bugs, not security vulnerabilities in the traditional sense — though the example could introduce type-confusion flaws into code that looks type-safe.

Beyond Rust: the kernel, macOS and a chip's root of trust

The Rust compiler was only one target. Using the same proof technique, Anthropic says it found more than 100 soundness bugs in the Linux kernel's eBPF verifier. One of them, CVE-2026-98041, has been patched. Agentic code review also surfaced a privilege-escalation flaw in macOS, CVE-2026-43783, and a flaw in Caliptra, the open-source chip security project, CVE-2026-11835, which could have let a compromised chip component run unverified firmware.

To measure the methods, Anthropic built a benchmark of 21 already-patched logic bugs. In blind trials, agentic code review rediscovered 11 of the 21 and informal proofs found eight; when given the invariants the code should satisfy, proofs found all 21. The runs also surfaced 316 other bugs; 189 were already fixed or known, and Anthropic is reporting the remaining 127.

AI as a bug hunter, with humans still in the loop

Anthropic researcher Nicholas Carlini said he was testing a large-model agent framework for finding soundness issues and handed the Rust counterexample to Rust-savvy developers for verification before filing it. He is not a Rust expert himself, he acknowledged, and a batch of candidates still awaits checking so the community is not flooded with low-quality reports.

The researchers conclude recent models can identify logic bugs without human guidance or specialized tooling. The Rust case shows both sides of that claim at once — an AI found a flaw that hid for seven years, and it still took human experts to confirm it, file it and fix it.

By Hamza Faisal