All vulnerabilities
CRITICALWeb3exploited in the wild

WEB3-RARI-FEI-2022

Web3 · Ethereum · Rari Capital Fuse

Summary

On 30 April 2022 the Rari Capital / Fei Protocol Fuse lending pools on Ethereum lost approximately $80 million (about $79.7 million across ETH, FEI, DAI, LUSD and USDC). Fuse pools were a fork of Compound's CToken, but the CEther contract sent ETH using low-level call.value() instead of Compound's gas-capped transfer(), forwarding all remaining gas to the recipient's fallback. The borrow() function called doTransferOut(), which performed that call.value() ETH transfer to the borrower before the borrow and collateral accounting was finalized, violating checks-effects-interactions. The attacker's fallback re-entered the Comptroller's exitMarket() while the deposited collateral was still counted as backing the loan, freeing the collateral while keeping the borrowed ETH; the Comptroller's reentrancy guard did not cover exitMarket on the affected pools. Funded by Balancer flash loans, this cross-contract reentrancy drained seven pools.

How to avoid it in your code

  • Update borrow and collateral state before any external value transfer, following checks-effects-interactions
  • Send ETH with a strict gas stipend, never raw call.value() that forwards all gas while accounting is mid-update
  • Extend the nonReentrant guard to cover every cross-contract path including exitMarket, redeem and borrow
  • Audit forked Compound/CToken code for deviations from upstream transfer semantics before deploying
  • Add cross-contract reentrancy tests that re-enter the Comptroller during a token transfer

References

Related vulnerabilities

All Web3 →