Does Formal Verification Replace a Smart Contract Audit?
Why proving code correctness against a specification is only part of securing a smart contract.
Does formally verified code still need a smart contract audit? Yes. A formal proof shows that code satisfies a written list of properties. Whether those properties describe what the code is meant to do is a separate question, and whether the code holds up against an attacker is a third. Both questions need people who understand what the system is for and how systems get attacked, and an audit or code review is where those people answer them.
Large language models (LLMs) are now solving open problems in mathematics, with each proof checked by Lean 4, an open-source tool that verifies every step of a proof mechanically. The same combination is being pointed at software. In his May 2026 post "A Shallow Dive into Formal Verification," Vitalik Buterin argues that AI-assisted formal verification could secure a small core of critical software, such as an operating system kernel or Ethereum itself, so thoroughly that the old belief that bugs are inevitable stops being true. It is tempting to read this as a sign that expensive audits and code reviews will soon be unnecessary.
Buterin's own post explains why that reading goes too far. He warns that "it's very easy to forget to prove the claims that are actually important," that false assumptions can slip into proofs, and that the parts of a system left unverified can still fail. Every one of these warnings describes a judgment a person has to make, and making those judgments carefully is what audits and code reviews are for.
At Certora, we build formal verification tools, and we expect AI-assisted verification to make code far more secure. We also expect people to keep reviewing what the proofs actually claim, and this piece explains why. A companion article, How Formally Verified Code Goes Wrong and How to Catch It, covers four ways a proof can fail. This one looks at the distance between three words that are often used as if they meant the same thing: verified, correct, and secure.
Formally Verified, Correct, Secure: What Each Word Claims
Code is formally verified when a tool has checked, for every possible input, that it satisfies a specification. A specification is a list of properties, and each property is a precise statement of something the code must always do, written so that a tool can check it. A tool that performs this check is called a prover. When the prover succeeds, the result is a proof that the code meets its specification under the stated assumptions.
Code is correct when it does what its owners intended. That intent lives in design documents, conversations, and people's heads, and the specification is an attempt to write it down precisely. Formally verified code is therefore correct only to the extent that its specification captures the intent behind it.
One rigorous way to capture intent is to write an abstract model of the whole system, a simplified description of everything it is supposed to do, and then prove that the real code never does anything the model forbids. The seL4 project, which verified the core of an operating system, took this route. For most realistic software, writing a complete model is impractical, so teams settle for a list of properties that capture the most important intended behavior. The quality of that list decides how much the proof is worth.
Code is secure when it keeps its important guarantees even while someone is actively trying to break them. Security is always measured against a threat model, which describes what an attacker can see, what an attacker can control, and what the system must protect. Common security goals include:
Integrity: nobody can make unauthorized changes.
Confidentiality: unauthorized parties cannot learn sensitive information.
Authorization: only permitted operations succeed.
Availability: attackers cannot block legitimate use beyond agreed limits.
Resource safety: attackers cannot force unacceptable consumption of resources such as computation or storage.
Business integrity: attackers cannot push the system into breaking its critical business invariants.
Financial systems add goals of their own, such as no double spending, meaning the same funds can never be spent twice, and solvency, meaning the system always holds enough assets to cover what it owes. Each of these goals has to be stated against a particular threat model, and a proof covers only the goals that are written into the specification.
Each of the three words asks more than the one before it. The table below shows what each claim compares and who is able to check it.
| Claim | What it compares | Who can check it |
|---|---|---|
| Verified | The code against the specification | A prover, automatically |
| Correct | The specification against the owners’ intent | People who know what the system is for |
| Secure | The intended behavior against a capable attacker | People who know how systems get attacked |
A prover answers the first question for every input. The second and third questions compare written text with something that was never written down, and that comparison is the work of human review.
Formally Verified but Not Correct: When the Specification Is Incomplete
A simple auction shows how a passing proof can leave the most important question unasked. Picture a sealed-bid auction run by a smart contract, a program that runs on a blockchain and can hold funds. In a sealed-bid auction, each bidder commits to a price without knowing what anyone else offered.. Anyone can place a bid by sending money to the contract before a deadline. Bids from the same person add up, and whoever has the largest total becomes the current winner.
A formal verification tool such as the Certora Prover can verify useful properties of this contract, including:
- Every bid is recorded accurately.
- The bidder with the highest total is always the winner.
- The highest bid never decreases.
- No bid is accepted after the deadline.
A report listing these four proofs would look reassuring to anyone signing off on the contract. Yet the contract has no way to return money to the bidders who lost, and no way to pay the winning bid to the seller. Every bid stays locked inside the contract permanently. None of the four properties says anything about money leaving the contract, so all four hold and the proof passes. The consequence is that every participant loses everything they bid, and the seller receives nothing.
The four properties pass easily because they are close to a restatement of what the code already does. Properties that mirror the code line by line confirm that the code does what it says, which adds little. The valuable properties come from the purpose of the system, and here the missing one is simple: every losing bidder can recover their funds.
A prover cannot notice that a property is absent. Finding the gap means comparing the specification with what the auction is for, and that comparison takes a reader who understands the purpose.
Missing properties are one way a specification falls short of intent. Properties that are written but prove nothing are another, as in the Notional Finance case, where a verified invariant turned out to be true regardless of the code and a $1 million bug bounty followed. The companion article covers tools that catch that second kind of mistake. Noticing that a property is missing altogether still depends on people.
Correct but Not Secure: The Smart Contract Auction Everyone Can Read
Suppose the team notices the gap, adds refunds and a payout to the seller, and proves the new properties. The auction now matches a reasonable specification of how an auction should behave. It is still exposed to an attack that none of the properties consider.
The developer wanted the bids to stay hidden until bidding closes. To keep the bids hidden, the developer marked the record of bids as private in Solidity, the main programming language for Ethereum smart contracts. That label only stops other contracts from reading the record through the contract's code. On a public blockchain, every stored value and every transaction is visible to anyone who looks, including transactions that are still waiting to be confirmed.
An attacker can use that visibility directly. The contract even declares highestBid and winner as public, so the number to beat is one function call away, and the private bids record adds no protection. The attacker waits until just before the deadline, reads the current highest bid, and bids one wei morethe smallest unit of ether and a tiny fraction of a cent. The attacker wins every auction they enter at the lowest price that beats the competition. Honest bidders lose to someone who paid almost nothing extra, and the seller can end up with less than a truly sealed auction would have raised. Once bidders realize this, they stop trusting the auction.
The proof misses this because confidentiality was never part of the specification, and no property about the contract's own code could express it. The leak happens at the level of the blockchain, and the fact that attackers can read everything on chain belongs to the threat model. A well-known fix is a commit-reveal design, where each bidder first submits a sealed fingerprint of their bid and only reveals the actual amount after bidding closes. Formal verification can then prove useful properties of the new design, but only after someone has recognized the threat and changed the design to address it.
Why a Math Proof Earns Trust and a Software Proof Needs Review
Both gaps in the auction were visible to any reader who asked what the contract was for. Mathematics has such readers built in. LLM-produced proofs earn trust there for two reasons: Lean checks every step mechanically, and a mathematical theorem has a short, public statement that experts have studied for years. When an LLM produces a Lean proof of a famous open problem, mathematicians compare the formal statement in Lean with the original problem, and a mistranslation is likely to be caught. The proof is only as meaningful as that formal statement, and the statement gets plenty of expert attention.
This point has a long history. In 1979, Richard DeMillo, Richard Lipton, and Alan Perlis published "Social Processes and Proofs of Theorems and Programs" in Communications of the ACM. They argued that mathematicians come to believe a theorem through a social process of reading, discussing, checking, and building on its proof, and that proofs about programs would never attract that kind of attention. A 2026 essay by Ivan Gavran, discussed on Hacker News, revisits their arguments and finds that automated tools have answered several of them. Gavran also agrees with them on one point that still stands: people remain the final judges of what "correct" means.
We read the situation the same way. LLMs and provers are taking over the mechanical part of verification, finding proofs and checking them, which is the part the 1979 authors thought would never be practical. The social process they described has not disappeared, and it now belongs on the specification and the threat model. A software specification is long, specific to one system, and read by very few people, so it does not get the expert attention a famous theorem gets unless someone is assigned to give it. An audit is how that attention is assigned.
Critical open-source code raises the stakes further. Libraries and protocols that many teams build on are reused in settings their authors never considered, such as a fork deployed on a different blockchain with different rules about who sees transactions first. A threat model that was right for the original deployment can be wrong for the next one, even when every proof still passes. Public review of the specification and its threat model is the software version of the social process that makes mathematicians trust a theorem.
What Human Review Should Focus On When Code Is Verified
Formal verification can dramatically increase code security when it is done well, and two things decide whether it is. The first is how faithfully people capture the intended behavior of the code. The second is how carefully they define the threat model. Both are hard, and LLMs will increasingly help draft them, but both still need a person to judge whether the draft is right.
The process is also incremental. Every new property that captures real intent, and every new threat the team considers, closes another gap, so a specification can keep improving over the life of a system. Audits and code reviews are the natural place to drive that improvement. With a prover checking the code against its properties for every input, reviewers can spend less time hunting line by line for coding errors and more time on the questions only they can answer:
- Does each property describe what the system is meant to do? A reviewer should be able to explain each property in plain language and tie it to a business requirement. A property that only restates what the code already does proves little.
- Which properties are missing? The auction's specification never required that losing bidders can recover their funds.
- What can an attacker see and control? The sealed bids were visible to everyone, which no property about the code could reveal.
- Which assumptions does the proof rely on, and are they checked when the code runs? Our companion article How Formally Verified Code Goes Wrong and How to Catch It
covers this and the other ways a proof can fail. Certora performs audits alongside formal verification, and in our experience writing the properties is often where design flaws first come to light, before any proof runs. Combining the two lets the prover cover every input while reviewers make sure the properties and the threat model describe the system that people actually need.
Formal Verification and Audits Cover Different Questions
LLMs will keep making formal verification cheaper and more widespread, which is good news for everyone who depends on critical code. A proof gives a strong guarantee that the code matches its specification, and that guarantee grows more valuable as more code is written by machines. Whether the code is correct and secure still depends on the specification and the threat model, and those deserve the same expert scrutiny that proofs in mathematics receive. Buterin warned that it is easy to forget to prove the claims that matter, and easy to let a false assumption slip into a proof. A reviewer is there to catch both: the property nobody wrote and the assumption nobody checked.
To find out what formal verification and a specification review can do for your code, talk to Certora. We offer formal verification and smart contract audits separately or as one combined engagement, so the proofs and the review of what they claim can come from the same team.
Frequently asked questions
- Does formal verification replace a smart contract audit? No. A prover checks code against a written specification for every input. It cannot confirm that the specification captures what the owners wanted or accounts for a capable attacker. An audit reviews the specification and the threat model.
- Can formally verified code still be insecure? Yes. A proof covers only the properties written into the specification. In the sealed-bid auction, every stated property can hold while every bid is readable, because confidentiality was never specified.
- What is a threat model? A threat model describes what an attacker can see, what an attacker can control, and what the system must protect. Security is always measured against one.
- What should an audit check when code is formally verified? Whether each property describes intended behavior, which properties are missing, what an attacker can see and control, and which assumptions the proof relies on.
Nisarg Patel
Mooly Sagiv


