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

  • U.S. July Nonfarm Payrolls Fall by 23,000, Missing Market Expectations

    On August 7, U.S. nonfarm payrolls decreased by 23,000 in July, compared with market expectations of an increase of 80,000, and the previous value was an increase of 57,000.

  • US May and June Nonfarm Payroll Additions Revised Down by 103,000 Combined

    On August 7, the US Bureau of Labor Statistics: May nonfarm payroll additions were revised down from 129,000 to 63,000; June nonfarm payroll additions were revised down from 57,000 to 20,000. After the revisions, the combined additions for May and June were 103,000 lower than previously reported.

  • U.S. Rate Futures Market Sees Lower Odds of Fed September Hike

    On August 7, the probability of a Fed rate hike in September as priced by U.S. interest rate futures declined.

  • New York Gold Futures Top $4,400 per Ounce

    New York gold futures topped $4,400 per ounce, up 2.36% on the day.

  • Japan Finance Minister: FX Market Affected by Moves Not Driven by Actual Demand

    Japanese Finance Minister Satsuki Katayama said she and U.S. Treasury Secretary Bessent agreed that the foreign exchange market has been affected by moves not driven by actual demand.

  • BTC Breaks Through $65,000

    Market data shows BTC has broken through $65,000, currently reported at $65,007.44, with a 24-hour increase of 0.6%. The market is highly volatile, please exercise risk control.

  • Brent Crude Drops 2.00% Intraday to $81.07/Barrel

    Brent crude oil fell 2.00% during the day, now at $81.07 per barrel. (Jin Shi)

  • Trump: Data Centers May Be More Important Than Oil

    August 7 news, U.S. President Trump said in an interview with Punchbowl News, "I saw the other day that Texas seems to be opposed to building data centers. I think that's a mistake. I'm not taking a position—I just think it's a mistake, because there are other communities that want to build data centers. When a community is willing to accept data centers, it means a lot of money will flow into that community. I don't think they're ugly. Some of the data centers I've seen are the most incredible buildings I've ever seen. They are very important to the economy. If Texas says no to data centers, that's a mistake, because data centers may be more important than oil."

  • Trump to Meet with Mining Executives

    On August 7, according to CCTV International News, US President Trump will convene executives from some of the world's largest mining companies at the US State Department on August 7 local time, in an effort to take action to 'secure critical mineral supplies for the US and its allies.' Reuters reported that the US urgently needs critical minerals to replenish weapons inventories depleted during the war against Iran. During the more than five-month war with Iran, the US military expended large quantities of precision-guided missiles and air defense interceptors. US defense officials and lawmakers have warned that given existing production capacity constraints, replenishing some stockpiles could take years—although the Trump administration has denied reports of a so-called 'severe shortage of ammunition stockpiles.' According to Pentagon officials and defense companies, supplies of minerals such as rare earths, tungsten, germanium, and scandium are essential for manufacturing precision-guided missiles, fighter jets, armored vehicles, infrared sensors, and other advanced weapons systems. Expected attendees include industry giants such as global mining giant Rio Tinto Group, Australia's BHP, US Freeport-McMoRan, US Mountain Pass Materials, US Rare Earths, US Energy Fuels, and Canada's Metals Company. According to sources, the Trump administration plans to announce multiple deals and memorandums of understanding.

  • US Regulators Systematically Review Chinese AI Firms' Third-Country Computing Power Leasing

    August 7 news, according to Bloomberg, people familiar with the matter revealed that the U.S. government department responsible for investigating chip export control violations is reviewing Chinese AI companies' leasing of computing power in third countries to obtain Nvidia advanced chips.