All vulnerabilities
CRITICALWeb3exploited in the wild

WEB3-HARVEST-2020

Web3 · Ethereum · Harvest Finance

Summary

On 26 October 2020 Harvest Finance lost approximately $33.8 million (with about $2.5 million later returned) on Ethereum in a flash-loan price-manipulation attack against its fUSDT and fUSDC vaults. The vaults priced shares from the live spot exchange rate of Curve's Y-pool, so the attacker flash-borrowed tens of millions in USDT and swapped roughly $17M USDT into USDC through the pool to temporarily depress USDC and lift the pool's reported USDC value to about $1.01. While the pool was skewed, the attacker deposited USDC into the vault and minted shares at the inflated price, then reversed the Curve swap to restore the rate and redeemed the shares for more underlying than deposited, repeating the loop many times. The root cause was deriving deposit/withdraw share value from a single Curve pool's instantaneous spot rate, which is fully manipulable inside one flash-loan transaction.

How to avoid it in your code

  • Do not price vault shares from a single AMM/Curve pool's instantaneous spot rate; use time-weighted or aggregated prices
  • For Curve LP valuation prefer get_virtual_price with sanity bounds rather than spot reserve ratios a flash loan can skew
  • Add deposit/withdrawal deviation checks that reject when the pool price diverges from an external reference
  • Charge withdrawal fees or impose same-block deposit/withdraw restrictions to remove atomic round-trip arbitrage
  • Never let one transaction both skew the pool and mint shares against it

References

Related vulnerabilities

All Web3 →