Hundred Finance Hack

Reported loss $7.4M
Optimism
Flashloan Donate Function Logic Exploit

What happened

On April 15, 2023, an attacker drained about $7.4 million from Hundred Finance's lending markets on Optimism. Hundred is a Compound v2 fork. Its hWBTC market held almost no supply, and the attacker used that to push the hWBTC exchange rate so high that a couple of wei of hWBTC counted as collateral worth hundreds of WBTC. They borrowed against it and then pulled out the WBTC they had donated, helped by a rounding-down bug when redeeming.

The attacker, 0x155da45d374a286d383839b1ef27567a15e67528, ran the main exploit in tx 0x6e9ebcdebbabda04fa9f2e3bc21ea8b2e4fb4bf4f4670cb8483e2f0b2604f451 through attack contract 0x978d0ce23869ec666bfde9868a8514f3d2754982. A second transaction was 0x15096dc6a59cff26e0bd22eaf7e3a60125dcec687580383488b7b5dd2aceea93. rekt.news reports that about $5.4M was bridged to Ethereum and swapped or put into Curve, while about $0.9M stayed on Optimism. Hundred offered a $500k bounty for identifying the attacker, sent the attacker an on-chain message to negotiate, and warned other Compound forks that the bug was a general flaw in the code, not specific to its deployment. This was Hundred's second exploit, bringing its total losses to about $16.9M.

How it happened

  1. The attacker flash-loaned 500 WBTC from Aave V3.
  2. They redeemed the hWBTC they already held, taking the market's hWBTC totalSupply to zero.
  3. They minted 200 hWBTC with 4 WBTC, then redeemed all but 2 wei of hWBTC. Now 2 wei was the whole supply.
  4. They sent the flash-loaned WBTC directly to the hWBTC contract without calling mint(). Because the exchange rate is based on the contract's cash balance (getCash()) divided by supply, this made each hWBTC wei worth a huge amount of WBTC.
  5. With that 2-wei hWBTC as collateral, they borrowed other assets, including about 1,021 ETH.
  6. They called redeemUnderlying to take the donated WBTC back. The hWBTC to burn worked out to about 1.99999, but truncate() rounded it down to 1 wei, so the withdrawal left collateral on the books.
  7. The remaining position was liquidated, the flash loan was repaid, and the borrowed assets were kept as profit. The attacker repeated this across Hundred's markets.

Protocol details

Classification Protocol Logic / Borrowing and Lending / Token & Share Accounting
Protocol Type Lending
Implementation language Solidity
Protocol links Website @HundredFinance

Security review history

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.