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

  • Iranian Source: Breakthrough in Iran-US Negotiation Preparations Possible 'Tonight or Tomorrow'

    On April 23, an Iranian diplomatic source told RIA Novosti that preparations for negotiations between Iran and the United States in Pakistan may achieve a breakthrough 'tonight or tomorrow.' (Xinhua News Agency)

  • Anthropic's Secondary Market Valuation Reaches $1 Trillion, Surpassing OpenAI

    On April 23, Anthropic's valuation on private equity trading platforms like Forge Global has risen to around $1 trillion, surpassing OpenAI's $880 billion. It is reported that the valuation of this artificial intelligence startup has rapidly increased due to buyers competing to purchase the increasingly scarce secondary market shares of Anthropic. (Dongxin News Agency)

  • BTC Surpasses $78,000

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

  • Bitmine Allegedly Acquires 100,000 ETH Worth $233.7 Million

    On April 23, according to monitoring by Lookonchain, three new addresses suspected to be associated with Tom Lee's Bitmine (0xB6a8...9c9E, 0xc2e0...2831, 0x4e5C...276c) received 100,000 ETH from BitGo, valued at $233.7 million.

  • Musk: AI Chip Shortage Expected in the Future

    On April 23, Tesla CEO Elon Musk stated during an earnings call that the company initiated the Terafab chip factory project due to an anticipated severe shortage of AI chips in the future. He remarked, "In terms of industry growth rates, logic chips, and even more so storage chips, we expect to encounter bottlenecks if we do not manufacture chips ourselves. This is the reason for the birth of Terafab." (Dongxin News Agency)

  • US Spot Bitcoin ETF Sees Net Inflow of $331.9 Million Yesterday

    On April 23, according to monitoring by Trader T, the US spot Bitcoin ETF experienced a net inflow of $331.9 million yesterday.

  • US Spot Ethereum ETF Sees Net Inflow of $96.43 Million Yesterday

    On April 23, according to monitoring by Trader T, the US spot Ethereum ETF saw a net inflow of $96.43 million yesterday.

  • U.S. State Department Urges American Citizens to Leave Iran Immediately

    On April 23, the Bureau of Consular Affairs of the U.S. State Department posted on social media that, given Iran's announcement of partial airspace reopening, American citizens in Iran should leave immediately. The post advised U.S. citizens to stay informed about the situation through local media and to consult commercial airlines for information on flights departing Iran. Additionally, U.S. citizens can also travel by land to Armenia, Azerbaijan, Turkey, and Turkmenistan, but should avoid areas along the Iran-Afghanistan, Iran-Iraq, or Iran-Pakistan borders.

  • Tesla: Increasing Investment in AI Computing Power and Advancing New Battery and Material Factories

    On April 23, Tesla's official blog announced that the company is increasing its investment in AI computing power to advance the construction of new battery and battery materials factories. This move is also aimed at further preparing for the production of the third-generation Megapack energy storage system, the Tesla autonomous electric vehicle Cybercab, and the Tesla electric truck Semi.

  • USA: Deploying the Strongest Military Force in History to the Middle East

    On April 23, local time April 22, the U.S. Central Command announced that since the U.S. military began its blockade operations in the waters related to the Strait of Hormuz on April 14, it has requested 31 vessels to turn around or return to port as part of the blockade. The U.S. Central Command also stated that the military is currently deploying the most comprehensive and powerful military force ever seen across the Middle East.