Gelato Hack
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
- Sorbet users approved
GUniRouter02to spend their tokens, often with unlimited allowances, so the router could deposit into G-UNI pools for them. rebalanceAndAddLiquidity()took caller-supplied_swapActionsand_swapDatasand passed them to an internal_swap()without restricting the target or calldata.- An attacker could encode a call that makes the router spend a victim's allowance, such as a
transferFromfrom the victim's wallet to the attacker. The router executed it as the approved spender. - The whitehat team used the same path first, sweeping approved balances from more than 60 wallets into Gelato's escrow in transaction
0x90a5d10c...c303. - Opportunistic bots used the same path on some remaining approvals before users revoked them.
Protocol details
Evidence
- report Gelato (@gelatonetwork): ATTN G-UNI USERS - critical vulnerability in a G-UNI Router contract on Sorbet Finance twitter.com
- report @peckshield incident report twitter.com
- transaction Etherscan tx 0x90a5d10c...c303 (Gelato Whitehat Contract) etherscan.io
- analysis 2021 Sorbet Finance Hack (Revoke.cash) revoke.cash
- analysis Bug Found Gelato's Contract: Might have Lead to Significant Losses (CoinCodeCap) coincodecap.com
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.