Cointime

Download App
iOS & Android

A Detailed Analysis of Euler Finance’s $197 Million Flash Loan Attack

Validated Project

On 13 March 2023 at 08:56:35 AM +UTC, DeFi lending protocol Euler Finance experienced a Flash Loan Attack.

Euler Finance is a protocol that operates as a permissionless lending protocol. Its primary goal is to facilitate lending and borrowing of various cryptocurrencies for users. The UK-based tech startup utilizes mathematical principles to develop non-custodial protocols on Ethereum and other blockchain networks, with a focus on achieving high performance.

Based on on-chain data analysis, the attacker has successfully executed multiple transactions resulting in the theft of approximately $197 million, making it the largest hack of 2023 thus far. Stolen assets include several million worth of DAI, USDC, Staked Ether (StETH), and Wrapped Bitcoin (WBTC).

The breakdown of the stolen assets are as follows:

Detailed Analysis

The attack was possible due to a lack of liquidity checks in the donateToReserves function of the Etoken. The attacker executed multiple calls with different currencies to generate profit, resulting in a massive loss of $196 million across six different tokens. Currently, the funds remain in the attacker’s account.

The attacker’s address is: https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db

The attacker’s contract address is: https://etherscan.io/address/0x036cec1a199234fc02f72d29e596a09440825f1c

One of the attack transactions can be found here: https://etherscan.io/tx/0xc310a0affe2169d1f6feec1c63dbc7f7c62a887fa48795d327d4d2da2d6b111d

1. The attacker first borrowed 30 million DAI through a flash loan from Aave and then deployed two contracts: one for lending and one for liquidation.

2. The attacker then called the deposit function and pledged 20 million DAI to the Euler Protocol contract, receiving 19.5 million eDAI in return.

3. The Euler Protocol allows users to borrow up to 10 times their deposit by calling the mint function. The attacker leveraged this capability to borrow 195.6 million eDAI and 200 million dDAI.

4. The attacker called the repay function using the remaining 10 million DAI borrowed through the flash loan to repay their debt and destroy 10 million dDAI. They then proceeded to call the mint function again to borrow 195.6 million eDAI and 200 million dDAI.

5. The attacker then called the donateToReserves function and donated 10 times the amount needed to repay their debt, sending 100 million eDAI. They then called the liquidate function to initiate the liquidation process and obtained 310 million dDAI and 250 million eDAI.

6. The attacker called the withdraw function and obtained 38.9 million DAI, which they used to repay the 30 million DAI borrowed through the flash loan. They profited 8.87 million DAI from the attack.

Core Vulnerability

First, let’s take a look at the donateToReserves function, which is where users become vulnerable to liquidation.

Comparing the donateToReserves function to the mint function in the diagram below, we can see that a key step, checkLiquidity, is missing from the donateToReserves function.

Next, we followed up and examined the implementation of checkLiquidity. We discovered the Call InternalModule function, which calls the RiskManager to check and ensure that Etoken > Dtoken for the user.

It is necessary to check the user’s liquidity each time an operation is performed by calling checkLiquidity.

However, the donateToReserves function does not execute this operation, allowing users to first put themselves in a state of liquidation through certain functions of the protocol, and then complete the liquidation.

Attack Reproduction

The Numen Cyber Lab’s team has managed to reproduce the attack.

You may find out more details on the PoC at https://github.com/numencyber/SmartContractHack_PoC/tree/main/EulerfinanceHack

Conclusion

Euler Finance have confirmed the attack on their official Twitter (@eulerfinance) and have stated that they are currently collaborating with security professionals and law enforcement to address the issue.

The recent attack on the Euler Finance protocol highlights the importance of implementing rigorous security measures, such as conducting thorough audits and regularly checking for vulnerabilities.

As the decentralized finance ecosystem continues to grow, it is crucial for projects to prioritize the security of their users’ funds and adopt best practices to mitigate the risk of similar attacks in the future.

Note

This article was originally posted on our website’s blog. Subsequent articles will be posted first on our website and Medium after a slight delay.

Please stay tuned and follow our Twitter @numencyber for any future updates.

Comments

All Comments

Recommended for you

  • BTC Drops Below $78,000

    Market data shows that BTC has dropped below $78,000, currently priced at $77,975.08, with a 24-hour increase of 2.65%. The market is experiencing significant volatility, so please ensure proper risk management.

  • ETH Surpasses $2400

    Market data shows that ETH has surpassed $2400, currently priced at $2400.69, with a 24-hour increase of 3.61%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Iranian Media Confirms Receipt of 'Some Signals' from the U.S. to Lift Blockade

    On April 22, according to Iran's Tasnim News Agency, an Iranian envoy stated that Iran is prepared to negotiate once the U.S. lifts its maritime blockade. The Iranian state media released a video featuring Amir Saeed Iravani, Iran's permanent representative to the United Nations, who indicated that Tehran is ready to engage in talks immediately after the U.S. ends its maritime blockade, emphasizing that Washington must first cease its 'violations of the ceasefire agreement.' Following the report, the market reacted swiftly, with gold and silver prices rising briefly, while the dollar and crude oil prices fell. Previously, media outlets such as the Associated Press and RIA Novosti had reported the ambassador's statements, but this is the first report from Iranian state media linked to the Islamic Revolutionary Guard Corps.

  • Dollar Index DXY Drops 10 Points, Currently at 98.28

    Market data shows that the Dollar Index DXY has dropped 10 points in the short term, currently reported at 98.28.

  • BTC Surpasses $78,000

    Market data shows that BTC has surpassed $78,000, currently priced at $78,008, with a 24-hour increase of 2.79%. The market is highly volatile, so please ensure proper risk management.

  • Iran Receives 'Certain Signs' Indicating US Prepared to Lift Sanctions

    On April 22, according to Iran's Tasnim News Agency: Iran has received 'certain signs' indicating that the United States is prepared to lift sanctions. (Jinshi)

  • Iran Implements Maritime Enforcement on Container Ship Ignoring Warnings

    According to Iran's Tasnim News Agency: Iran has stated that it has implemented maritime enforcement on a container ship that ignored warnings. (Jinshi)

  • Expert: Trump's Hostility Towards Iran Has Deep Roots; US-Israel Leadership Lacks Historical Foundation and Acumen

    On April 22, according to Al Jazeera, Brian Clark, Director of Defense Concepts at the Hudson Institute in Washington, stated: "Trump has expressed disdain for the Iranian leadership for many years, and he seems to have been seeking a legacy initiative that could permanently change Iran, making it at least a 'neutral or even friendlier country towards the US.' Therefore, from this perspective, it is indeed not a new goal he suddenly started pursuing. The leadership of the US and Israel believes that now might be the time to finally subdue the Iranian regime, as it is in a passive position. However, this may reflect a lack of historical foundation and acumen in the US-Israel leadership, as Iran is not a country that can easily have its existing leadership structure overthrown." (Jinshi)

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

    On April 22, according to monitoring by Trader T, the US spot Ethereum ETF recorded a net inflow of $43.36 million yesterday.

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

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