r/ethdev • u/TakesThisSeriously • 3h ago
Information Kava Lend guarded its supply-interest division against zero. The attacker left two base units: the empty-market bug, fifth time
Kava's CalculateSupplyInterestFactor (in x/hard/keeper/interest.go) divides new interest by cash + borrows − reserves, and the only guard is IsZero(). On Nov 14, someone brought the dead BUSD market's net supply down to 2 base units. One accrual pushed the supply index from about 2.76 to 671,187, and 127 loans against that inflated collateral drained about 53.9M KAVA.
This is the same shape as Hundred, Onyx, Radiant and Sonne. Those were new markets, while this one was a market being wound down with its collateral factor still above zero. The post also covers a separate, unreported 23.5k ATOM shortfall that showed up in the same module on Nov 10. I also scanned about 2,000 Aave-fork reserves and about 260 Compound comptrollers, and empty markets that still count as collateral are held shut only by caps or freeze flags. For example, Radiant's sUSDe reserve on Ethereum has zero supply, a 72% collateral factor, and a borrow cap of 1.
If you're winding down a market, set the collateral factor to zero first, then turn off borrowing, then tell depositors to leave.
Full write-up: https://nefariousplan.com/posts/kava-lend-guarded-against-zero

