Gelato Hack

Reported loss Not disclosed
Other

What happened

On December 11, 2021, Gelato was warned by samczsun of a critical bug in GUniRouter02. This was the router that its Sorbet Finance app asked users to approve when they added liquidity to G-UNI (Uniswap v3) pools. PeckShield traced the bug to rebalanceAndAddLiquidity() and its internal _swap(). The function accepted caller-supplied swap actions and swap data, so the router would carry out arbitrary instructions. Because users had given the router large or unlimited token approvals, anyone could use it to pull tokens from those users' wallets.

Gelato worked with @roamingRahi on a whitehat rescue. The rescue swept the vulnerable approved balances into an escrow contract, 0x57a7a432A159174D6c6e2004800a9ef5c13940b7, from which users could reclaim them. It secured about $26 million, mostly DAI and USDC plus FRAX, FEI, ENS, WETH and other tokens. Gelato's first alert said no funds had been lost. Revoke.cash later reported that malicious bots front-ran part of the clean-up and took about $744,000. It also says GEL holders voted in January 2022 to fund refunds for losses before December 20, 2021.

The old router could not be patched. Gelato told Sorbet users to revoke approvals to it, and revoke.cash says a new audited contract went live on December 17, 2021.

Whitehat rescue transaction: 0x90a5d10ca9092a82464fd87efb1a7ed06c0d0420fde0cbb20af6e7ec9046c303

How it happened

  1. Sorbet users approved GUniRouter02 to spend their tokens, often with unlimited allowances, so the router could deposit into G-UNI pools for them.
  2. rebalanceAndAddLiquidity() took caller-supplied _swapActions and _swapDatas and passed them to an internal _swap() without restricting the target or calldata.
  3. An attacker could encode a call that makes the router spend a victim's allowance, such as a transferFrom from the victim's wallet to the attacker. The router executed it as the approved spender.
  4. The whitehat team used the same path first, sweeping approved balances from more than 60 wallets into Gelato's escrow in transaction 0x90a5d10c...c303.
  5. Opportunistic bots used the same path on some remaining approvals before users revoked them.

Protocol details

Classification Exchange (DEX)
Protocol Type Exploit/Other
Protocol links Website @gelatonetwork

Build your security review skills

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