All vulnerabilities
CRITICALWeb3exploited in the wildcurated

WEB3-EULER-2023

Web3 · Ethereum · Euler Finance

Summary

On 13 March 2023 the Ethereum lending protocol Euler Finance was drained of about $197 million, the biggest DeFi hack of the year. The attacker did not steal a key or break any cryptography. They borrowed a fortune with a flash loan, used a single missing safety check in Euler's code to deliberately push their own position into bad debt, and then exploited Euler's own liquidation rules to be paid far more than they were owed. In a now-familiar twist, the attacker, identifying only as "Jacob," gave more than all of it back over the following weeks. It is a clean lesson in DeFi's defining risk: composable money where one unchecked code path can be turned into a money pump.

How it happened

Euler is a DeFi lending protocol, and the bug was mundane: a function called donateToReserves let a user donate tokens to the protocol's reserves without checking that the donation left their own account solvent. That single missing health check was the whole opening, and tellingly the function had been added later in a governance upgrade, in scope for only one of Euler's ten-odd audits.

The attacker turned it into a machine. First they took a roughly $30 million flash loan from Aave, free capital for one transaction. They used Euler's leveraged minting (up to about 19x) to build an enormous position, then called donateToReserves to give away enough of their own collateral (dropping it to about 310 million against 390 million in debt tokens) to shove the account into bad debt on purpose. Finally they self-liquidated through a second address. Euler's "soft liquidation" logic applied a discount that grew with how unhealthy the account was, up to 20%, so the liquidator (the attacker's other wallet) was handed far more collateral than the debt was worth. Repeated across six token pools (DAI, stETH, WBTC, USDC and more), the same donate-then-self-liquidate cycle pulled out roughly $197 million in all.

The recovery

What made Euler unusual was the ending. After days of on-chain negotiation, public pressure, and Euler offering to drop legal action and pay a bounty if most of the money came back, the attacker returned more than all of it, around $240 million, because the stolen ~$197 million had appreciated with ETH during the three weeks of back-and-forth. Euler confirmed the recovery complete on 3 April 2023. As with the Poly Network theft, the transparency of the blockchain turned out to be the protocol's best leverage: the money was always in plain view.

Why Euler still matters

Euler is the archetypal modern DeFi hack: a flash-loan-amplified logic bug. There was nothing exotic, just a function that changed balances without re-checking the account's health, weaponised with free borrowed capital and the protocol's own liquidation incentives. The lessons are precise: run a health and solvency check on every balance-changing path, including donations and transfers out of a position; apply checks-effects-interactions and re-validate account health after each state change; cap liquidation discounts so a liquidator can never be paid more than the debt plus a sane incentive; and add invariant tests asserting that no single atomic operation can move a healthy account into bad debt. Above all, treat a flash-loaned, single-transaction leverage cycle as a standard adversarial scenario, because attackers always will, and re-audit any feature added after the original review. It sits alongside the Curve hack as a defining DeFi failure of 2023.

How to fix it

  • Pause the protocol and patch the unchecked path (here, the donate function) to enforce a solvency check before any balance change is finalized.
  • Re-audit every other balance-changing function for the same missing check, since this bug class rarely appears alone, and re-audit features added after the original review.
  • Trace funds and negotiate recovery on-chain; Euler recovered more than everything through traceability and public pressure.

How to avoid it

  • Run a health/solvency check on every balance-changing path, including donations and transfers out of positions.
  • Apply checks-effects-interactions and re-validate account health after each state mutation.
  • Cap or floor liquidation discounts so liquidators cannot be paid more than the debt plus reasonable incentive.
  • Add invariant tests asserting no operation can move a healthy account into bad debt atomically.
  • Treat flash-loaned, single-transaction leverage cycles as a tested adversarial scenario, and re-audit governance-added functions.

References

Related vulnerabilities

All Web3 →