Curve Finance Reentrancy Vulnerability
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' section 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!
Curve Finance used Vyper compiler versions between 0.2.15 and 0.3.0 to deploy the smart contracts behind some of their pools. These pools included crv/eth, aleth/eth, mseth/eth, and peth/eth. A vulnerability in smart contract meant that re-entrancy protection which was supposed to be applied was ineffective, and allowed $61.7m USD worth of funds to be drained from the smart contracts. $5.4m of these funds were exploited by a MEV-bot operator, who offered to return them. Curve Finance attempted negotiating for the rest of the funds, and it is unclear the outcome.
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][15]
About Curve Finance
"Curve is one of the largest decentralized exchanges (DEX) in the crypto market today, with about $1.67 billion in total value locked (TVL), according to data on DeFi TVL aggregator DeFiLlama."
"A bug within older versions of the Vyper compiler caused a failure in a security feature used by a limited set of Curve pools (see affected pools below). As a result attackers were able to drain the affected pools of their tokens. The exploit comes directly at the expense of Curve liquidity providers for these affected pools, although Curve is attempting to contact exploiters and recover user funds. Thanks to a white hat, a portion of tokens from one affected pool were recovered by the DAO. The Curve eDAO cannot pause Curve pools or handle user funds in any way. However, it can kill CRV gauge emissions to Curve pools. It is expected the eDAO will kill gauge emissions to all affected pools."
"Curve, a stablecoin exchange at the heart of decentralized finance (DeFi) on Ethereum, has been the victim of an exploit according to a tweet from the project. Curve relies on smart contracts instead of middlemen to offer financial services such as stablecoin borrowing, trading and lending to users. Depositors on Curve earn annual yields of up to 4% from one of the many pools on the platform."
"Several stable pools on Curve Finance using Vyper were exploited on July 30, with losses reaching over $47 million. According to Vyper, its 0.2.15, 0.2.16 and 0.3.0 versions are vulnerable to malfunctioning reentrancy locks."
"A number of stablepools (alETH/msETH/pETH) using Vyper 0.2.15 have been exploited as a result of a malfunctioning reentrancy lock. We are assessing the situation and will update the community as things develop. Other pools are safe."
"According to initial investigation, some versions of the Vyper compiler do not correctly implement the reentrancy guard, which prevents multiple functions from being executed at the same time by locking a contract. Reentrancy attacks can potentially drain all funds from a contract."
"The investigation is ongoing but any project relying on these versions should immediately reach out to us," Vyper wrote on X. Based on an analysis of affected contracts by security firm Ancilia, 136 contracts used Vyper 0.2.15 with reentrant protection, 98 contracts used Vyper 0.2.16 and 226 contracts used Vyper 0.3.0."
"Curve's contracts become vulnerable when making a raw_call to send native tokens. The affected Curve pools were each using one of the aforementioned Vyper versions and are paired with native ETH. Tokens using the ERC-777 standard have also been affected, although Curve pools involving these tokens have all largely been deprecated (e.g. pBTC and HOME). ERC-777 adds callbacks, making those pools susceptible to the same reentrancy issue. Pools paired with WETH have not been affected."
"The exploiter opened an 80,000 WETH flash loan from Balancer and unwrapped all to ETH. They provided 40,000 ETH as liquidity to the Curve pETH/ETH pool and received 32,431.41 pETH-ETH LP tokens. 3,740 pETH and 34,316 ETH was removed from the pool by burning 32,431.41 pETH/ETH pool LP tokens. They again provided 40,000 ETH as liquidity to the Curve pETH/ETH pool, minting 82,182 more LP tokens. Another 1,184.73 pETH and 47,506.53 ETH was withdrawn by burning 10,272.84 Curve LP tokens. 4,924 pETH was swapped for 4,285 ETH within the Curve pool. 86,106.65 ETH was wrapped to WETH. 80,000 WETH repaid to Balancer to return the flash loan. 6,106.65 WETH ~$11 million was retained as profit."
"pETH/ETH | 6,106.65 WETH (~$11m) msETH/ETH | 866.55 WETH (~$1.6 m) and 959.71 msETH (~$1.8m) alETH/ETH | 7,258.70 WETH (~$13.6 m) and 4,821.55 alETH (~9m) CRV/ETH | 7,193,401.77 CRV (~$5.1m at time of exploit), 7,680.49 WETH (~$14.2m), and 2,879.65 ETH (~$5.4m)"
"A number of decentralized finance projects were affected by the attack. Decentralized exchange Ellipsis reported that a small number of stable pools with BNB were exploited using an old Vyper compiler. Alchemix’s alETH-ETH also witnessed $13.6 million outflow, along with $11.4 million exploited on JPEGd’s pETH-ETH pool, and $1.6 million in Metronome’s sETH-ETH pool. Curve Finance CEO Michael Egorov later confirmed 32 million CRV tokens worth over $22 million had been drained from the swap pool in a Telegram channel."
"A white hat hacker managed to take around 2,879 Ether, worth around $5.4 million, from an exploiter and returned it to the decentralized finance (DeFi) protocol Curve Finance amid the recent hack."
"On the same day, an ethical hacker seized some of the stolen assets and returned them to Curve Finance. A maximal extractable value bot operator with the username “c0ffeebabe.eth” used a front-running bot against a malicious hacker to secure almost 3,000 ETH. The funds were then returned to the Curve deployer address, which looks to be its rightful custodian."
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 |
|---|---|---|
| July 21st, 2021 2:41:00 PM MDT | Lemur Committed To Code | The team behind Vyper introduces a cute lemur into their source code in version 2391. |
| August 27th, 2021 6:42:00 AM MDT | Lemur Removal Started | The Vyper team partially removes the lemur. |
| October 25th, 2021 10:21:00 PM MDT | Lemur Removal Complete | The Vyper team fully removes the remaining parts of the lemur. |
| November 18th, 2022 4:22:00 AM MST | Discussion Of Vyper | Discussion of the potential impacts of Vyper. Compilers are deemed to be low risk. |
| July 30th, 2023 7:10:00 AM MDT | Exploit Transaction | The time of the first exploit transaction. |
| July 30th, 2023 10:44:00 AM MDT | Vyper Announcement | Vyper announces about vulnerable reentrancy locks in particular versions of the protocol. |
| July 30th, 2023 10:45:00 AM MDT | Curve Finance Announcement | Curve Finance announces about the vulnerable pools. |
| July 30th, 2023 12:04:29 PM MDT | CoinTelegraph Article | CoinTelegraph publishes an article about the exploit in Curve Finance. |
| July 30th, 2023 1:29:00 PM MDT | CEO Confirmation | Curve Finance CEO Michael Egorov later confirmed 32 million CRV tokens worth over $22 million had been drained from the swap pool in a Telegram channel. |
| July 30th, 2023 1:59:00 PM MDT | BlockSecTeam Tweet | BlockSecTeam tweets more information about the exploit on Twitter. |
| July 30th, 2023 2:25:00 PM MDT | CoinDesk Article | CoinDesk article exploiting. |
| July 30th, 2023 4:00:00 PM MDT | Last Exploit Transaction | The reported end of the exploit transactions. |
| July 30th, 2023 5:50:47 PM MDT | Refund Transaction | $5.4m worth of ethereum is refunded to the Curve deployer contract from the user c0ffeebabe.eth. |
| July 30th, 2023 6:07:00 PM MDT | PeckShield Recognition | PeckShield recognizes the return of funds with a public tweet. |
| July 31st, 2023 2:08:00 AM MDT | Curve Finance Announcement | Curve Finance posts the list of acffected addresses. |
| July 31st, 2023 4:30:52 AM MDT | CoinTelegraph Article | CoinTelegraph posts an article on the return of the funds. |
| August 1st, 2023 11:29:55 AM MDT | TechCrunch ArticleTechCrunch posts and announces the loss amounts as "around $62 million". |
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 $61,700,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
The total amount recovered has been estimated at $5,400,000 USD.
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?
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
- ↑ https://cointelegraph.com/news/white-hat-returns-5-million-curve-finance-hack (Apr 4, 2024)
- ↑ Ethereum Transaction Hash (Txhash) Details | Etherscan (Apr 5, 2024)
- ↑ @PeckShieldAlert Twitter (Apr 5, 2024)
- ↑ https://cointelegraph.com/news/curve-finance-pools-exploited-over-24-reentrancy-vulnerability (Apr 5, 2024)
- ↑ @CurveFinance Twitter (Apr 5, 2024)
- ↑ Telegram: Contact @lobsters_chat (Apr 5, 2024)
- ↑ Curve Finance Drained of $50M While CRV Token Sinks 12% in Latest DeFi Exploit (Apr 5, 2024)
- ↑ @CurveFinance Twitter (Apr 5, 2024)
- ↑ TechCrunch is part of the Yahoo family of brands (Apr 5, 2024)
- ↑ @CurveFinance Twitter (Apr 5, 2024)
- ↑ Curve Pool Reentrancy Exploit Postmortem July 30th, 2023 - HackMD (Apr 5, 2024)
- ↑ fix: storage slot allocation bug by charles-cooper · Pull Request #2391 · vyperlang/vyper · GitHub (Apr 5, 2024)
- ↑ Fix unused storage slots by charles-cooper · Pull Request #2439 · vyperlang/vyper · GitHub (Apr 5, 2024)
- ↑ fix codegen failure with nonreentrant keys by charles-cooper · Pull Request #2514 · vyperlang/vyper · GitHub (Apr 5, 2024)
- ↑ @BlockSecTeam Twitter (Apr 5, 2024)