Cointime

Download App
iOS & Android

Curve Cracked: How $52M Vanished in a Vyper Vulnerability

Validated Project

In a recent turn of events, the decentralized stablecoin protocol Curve faced a significant reentrancy attack resulting in severe losses. Here, MetaTrust Labs presents a security analysis of the incident and provides essential security recommendations.

Event Recap

According to Curve Finance's official Twitter account, on July 31, 2023, some stablecoin pools (alETH/msETH/pETH) written using Vyper version 0.2.15 were subjected to a reentrancy attack. Curve Finance clarified that this attack was caused by a malfunctioning reentrancy lock in Vyper 0.2.15 and solely affected pools using pure ETH. Presently, Curve is assessing the extent of the damage, ensuring the safety of other pools.

Based on MetaTrust Labs' analysis, this vulnerability was introduced between August and October 2021, primarily due to the Vyper compiler versions 0.2.15/0.2.16/0.3.0. The root cause of the exploit was a compiler bug that resulted in ineffective reentrancy protection in the generated bytecode.

As per on-chain data, the Curve Finance stablecoin pool hack has led to cumulative losses of $52 million in projects like Alchemix, JPEG’d, and the CRV/ETH pool. The Curve Finance native token, CRV, has also taken a hit, experiencing a drastic intraday drop of over 15%.

Root Causes

Curve Finance fell victim to this attack due to the use of Vyper, a smart contract programming language, with version 0.2.15. Unfortunately, this version contained a bug known as "malfunctioning reentrancy locks," which attackers exploited to cause the losses. The vulnerability faced by Curve Finance is categorized as a Language Specific flaw.

Language Specific vulnerabilities arise from defects or incompatibilities in the programming language or compiler itself. These types of vulnerabilities are challenging to detect and prevent since they result from issues with the underlying technical platform rather than developer oversight or logical errors. Moreover, such vulnerabilities may affect multiple projects or contracts utilizing the same language or compiler.

Vyper, as a Python-based smart contract programming language, aims to provide higher security and readability. It claims to be "security-first" and omits certain features, such as classes, inheritance, modifiers, and inline assembly, which could introduce security risks. Nevertheless, Vyper is not without flaws and may still have bugs or vulnerabilities that can impact contract security. In addition to the reentrancy lock fault faced by Curve Finance, Vyper has previously encountered issues like array overflows, integer overflows, and storage access errors.

Security Suggestions

In response to the reentrancy attack on Curve Finance, several measures have been taken or proposed. Here are some potential security actions Curve could take:

  1. Remove Liquidity: Users of affected pools can choose to remove liquidity to avoid further losses. Curve Finance has already provided a "Remove Liquidity" button on its official website to facilitate this process.
  2. Upgrade Compiler: Contracts compiled with Vyper versions 0.2.15/0.2.16/0.3.0 should be upgraded to the latest version, Vyper 0.3.1, as it addresses the reentrancy lock issue. Additionally, employing other tools or methods for contract security verification, such as formal verification and code audits, is advisable.
  3. Heightened Vigilance: Projects utilizing Vyper or any other programming language should exercise increased vigilance, closely monitoring language or compiler updates and vulnerability fixes, and taking necessary measures to safeguard their assets. Furthermore, when adopting new languages or technologies, thorough evaluations of their maturity and stability are essential to avoid blindly pursuing novelty or efficiency.

Conclusion

The reentrancy attack on Curve Finance serves as a regrettable security incident and a thought-provoking lesson. In the realm of DeFi, security always takes precedence, and project teams must continually raise their awareness and capabilities to combat potential threats. In this ever-evolving landscape, even the smallest detail can become an attacker's point of entry.

Follow Us

Twitter: @MetaTrustLabs

Website: metatrust.io

Comments

All Comments

