Cream Finance Hack
Incident Overview
Cream Finance got exploited through a vulnerability hidden in the borrow() function, which was repeatedly utilized for reentrancy attacks. The attacker made away with approx. $36 million.
Cream (Crypto Rules Everything Around Me) Finance is a decentralized lending protocol designed for institutions, protocols and people in order to access financial services.
The risk for reentrancy arose because of the way $AMP was integrated into the protocol. The $AMP token contract is based on the ERC777 standard, which utilizes the _callPostTransferHooks hook. The attack transactions started with supplying $ETH as a collateral for borrowing $AMP from the crAMP market. When transferring AMP to the attacking contract, the _callPostTransferHooks was called, which in turn triggered the execution of a fallback function in the attack contract allowing the latter to re-enter the crETH market to borrow $ETH against the very same collateral initially supposed to be used for borrowing $AMP.
The flow of an example exploit transaction: https://etherscan.io/tx/0xa9a1b8ea…ffe61e
- The hacker creates contract A to flash loan 500 $WETH and use the funds as collateral on cream, minting 24.17k crETH;
- borrows 19.48M $AMP for the received crETH;
- exploits the reentrancy possibility by repeatedly calling borrow() during the token transfer, taking a further 355 $ETH before the state of the initial borrow() has been updated;
- uses contract B, which receives a half (9.74M) of A's borrowed $AMP;
- contract B liquidates part of A's loan, redeeming 187 $WETH and transferring it back to contract A;
- contract A uses $ETH borrowed via reentrancy to repay the remainder of the flash loan.
The profits of the above explained transaction amounted to 41 $ETH and 9.74M $AMP.
In total, 17 attack transactions were conducted netting the attackers a total of $AMP 462,079,976 and $ETH 2,804.96.
Attack contract A:
https://etherscan.io/address/0x38c40427…0bd22b
Attack contract B:
https://etherscan.io/address/0x0ec306D7…75A125
Exploiter address 1:
https://etherscan.io/address/0xce1f4b4f…ff6ede
Exploiter address 2:
https://etherscan.io/address/0x8036EbD0…6aaF1F
Incident Report
Protocol Information
What the Attacker Needed to Succeed
Understanding the prerequisites for this type of attack helps auditors identify protocols that are most at risk and helps developers build better defenses.
What Auditors Should Check
If you're auditing a protocol with similar architecture to Cream Finance, these are the critical security checks that could have prevented this incident (August 2021).
- Verify all logic paths related to Other are guarded by proper access controls and input validation
- Review privileged functions (owner, admin, governance) for potential abuse vectors - centralization risks should be documented and bounded with timelocks or multi-sigs
Master these auditing techniques with hands-on labs and real exploit scenarios in the Smart Contract Hacking course.
Free TrialSources & References
- 01
-
02
Source 2 https://rekt.news/cream-rekt/
Learn to Prevent the Next Cream Finance
The Cream Finance hack is one of many attacks that skilled auditors are trained to detect before deployment. Master real exploit patterns and defense techniques with hands-on Web3 security training.