A “proof” of Fermat’s Last Theorem that fits the margin
Lean's low-level string-slicing function disagreed between its logical definition and its compiled native code when asked to extract a slice at an astronomically large position, so a contradiction could be manufactured. An attacker could then use that contradiction to get Lean to accept a bogus proof of Fermat's Last Theorem.
blog.trailofbits.com
Published on blog.trailofbits.com
Fermat famously claimed to have a “truly marvelous proof” of his Last Theorem, but he never wrote it down, insisting the margin of his page was too narrow to contain it. A few centuries later, Anthropic announced a complete formalization of Fermat’s Last Theorem using 13 million lines of Lean code (clearly not what…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
A proof that should be rejected was accepted as checked, though the text notes this is not a kernel soundness issue and that the extra native_decide axiom widens the trusted boundary.
What the attacker needed
Lean up to version 4.33.1; use of native_decide
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Lean is a tool that checks mathematical proofs by machine. A function that cuts pieces out of text behaved one way when reasoned about abstractly and another way when actually run, so the checker could be tricked into believing two opposite things at once. Once a system believes a contradiction, it will accept any claim as proven.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.