Recommended for you

  • BTC Surpasses $84,000

    Market data shows that BTC has surpassed $84,000, currently priced at $84,035.16, with a 24-hour increase of 1.16%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Zelensky Responds to Trump's Russia-Ukraine Ceasefire Statement: Ukraine Will Agree if Russia Accepts Energy Ceasefire

    According to Axios, Ukrainian President Zelensky stated that Trump's ceasefire statement was also a surprise to him. Ukraine will agree if Russia accepts an energy ceasefire.

  • CryptoBillis Ledger Attacker Deposits $3.89 Million in Crypto Assets to Binance

    On October 11, the attacker of CryptoBillis Ledger deposited approximately $3.89 million in crypto assets to Binance over the past two days, including 3.685 million USDT and 615,000 TRX (about $204,000). This attacker had previously stolen over $90 million in crypto assets. (PeckShieldAlert)

  • KillaXBT: BTC May Surge Before Midterm Elections, Drop After, Historical Probability 75% Bearish

    On October 11, Killa (@KillaXBT), a user on X, shared his perspective that the ideal path for BTC is to rise before the midterm elections, establishing a bullish narrative and surpassing previous highs. Following this, he anticipates a pullback post-election, similar to past cycles, but with higher lows instead of new cycle lows. He believes that if there is a decline before the elections, it is more likely to rise towards $95,000 afterward. Citing data, he noted that nearly $2 billion in long positions were just liquidated, with only three weeks until the midterm elections. Historically, in four midterm elections, three have seen bearish trends emerge one to two months after the elections, giving a probability of 75%. He stated that the worst-case scenario would be a price rebound leading into the elections, followed by a reversal that traps the other side before de-risking. He believes that the narrative for one side has already been liquidated, and the current exposure of shorts is higher than that of longs. The author claims to still hold 10x long positions and longs established at 62.6K and 76.4K, with all positions fully allocated and not closed. This represents his personal trading view and is not an objective event.

  • Argentine Central Bank Indicates Cryptocurrencies May Open to Banks

    On October 11, the Argentine Central Bank stated that during Milei's second term, cryptocurrencies may be opened to banks, lifting a ban that has been in place for four years.

  • Trump: Russia and Ukraine Agree to 'Energy Ceasefire'

    On October 11, U.S. President Trump announced that an 'energy ceasefire' has been reached in the Russia-Ukraine war, effective immediately. Both sides have agreed not to disrupt it.

  • CITIC Securities: Hong Kong Stocks' Fundamentals Expected to Have Bottomed Out

    On October 11, CITIC Securities' research report pointed out that for Hong Kong stocks, although the overseas interest rate hike cycle combined with the restart of AI-driven trading continues to pressure liquidity, the fundamental expectations have bottomed out, and the earnings growth expectations for major broad-based indices have begun to be revised upwards. There is a significant divergence in the adjustment of industry earnings expectations, with some specific sectors seeing upward revisions, while industries related to domestic demand still face downward pressure on earnings expectations. The upcoming third-quarter performance will be an important basis for assessing the progress of recovery. The report advises investors to maintain patience with Hong Kong stocks, expecting that short-term dividend strategies will continue to outperform.

  • Five Major U.S. TV Networks Boycott White House Coverage; DOJ Launches Antitrust Investigation

    On October 11, the U.S. Department of Justice announced it is investigating whether five television networks, including CNN, violated federal antitrust laws. This follows President Trump's ban on reporters from CNN and two other news organizations from entering the White House for coverage, prompting these five major media outlets to collectively boycott and refuse to report on White House activities in solidarity with the banned reporters. The antitrust division of the DOJ is examining CNN, NBC, CBS, Fox News, and ABC. These news organizations have formed a television broadcasting alliance to jointly cover presidential activities and share video footage. The DOJ stated that the members of this television press corps are boycotting White House coverage; such collective boycott actions among business competitors may violate the Sherman Antitrust Act. The antitrust division is investigating to determine if these news organizations have violated antitrust laws. Last month, Trump barred reporters from CNN, MS NOW, and Politico from entering the White House, citing that their coverage was unfavorable to him. Following this, major television networks suspended joint reporting. When CNN was removed from its scheduled coverage of Trump at the United Nations General Assembly, other networks refused to take its place.

  • Zelensky: Will Organize Ukrainian Elections if Putin Agrees to 60-Day Ceasefire

    On October 11, according to ABC News, Ukrainian President Zelensky responded to U.S. President Trump, stating that he would organize Ukrainian elections if Russian President Putin agrees to a 60-day ceasefire.

  • CITIC Securities: Hong Kong Stocks' Fundamentals Expected to Have Reached Bottom

    On October 11, CITIC Securities' research report indicated that for Hong Kong stocks, although the overseas interest rate hike cycle combined with the restart of AI-driven trading continues to pressure liquidity, the fundamental expectations have reached a bottom, and the earnings growth expectations for major broad-based indices have begun to be revised upward. There is a significant divergence in the adjustment of industry earnings expectations, with some specific sectors seeing upward revisions, while earnings expectations in domestic demand-related industries still face downward pressure. The upcoming third-quarter performance will be an important basis for assessing the progress of recovery. The report advises investors to maintain patience with Hong Kong stocks, expecting that short-term dividend strategies will still outperform.