Cointime

Download App
iOS & Android

Analysis of Flash Loan Price Manipulation Attacks on the Themis Protocol

On June 28th, Beijing time, Themis protocol was targeted by a Flash Loan attack, with the attacker having gained approximately $370,000 in profits.

SharkTeam conducted a technical analysis of this incident promptly and has summarized security measures to be taken. It is hoped that future projects can learn from this and collectively strengthen the security defenses of the blockchain industry.

1. Incident analysis

Attacker address: 0xdb73eb484e7dea3785520d750eabef50a9b9ab33

Attack contract:

0x05a1b877330c168451f081bfaf32d690ea964fca

0x33f3fb58ea0f91f4bd8612d9f477420b01023f25

Attacked contract: 0x75f805e2fb248462e7817f0230b36e9fae0280fc

Attack transactions:

0xff368294ccb3cd6e7e263526b5c820b22dea2b2fd8617119ba5c3ab8417403d8

Attack process:

(1) The attacker (0xdb73eb48) borrowed 22,000 WETH through a Flash Loan.

(2) Subsequently, the attacker borrowed an additional 10,000 and 8,000 WETH from the UniswapV3Pool.

(3) Then, the attacker (0xdb73eb48) deposited 220 WETH and borrowed DAI, USDT, USDC, ARB, and WBTC separately.

(4) Furthermore, the attacker (0xdb73eb48) deposited another 220 WETH and borrowed DAI, USDT, USDC, ARB, and WBTC separately.

(5) The attacker (0xdb73eb48) added 55 WETH to the pool and obtained 54.6 wstETH.

(6) The attacker (0xdb73eb48) called the swap function and exchanged all 39,725 WETH for 2,423 wstETH.

(7) Then, taking advantage of the high price of wstETH, the attacker borrowed 317 WETH using only 54.6 wstETH.

Finally, the attacker (0xdb73eb48) exchanged wstEth back to WETH, returned the flash loan, and left the market with a profit.

2 Vulnerability Analysis

The essence of this attack is the manipulation of prices for two tokens in the pool using a Flash Loan. The proportion calculated by the oracle can be manipulated, leading to asset losses. The attacker's initial three steps involved exchanging WETH for various tokens while depositing WETH into the pool, increasing the pool's WETH balance. The crucial step was the sixth step, where over 30,000 WETH was exchanged, causing a significant issue with the ratio between wstETH and WETH in the pool. This distorted ratio led to an increased exchange ratio calculated by the oracle, allowing the attacker to borrow more WETH using a small amount of wstETH.

It is evident that there was a noticeable increase in the calculated results after exchanging WETH for wstETH.

3. Security Recommendations

In light of this attack incident, developers should adhere to the following considerations during the development process:

1. Conduct thorough validation to identify any potential price manipulation issues in the development of oracles and liquidity pools.

2. Consider implementing Time-Weighted Average Price (TWAP) algorithms within oracles to calculate token prices.

3. Prior to project deployment, seek technical assistance from professional third-party auditing teams.

Comments

All Comments

Recommended for you

  • Hassett: Confident Waller Will Assume Fed Chair Position in May

    Hassett, the Director of the National Economic Council at the White House, expects that Powell will not remain as a Federal Reserve governor. He is confident that Waller will assume the position of Fed Chair in May.

  • Becerra: It's Time to Submit the CLARITY Act for President Trump's Signature

    On April 9, U.S. Treasury Secretary Becerra stated that Congress has spent nearly five years attempting to pass a framework to ensure the future development of the financial industry. Now is the time for Senate Banking Republicans to review and submit the CLARITY Act for President Trump's signature.

  • Binance Officially Launches Prediction Market

    On April 9, Binance announced the launch of its prediction market, a new feature that allows users to participate in probability-based markets through integration with third-party platforms from the Binance app. The Binance wallet will integrate market access provided by Predict.fun, a leading on-chain prediction market provider on the BNB Smart Chain (BSC). In the Binance App, go to the [Markets] tab. Click on the [Prediction] tab (available only in supported regions). Select a category to browse available markets offering real-time probability pricing.

  • Iranian Military Spokesman: 'Prepared for Long-term War'

    According to the Iranian Students' News Agency on the 9th, the Iranian military spokesman expressed hope for reaching an agreement in the ceasefire negotiations, but stated that if the talks fail, 'we are also prepared for a long-term war.' The conditions proposed by Iran will serve as the basis for the negotiations. (Xinhua News Agency)

  • US Spot Bitcoin ETF Sees Net Outflow of $124.25 Million Yesterday

    On April 9, according to monitoring by Trader T, the US spot Bitcoin ETF experienced a net outflow of $124.25 million yesterday.

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

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

  • BTC Falls Below $71,000

    Market data shows that BTC has fallen below $71,000, currently priced at $70,997.18, with a 24-hour decline of 0.52%. The market is experiencing significant volatility, so please ensure proper risk management.

  • BTC Drops Below $71,000

    Market data shows that BTC has fallen below $71,000, currently priced at $70,989.94, with a 24-hour increase of 4.15%. The market is experiencing significant volatility, so please ensure proper risk management.

  • Ethereum Foundation Plans to Sell 5,000 ETH to Fund R&D, Grants, and Donations

    On April 8, the Ethereum Foundation announced on the X platform that it will exchange 5,000 ETH for stablecoins today using CoWSwap's TWAP feature, as part of its ongoing efforts to fund research and development, grants, and donations.

  • Web3 data and AI company Validation Cloud completes $10 million in new round of financing

     Web3 data and AI company Validation Cloud announced a $10 million financing round from True Global Ventures. The company plans to use the funds to expand its AI products and achieve seamless access to Web3 data.