Sitemap

SlowMist: An Analysis of the Attack on DODO (Released in 2021)

4 min readMay 8, 2023

--

Press enter or click to view image in full size

According to reports, the decentralized trading platform DODO’s wCRES/USDT V2 liquidity pool was attacked by hackers, who transferred nearly $980,000 worth of wCRES and nearly $1.14 million worth of USDT. DODO has stated that the team has taken down the affected pool’s entry point, and the attack only impacts the DODO V2 crowd pool. Apart from the V2 crowd pool, all other pools remain secure. The team is currently collaborating with security firms to investigate the incident and working diligently to recover some of the funds. For more updates, please stay tuned to DODO’s official community announcements.

The SlowMist Security Team immediately followed up and analyzed the incident, and the details are provided below for your reference.

Attack Details Analysis

By examining the attack transaction, we can see that the entire attack process is quite simple. The attacker first transferred FDO and FUSDT tokens into the wCRES/USDT liquidity pool. Then, the attacker used the pool contract’s flashLoan function to borrow wCRES and USDT tokens and initialized the pool contract.

Press enter or click to view image in full size

Why can the attacker successfully borrow wCRES and USDT after depositing FDO and FUSDT tokens, and also initialize the liquidity pool contract? Is it because there is a vulnerability in the pool’s flash loan feature?

Next, let’s analyze the flashLoan function in detail:

Press enter or click to view image in full size

Upon analyzing the specific code, we can see that during the flash loan, the funds are transferred out through the _transferBaseOut and _transferQuoteOut functions. Then, the DVMFlashLoanCall function is used for specific external logic calls, and finally, the contract funds are checked. We can see that this is a normal flash loan feature, so the problem must lie in the execution of external logic during the flash loan.

By analyzing the external logic call of the flash loan, we can find that the attacker called the init function of the wCRES/USDT liquidity pool contract and passed in the FDO address and FUSDT address to initialize the liquidity pool contract.

Press enter or click to view image in full size

At this point, we can see that the liquidity pool contract can be re-initialized. To get to the bottom of this, let’s analyze the initialization function in detail:

Press enter or click to view image in full size

Upon examining the code in detail, we can see that the liquidity pool contract’s initialization function has no authentication or logic to prevent repeated calls to the initialization. This means that anyone can call the initialization function on the liquidity pool contract and re-initialize the contract. At this point, we can deduce the complete attack process for this incident.

Attack Process

1. The attacker first creates FDO and FUSDT token contracts and deposits FDO and FUSDT tokens into the wCRES/USDT liquidity pool.

2. Next, the attacker calls the flashLoan function of the wCRES/USDT liquidity pool contract to borrow wCRES and USDT tokens from the pool.

3. Since the init function of the wCRES/USDT liquidity pool contract lacks any authentication and logic to prevent repeated initialization calls, the attacker uses the external logic execution feature of the flash loan to call the initialization function of the wCRES/USDT liquidity pool contract, replacing the token pair from wCRES/USDT to FDO/FUSDT.

4. As the liquidity pool’s token pair is replaced with FDO/FUSDT and the attacker had already deposited FDO and FUSDT tokens into the pool contract at the beginning of the attack, they ultimately pass the balance check for returning the flash loan funds and make a profit.

Summary

The main reason for this attack is that the liquidity pool contract’s initialization function lacks any authentication and restrictions to prevent repeated initialization calls. This allowed the attacker to borrow real tokens through a flash loan, then re-initialize the contract to replace the liquidity pool’s token pair with fake tokens created by the attacker, thereby bypassing the flash loan fund repayment check and pocketing the real tokens.

Reference attack transaction

About SlowMist

SlowMist is a blockchain security firm established in January 2018. The firm was started by a team with over ten years of network security experience to become a global force. Our goal is to make the blockchain ecosystem as secure as possible for everyone. We are now a renowned international blockchain security firm that has worked on various well-known projects such as Huobi, OKX, Binance, imToken, Crypto.com, Amber Group, Klaytn, EOS, 1inch, PancakeSwap, TUSD, Alpaca Finance, MultiChain, O3Swap, etc.

Website:
https://www.slowmist.com
Twitter:
https://twitter.com/SlowMist_Team
Github:
https://github.com/slowmist/

--

--

SlowMist
SlowMist

Written by SlowMist

SlowMist is a Blockchain security firm established in 2018, providing services such as security audits, security consultants, red teaming, and more.