Cream Finance Reentrancy Bug: Difference between revisions
(Created page with "{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/creamfinancereentrancybug.php}} thumb|Cream FinanceCream Finance is a decentralized lending program. There was a reentrancy exploit in the smart contract hot wallet where AMP and ETH were stored. This enabled a hacker to remove 462,079,976 in AMP and 2,804.96 ETH. It appears that Cream Finance has committed to making this right, and that the hacker ultimately returned the...") |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/creamfinancereentrancybug.php}} | {{Imported Case Study 2|source=https://www.quadrigainitiative.com/casestudy/creamfinancereentrancybug.php}} | ||
{{Unattributed Sources}} | |||
[[File:Creamfinance.jpg|thumb|Cream Finance]]Cream Finance is a decentralized lending program. There was a reentrancy exploit in the smart contract hot wallet where AMP and ETH were stored. This enabled a hacker to remove 462,079,976 in AMP and 2,804.96 ETH. It appears that Cream Finance has committed to making this right, and that the hacker ultimately returned the funds. A 10% bounty was offered. | [[File:Creamfinance.jpg|thumb|Cream Finance]]Cream Finance is a decentralized lending program. There was a reentrancy exploit in the smart contract hot wallet where AMP and ETH were stored. This enabled a hacker to remove 462,079,976 in AMP and 2,804.96 ETH. It appears that Cream Finance has committed to making this right, and that the hacker ultimately returned the funds. A 10% bounty was offered. | ||
This is a global/international case not involving a specific country. | This is a global/international case not involving a specific country.<ref name="openblocksecgithub-2342" /><ref name="creamfinancemedium-3831" /><ref name="creamfinancemedium-3832" /><ref name="etherscan-3833" /><ref name="etherscan-3834" /><ref name="peckshieldtwitter-3835" /><ref name="slowmistmedium-3836" /><ref name="knownsecblockchainlabmedium-3837" /><ref name="rektnews-3838" /><ref name="peckshieldtwitter-3839" /><ref name="creamdotfinancetwitter-3840" /><ref name="cointelegraph-6291" /><ref name="coinbureau-6292" /><ref name="creamfinancemedium-6293" /> | ||
== About Cream Finance == | == About Cream Finance == | ||
| Line 69: | Line 70: | ||
!Description | !Description | ||
|- | |- | ||
|August 30th, 2021 | |August 30th, 2021 | ||
|Main Event | |Main Event | ||
|Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here. | |Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here. | ||
| Line 77: | Line 78: | ||
| | | | ||
|} | |} | ||
== Technical Details == | |||
This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited? | |||
== Total Amount Lost == | == Total Amount Lost == | ||
| Line 96: | Line 100: | ||
== Ongoing Developments == | == Ongoing Developments == | ||
What parts of this case are still remaining to be concluded? | What parts of this case are still remaining to be concluded? | ||
== General Prevention Policies == | |||
Hot wallets should either not store customer funds, or be insured fully through smart contract insurance or our proposed industry insurance fund. | |||
== Individual Prevention Policies == | |||
{{Prevention:Individuals:Placeholder}} | |||
{{Prevention:Individuals:End}} | |||
== Platform Prevention Policies == | |||
{{Prevention:Platforms:Placeholder}} | |||
{{Prevention:Platforms:End}} | |||
== Regulatory Prevention Policies == | |||
{{Prevention:Regulators:Placeholder}} | |||
{{Prevention:Regulators:End}} | |||
== References == | == References == | ||
[https://github.com/openblocksec/blocksec-incidents/blob/main/defi/2021.md blocksec-incidents/2021.md at main · openblocksec/blocksec-incidents · GitHub] (Aug | <references><ref name="openblocksecgithub-2342">[https://github.com/openblocksec/blocksec-incidents/blob/main/defi/2021.md blocksec-incidents/2021.md at main · openblocksec/blocksec-incidents · GitHub] (Aug 11, 2021)</ref> | ||
[https://medium.com/cream-finance/c-r-e-a-m-finance-is-coming-to-arbitrum-a806585d6102 C R E A M Finance Is Coming To Arbitrum] (Nov | <ref name="creamfinancemedium-3831">[https://medium.com/cream-finance/c-r-e-a-m-finance-is-coming-to-arbitrum-a806585d6102 C R E A M Finance Is Coming To Arbitrum] (Nov 6, 2021)</ref> | ||
[https://medium.com/cream-finance/c-r-e-a-m-finance-post-mortem-amp-exploit-6ceb20a630c5 C R E A M Finance Post Mortem Amp Exploit] (Nov | <ref name="creamfinancemedium-3832">[https://medium.com/cream-finance/c-r-e-a-m-finance-post-mortem-amp-exploit-6ceb20a630c5 C R E A M Finance Post Mortem Amp Exploit] (Nov 6, 2021)</ref> | ||
[https://etherscan.io/tx/0x0016745693d68d734faa408b94cdf2d6c95f511b50f47b03909dc599c1dd9ff6 Ethereum Transaction Hash (Txhash) Details | Etherscan] (Nov | <ref name="etherscan-3833">[https://etherscan.io/tx/0x0016745693d68d734faa408b94cdf2d6c95f511b50f47b03909dc599c1dd9ff6 Ethereum Transaction Hash (Txhash) Details | Etherscan] (Nov 6, 2021)</ref> | ||
[https://etherscan.io/tx/0xc90468d698700757f33543039c7cb10d4ca49d57b5417789e7656e73019de674 Ethereum Transaction Hash (Txhash) Details | Etherscan] (Nov | <ref name="etherscan-3834">[https://etherscan.io/tx/0xc90468d698700757f33543039c7cb10d4ca49d57b5417789e7656e73019de674 Ethereum Transaction Hash (Txhash) Details | Etherscan] (Nov 6, 2021)</ref> | ||
[https://twitter.com/peckshield/status/1432249600002478081 @peckshield Twitter] (Nov | <ref name="peckshieldtwitter-3835">[https://twitter.com/peckshield/status/1432249600002478081 @peckshield Twitter] (Nov 6, 2021)</ref> | ||
[https://slowmist.medium.com/slowmist-brief-analysis-of-cream-finance-hacked-event-30b18e1db8c https://slowmist.medium.com/slowmist-brief-analysis-of-cream-finance-hacked-event-30b18e1db8c] (Nov | <ref name="slowmistmedium-3836">[https://slowmist.medium.com/slowmist-brief-analysis-of-cream-finance-hacked-event-30b18e1db8c https://slowmist.medium.com/slowmist-brief-analysis-of-cream-finance-hacked-event-30b18e1db8c] (Nov 6, 2021)</ref> | ||
[https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-cream-finance-reentry-vulnerability-incident-analysis-bb7a540c1816 https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-cream-finance-reentry-vulnerability-incident-analysis-bb7a540c1816] (Nov | <ref name="knownsecblockchainlabmedium-3837">[https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-cream-finance-reentry-vulnerability-incident-analysis-bb7a540c1816 https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-cream-finance-reentry-vulnerability-incident-analysis-bb7a540c1816] (Nov 6, 2021)</ref> | ||
[https://www.rekt.news/cream-rekt/ Rekt - Cream Finance - REKT] (Nov | <ref name="rektnews-3838">[https://www.rekt.news/cream-rekt/ Rekt - Cream Finance - REKT] (Nov 6, 2021)</ref> | ||
[https://twitter.com/peckshield/status/1435495419652583425 @peckshield Twitter] (Nov | <ref name="peckshieldtwitter-3839">[https://twitter.com/peckshield/status/1435495419652583425 @peckshield Twitter] (Nov 6, 2021)</ref> | ||
[https://twitter.com/CreamdotFinance/status/1432249771750686721 @CreamdotFinance Twitter] (Nov | <ref name="creamdotfinancetwitter-3840">[https://twitter.com/CreamdotFinance/status/1432249771750686721 @CreamdotFinance Twitter] (Nov 6, 2021)</ref> | ||
[https://cointelegraph.com/news/cream-finance-launches-1-5m-bug-bounty-to-improve-defi-security Cream Finance launches $1.5M bug bounty to improve DeFi security] (Feb 8) | <ref name="cointelegraph-6291">[https://cointelegraph.com/news/cream-finance-launches-1-5m-bug-bounty-to-improve-defi-security Cream Finance launches $1.5M bug bounty to improve DeFi security] (Feb 8, 2022)</ref> | ||
[https://www.coinbureau.com/review/cream-finance/ Cream Finance Review: What You NEED To Know About CREAM!!] (Feb 8) | <ref name="coinbureau-6292">[https://www.coinbureau.com/review/cream-finance/ Cream Finance Review: What You NEED To Know About CREAM!!] (Feb 8, 2022)</ref> | ||
[https://medium.com/cream-finance/august-19th-beta-liquidity-mining-distribution-9e90ee435377 August 19th Beta Liquidity Mining Distribution] (Feb 8) | <ref name="creamfinancemedium-6293">[https://medium.com/cream-finance/august-19th-beta-liquidity-mining-distribution-9e90ee435377 August 19th Beta Liquidity Mining Distribution] (Feb 8, 2022)</ref></references> | ||
Latest revision as of 19:29, 3 May 2023
Notice: This page is a freshly imported case study from the original repository. The original content was in a different format, and may not have relevant information for all sections. Please help restructure the content by moving information from the 'About' and 'General Prevention' sections to other sections, and add any missing information or sources you can find. If you are new here, please read General Tutorial on Wikis or Anatomy of a Case Study for help getting started.
Notice: This page contains sources which are not attributed to any text. The unattributed sources follow the initial description. Please assist by visiting each source, reviewing the content, and placing that reference next to any text it can be used to support. Feel free to add any information that you come across which isn't present already. Sources which don't contain any relevant information can be removed. Broken links can be replaced with versions from the Internet Archive. See General Tutorial on Wikis, Anatomy of a Case Study, and/or Citing Your Sources Guide for additional information. Thanks for your help!
Cream Finance is a decentralized lending program. There was a reentrancy exploit in the smart contract hot wallet where AMP and ETH were stored. This enabled a hacker to remove 462,079,976 in AMP and 2,804.96 ETH. It appears that Cream Finance has committed to making this right, and that the hacker ultimately returned the funds. A 10% bounty was offered.
This is a global/international case not involving a specific country.[1][2][3][4][5][6][7][8][9][10][11][12][13][14]
About Cream Finance
"C.R.E.A.M. Finance is a decentralized lending protocol for individuals, institutions and protocols to access financial services. Part of the yearn finance ecosystem, it is a permissionless, open source and blockchain agnostic protocol serving users on Ethereum, Binance Smart Chain and Fantom. Users who are passively holding Ethereum or Bitcoin can deposit their assets on C.R.E.A.M. to earn yield, similar to a traditional savings account."
"At approximately 12pm on 31st August (UTC +8), C.R.E.A.M. Finance was exploited for 462,079,976 in AMP tokens and 2,804.96 ETH tokens."
"There was a main exploit along with a smaller copy-cat. The copy-cat exploit address has withdrawal history from Binance. We are working with Binance to identify the second perpetrator. We will forward all relevant information to law enforcement authorities and prosecute to the fullest extent of the law."
"The hack is made possible due to a reentrancy bug introduced by $AMP, which is an ERC777-like token and exploited to re-borrow assets during its transfer before updating the first borrow." "The AMP token contract implements ERC777, which has the _callPostTransferHooks hook that triggers tokensReceived() function that was implemented by the recipient. The reentrancy opportunity related to ERC-777-style transfer hooks allowed the exploiter to nest a second borrow() function inside the token transfer() before the initial borrow() was updated. This was used over 17 transactions."
"With the assistance of PeckShield, we have determined that the root cause of the exploit was an error in the way C.R.E.A.M. Finance integrated AMP into our protocol. While unfortunate and disappointing, we take ownership of the error."
"Since the execution of this attack vector would result in the protocol holding bad debts against the attacking contract address, each attacking contract could only be used once. The attacker repeated the attack 7 times with deployments of duplicated attacking contracts before 10 revised version of the attack were launched."
"In the first wave of the attacks, the attacker started with supplying ETH as collateral in crETH market, and then borrowed AMP from crAMP market. Within the execution of transferring AMP to the attacking contract, _callPostTransferHooks was called, which in turn executed an external contract call that then re-entered crETH market to borrow ETH against the very same collateral that was supposed to be posted for borrowing AMP."
"To be more specific, the vulnerability is present within our borrow function when executed in combination with $AMP token’s ERC777 implementation, which calls the tokenReceived hook. In our crToken contract, we transfer the loan before updating the storage. Since $AMP is an ERC777-like token, tokenReceived hook is called. This allowed the attacker to nest a second borrow() function before the initial borrow() completed its execution, the effect of which allowed the attacker to borrow more than normally they would have been allowed."
"[I]n the example tx, the hacker makes a flashloan of 500 ETH and deposit the funds as collateral. Then the hacker borrows 19M $AMP and makes use of the reentrancy bug to re-borrow 355 ETH inside $AMP token transfer(). Then the hacker self-liquidates the borrow." "The hacker repeats the above process in 17 different txs and gains in total 5.98K ETHs (with ~$18.8M)."
"We paused the AMP supply and borrow functions. We will re-enable the AMP market when a patch can be safely deployed. We are working with auditors and technical advisors to ensure that we can safely protect against similar attacks in the future."
"We will be replacing the stolen ETH and stolen AMP so that there’s no liquidity issues for users. We will commit to allocating 20% of all protocol fees toward repayment until this debt is fully paid. In the meantime, we will post a CREAM collateral with the Flexa/AMP team to secure this debt."
"We are committed to making this right for those negatively impacted by the exploiter. We are committed to this industry and building innovative DeFi products. We appreciate the support of our partners and community and will move forward together."
"We have long term goals, and C.R.E.A.M. Finance will continue to build and innovate. We will learn from this exploit and use it as an opportunity to further strengthen the C.R.E.A.M. protocol. While certainly a setback, we remain driven in our mission to bring capital efficiency decentralized lending markets, fulfilling the financial needs of individuals, institutions and protocols."
"@CreamdotFinance hacker just returned 5,152.6 ETH"
This is a global/international case not involving a specific country.
The background of the exchange platform, service, or individuals involved, as it would have been seen or understood at the time of the events.
Include:
- Known history of when and how the service was started.
- What problems does the company or service claim to solve?
- What marketing materials were used by the firm or business?
- Audits performed, and excerpts that may have been included.
- Business registration documents shown (fake or legitimate).
- How were people recruited to participate?
- Public warnings and announcements prior to the event.
Don't Include:
- Any wording which directly states or implies that the business is/was illegitimate, or that a vulnerability existed.
- Anything that wasn't reasonably knowable at the time of the event.
There could be more than one section here. If the same platform is involved with multiple incidents, then it can be linked to a main article page.
The Reality
This sections is included if a case involved deception or information that was unknown at the time. Examples include:
- When the service was actually started (if different than the "official story").
- Who actually ran a service and their own personal history.
- How the service was structured behind the scenes. (For example, there was no "trading bot".)
- Details of what audits reported and how vulnerabilities were missed during auditing.
What Happened
The specific events of the loss and how it came about. What actually happened to cause the loss and some of the events leading up to it.
| Date | Event | Description |
|---|---|---|
| August 30th, 2021 | Main Event | Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here. |
Technical Details
This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited?
Total Amount Lost
The total amount lost has been estimated at $18,800,000 USD.
How much was lost and how was it calculated? If there are conflicting reports, which are accurate and where does the discrepancy lie?
Immediate Reactions
How did the various parties involved (firm, platform, management, and/or affected individual(s)) deal with the events? Were services shut down? Were announcements made? Were groups formed?
Ultimate Outcome
What was the end result? Was any investigation done? Were any individuals prosecuted? Was there a lawsuit? Was any tracing done?
Total Amount Recovered
There do not appear to have been any funds recovered in this case.
What funds were recovered? What funds were reimbursed for those affected users?
Ongoing Developments
What parts of this case are still remaining to be concluded?
General Prevention Policies
Hot wallets should either not store customer funds, or be insured fully through smart contract insurance or our proposed industry insurance fund.
Individual Prevention Policies
No specific policies for individual prevention have yet been identified in this case.
For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.
Platform Prevention Policies
Policies for platforms to take to prevent this situation have not yet been selected in this case.
For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.
Regulatory Prevention Policies
No specific regulatory policies have yet been identified in this case.
For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.
References
- ↑ blocksec-incidents/2021.md at main · openblocksec/blocksec-incidents · GitHub (Aug 11, 2021)
- ↑ C R E A M Finance Is Coming To Arbitrum (Nov 6, 2021)
- ↑ C R E A M Finance Post Mortem Amp Exploit (Nov 6, 2021)
- ↑ Ethereum Transaction Hash (Txhash) Details | Etherscan (Nov 6, 2021)
- ↑ Ethereum Transaction Hash (Txhash) Details | Etherscan (Nov 6, 2021)
- ↑ @peckshield Twitter (Nov 6, 2021)
- ↑ https://slowmist.medium.com/slowmist-brief-analysis-of-cream-finance-hacked-event-30b18e1db8c (Nov 6, 2021)
- ↑ https://medium.com/@Knownsec_Blockchain_Lab/knowsec-blockchain-lab-cream-finance-reentry-vulnerability-incident-analysis-bb7a540c1816 (Nov 6, 2021)
- ↑ Rekt - Cream Finance - REKT (Nov 6, 2021)
- ↑ @peckshield Twitter (Nov 6, 2021)
- ↑ @CreamdotFinance Twitter (Nov 6, 2021)
- ↑ Cream Finance launches $1.5M bug bounty to improve DeFi security (Feb 8, 2022)
- ↑ Cream Finance Review: What You NEED To Know About CREAM!! (Feb 8, 2022)
- ↑ August 19th Beta Liquidity Mining Distribution (Feb 8, 2022)