My last two articles were about PoCs that prove a bug exists when it does not. Invariant suites fail the other way round. They prove a bug is absent when it is not.
The logic of a green invariant run is an argument from absence: the fuzzer tried hard and found nothing, so there is nothing to find. That argument is only as strong as two things the green result does not show you: how much of the reachable state the fuzzer actually explored, and whether the property could have failed at all. Either one can be close to zero while the summary line says [PASS].
To make that concrete, I built a small example and ran it. Everything below is real output from Foundry 1.5.1. The code is synthetic, and the bug is one I planted on purpose.
A share vault with one defect: withdraw rounds the number of shares it burns down, in the caller's favour. ERC-4626 asks for the opposite. Rounding should always favour the vault.
function withdraw(uint256 assets, address receiver) external returns (uint256 shares) {
shares = convertToShares(assets); // assets * totalSupply / totalAssets, rounded down
balanceOf[msg.sender] -= shares;
totalSupply -= shares;
asset.transfer(receiver, assets);
}
While the share price is exactly 1, the rounding never matters. Once the vault earns anything and the price rises above 1, small withdrawals burn fewer shares than they should, sometimes none at all. Every such withdrawal moves value from the other depositors to the caller.
Here is a handler and two invariants. Nothing in them is exotic. Each line is the quickest way to write that part of a suite, which is exactly why it is worth reading twice.
contract WeakHandler is Test {
Vault public vault;
Token public token;
uint256 public ghost_shares;
function deposit(uint256 assets) external {
assets = bound(assets, 1e18, 1e24);
token.mint(address(this), assets);
token.approve(address(vault), assets);
ghost_shares += vault.convertToShares(assets);
vault.deposit(assets, msg.sender);
}
function withdraw(uint256 assets) external {
assets = bound(assets, 1e18, 1e24);
uint256 shares = vault.convertToShares(assets);
vm.prank(msg.sender);
vault.withdraw(assets, msg.sender);
ghost_shares -= shares;
}
}
function invariant_solvent() public view {
assertGe(token.balanceOf(address(vault)), vault.totalAssets());
}
function invariant_supplyMatchesGhost() public view {
assertEq(vault.totalSupply(), handler.ghost_shares());
}
With runs = 256, depth = 100 and show_metrics = true:
[PASS] invariant_solvent() (runs: 256, calls: 25600, reverts: 12735)
| Contract | Selector | Calls | Reverts | Discards |
| WeakHandler | deposit | 12822 | 0 | 0 |
| WeakHandler | withdraw | 12778 | 12735 | 0 |
[PASS] invariant_supplyMatchesGhost() (runs: 256, calls: 25600, reverts: 12950)
| WeakHandler | deposit | 12611 | 0 | 0 |
| WeakHandler | withdraw | 12989 | 12950 | 0 |
Two green invariants, 51,200 calls between them, and the bug is right there. This suite fails in four different ways, and each one alone would have been enough to hide it.
Look at the Reverts column. 12,735 of 12,778 withdrawals reverted, 99.7 percent. The fuzzer picks a fresh sender for each call. deposit credits the shares to whoever called it, and withdraw then pranks as a random sender that almost never holds enough shares, so the burn underflows.
By default Foundry's fail_on_revert is false. A reverted handler call is counted and the run goes on. Nothing fails, nothing warns, and unless you turn on the metrics table you never see that the function you most needed to exercise barely ran.
The fix is to make the handler reach the call instead of hoping for it. Use a fixed set of actors chosen by a seed, prank as the chosen actor for the whole call, and bound the amount by what that actor can actually withdraw:
modifier useActor(uint256 seed) {
actor = actors[bound(seed, 0, actors.length - 1)];
vm.startPrank(actor);
_;
vm.stopPrank();
}
function withdraw(uint256 seed, uint256 assets) external useActor(seed) {
uint256 max = vault.maxWithdraw(actor);
if (max == 0) return;
assets = bound(assets, 1, max);
vault.withdraw(assets, actor);
}
Once the handlers guard their own preconditions, turn fail_on_revert on for that suite. A revert from a handler that should not revert is either a bug in the handler or a finding, and both are worth stopping for.
Even the 43 withdrawals that did succeed could not have found this bug. Nothing in the weak suite ever moves the share price off exactly 1. There is no yield, no donation and no fee, so assets * totalSupply / totalAssets divides exactly every time and there is nothing to round. The suite ran tens of thousands of calls in a world where the defect was mathematically unreachable.
The bounds made it worse. bound(assets, 1e18, 1e24) looks generous, but it maps every input, including the 0, 1 and max values the fuzzer likes to try, into a range that leaves out exactly the dust amounts where rounding bugs live.
The fix is a handler for every way state changes in production, not only the functions users call. Yield, donations, fees, vm.warp for anything time-based, oracle moves for anything priced. And bounds that include 0, 1 and the maximum:
function accrueYield(uint256 amount) external {
if (vault.totalSupply() == 0) return;
amount = bound(amount, 1, 1e20);
token.mint(address(vault), amount);
}
ghost_shares += vault.convertToShares(assets) is the most natural line in the suite, and it makes the second invariant worthless. The ghost variable is computed with the vault's own math, so totalSupply == ghost_shares checks the contract against itself. If convertToShares is wrong, the ghost is wrong in exactly the same way, and the invariant holds.
The fix is to derive ghost values from observed effects, such as token balance deltas measured before and after each call, or from a model you wrote from the specification rather than from the code. If the expected value in an invariant is computed by calling the contract under test, the invariant is not independent of it.
balanceOf(vault) >= totalAssets() reads like a solvency check. In this vault totalAssets() is balanceOf(vault), so the invariant is true by definition. It would hold if the vault gave every token away.
This one is not about reach. To check, I kept the weak solvency invariant and swapped in the good handler, with actors, guarded bounds and a yield handler, so that every call succeeded and the price moved. It still passed: 256 runs, 25,600 calls, zero reverts, bug present. A property that says nothing about who is owed what cannot notice when one depositor takes value from another.
The fix is a property that names a victim. For a share vault, the simplest one is that, absent losses, the share price never goes down. Every rounding decision in a correct vault favours the vault, so no single deposit or withdrawal can lower the assets per share. I check it in the handler, cross-multiplied so the check itself never rounds:
modifier checkPrice() {
uint256 a0 = vault.totalAssets();
uint256 s0 = vault.totalSupply();
_;
uint256 a1 = vault.totalAssets();
uint256 s1 = vault.totalSupply();
if (s0 > 0 && s1 > 0 && a1 * s0 < a0 * s1) priceDecreased = true;
}
function invariant_sharePriceNeverDecreases() public view {
assertFalse(handler.priceDecreased(), "share price decreased");
}
The same vault, with the handler fixes from sections one and two and the property from section four:
[FAIL: share price decreased]
[Sequence] (original: 18, shrunk: 4)
deposit(...)
accrueYield(36)
deposit(...)
withdraw(...)
Four calls: a deposit, 36 wei of yield, which is enough to take the price off 1, a second deposit, and a withdrawal that burns fewer shares than it should.
Then the control, which I would not skip. The same suite, run against the vault with the burn rounded up:
[PASS] invariant_sharePriceNeverDecreases() (runs: 256, calls: 25600, reverts: 0)
| StrongHandler | accrueYield | 8506 | 0 | 0 |
| StrongHandler | deposit | 8628 | 0 | 0 |
| StrongHandler | withdraw | 8466 | 0 | 0 |
That run matters as much as the failure. A property that fails on every implementation is as useless as one that passes on every implementation. The pair, failing on the bug and passing on the fix, is what makes the property evidence.
That pair is the general method, and it is the mirror image of the fix test from my last article. A PoC must fail when you apply the fix. An invariant suite must fail when you plant the bug.
Take the protocol, introduce a defect you know the suite should catch, such as a flipped rounding direction, a removed check or an off-by-one in an accrual, and run the suite. If it stays green, you have measured something about your suite that no number of green runs could tell you. Mutation tools such as Gambit and slither-mutate generate those defects mechanically. Doing it by hand for the three bugs you are most afraid of is a good start.
BEFORE YOU BELIEVE A GREEN INVARIANT RUN
REACH
[ ] show_metrics on, and every handler selector has successful calls
[ ] every revert is explained, or fail_on_revert = true with guarded handlers
[ ] a handler exists for every production state change: yield, donations, fees, time, prices
[ ] bound() ranges include 0, 1, dust and the maximum
STRENGTH
[ ] no ghost value computed by calling the contract under test
[ ] no invariant that is true by definition of the getter it reads
[ ] at least one property names who must not lose
CONTROL
[ ] the suite fails on a planted bug, and passes on the fix
The example is synthetic, and the property is in-sample. I knew the bug when I wrote the invariant that catches it. The honest question is whether you would write that property without knowing. For this bug the answer is yes, because "rounding favours the vault" is in the ERC-4626 specification and "share price does not fall without a loss" follows from it. For a protocol with no specification, finding the right property is the hard part, and no checklist does it for you.
Successful calls are not coverage. The metrics table shows that a function ran, not that it reached its interesting branches. Use line and branch coverage as well. Echidna and Medusa report it, and Foundry can measure it too.
Runs are random. Different seeds give different sequences and counts. The shrunk sequence above is one of many that reach the bug.
Price monotonicity is not universal. Vaults with real losses, such as slashing, bad debt or impermanent loss, can lose value per share legitimately. Their properties have to say when.
Open your invariant suite, set show_metrics = true, and read the Reverts column before you read anything else. Then list the ways state changes in production and check that each one has a handler. Then plant one bug and see whether the suite notices.
If it does not, the green runs you have been looking at were not about your protocol.
A fuzzer that never fails is either looking at a safe protocol or not looking. Make it show you which.

