Toutes les vulnérabilités
CRITICALWeb3exploited in the wild

WEB3-ZKLEND-2025

Web3 · Starknet · zkLend (Starknet money market)

Résumé

On February 12, 2025 zkLend, a money-market protocol on Starknet, lost about $9.5 million (roughly 61 wstETH) through an integer-division rounding exploit in its lending accumulator on an empty market. The attacker deposited 1 wei into an empty wstETH market where reserve balance and zToken supply were zero, then used repeated flash-loan borrow-and-repay cycles to inflate the lending_accumulator, computed as (reserve_balance + total_debt - amount_to_treasury) * 1e27 / ztoken_supply, to an extreme value around 4.069e45. Because zToken amounts are derived via amount * 1e27 / lending_accumulator using direct division that rounds down, the attacker could deposit a few wstETH yet mint only 1 zToken, and on withdrawal burn 1 zToken while pulling out more wstETH than deposited. Repeating this rounding asymmetry grew the raw balance and let the attacker drain wstETH and other assets across the protocol.

Comment l’éviter dans votre code

  • Never initialize accumulator-based markets from an empty state; require a protocol-seeded initial supply so the accumulator cannot be inflated.
  • Round share/zToken issuance down and asset withdrawal in the protocol's favour so a withdrawal can never exceed the value deposited.
  • Track reserves internally instead of reading raw balances, so donations and flash-loan repayments cannot manipulate the accumulator.
  • Cap per-transaction or per-block growth of the lending accumulator and reject deposits that mint zero shares.
  • Add scaled-precision or virtual-offset arithmetic so integer division truncation cannot be weaponized at low supply.

Références

Vulnérabilités liées

Tout Web3 →