Ten Million Dollars Stolen - DeFi Platform MonoX Money Hack Analysis

慢雾科技 view 20037 2021-12-12 12:26
share to
Scan QR code with WeChat

According to Slow Fog Zone news on November 30, 2021, the DeFi MonoX Financial platform was attacked and approximately $ 18.2 million from WETH and $ 10.5 million from MATIC were stolen. Other hackers include WBTC, LINK, and GHST .; The total losses for DUCK, MIM and IMX were around $ 31 million. The SlowMist security team is the first to present a brief review and share:

base nres

The point of this argument is that the swap contract does not identify if the tokens exchanged by the pool and the tokens exchanged are the same, but using the negative value of the new exchange rate, when the attacker sends the same token, the symbolic value. counted and used twice, the value of the tokens continues to increase and the tokens are exchanged for other tokens in the pool to earn money.

Related information

MonoX is a new DeFi technology that uses the same unique design for liquid water. This is accomplished by integrating deposit tokens and stable vCASH into the virtual marketplace. Among them, the first single token liquidity pool application is Monoswap, an automated company that will start in October 2021.

Address of attacker 1:

0xecbe385f78041895c311070f344b55bfaa953258

Address of attacker 2:

0x8f6a86f3ab015f4d03ddb13abb02710e6d7ab31b

Attack contract 1:

0xf079d7911c13369e7fd85607970036d2883afcfd

Attack contract 2:

0x119914de3a03256fd58b66cd6b8c6a12c70cfb2

Attack Transaction 1:

https://etherscan.io/tx/0x9f14d093a2349de08f02fc0fb018dadb449351d0cdb7d0738ff69cc6fef5f299

Offensive chord 2:

https://polygonscan.com/tx/0x5a03b9c03eedcb9ec6e70c6841eaa4976a732d050a6218969e39483bb3004d5d

Strike details

1. First, the attacker calls Monoswap.swapExactTokenForToken.

0.1 TZS 79,986094311542621010 MONO.

2. Protesters benefit from the inability to remove resources for other pool users and get the most out of adding liquid to the pool.

The downside to removing runoff here is on Monoswap.sol lines 471-510. Once the effluents from the lake have been removed, the _removeLiquidityHelper function is called by the withdrawal Liquidity function, these two operations are called, it is referred to: Parameter ID proof allows direct removal of the liquid for each user of the pool.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

Remove the fluid from 0x7b9aa6 and replace 1670.7572297649224 MONO and 6.862171986812230290 vCASH for 0x7b9aa6.

Remove the fluid from cowrie.eth and send 152.9745213857155 MONO and 0.628300423692773565 vCASH to cowrie.eth.

Remove the fluid from 0xab5167 and replace 99940.7413658327 MONO and 410.478879590637971405 vCASH for 0xab5167.

To counter Contract 1, create a capital layer in the MONO token liquidity pool.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

3. The attacker then uses Monoswap.swapExactTokenForToken 55 times to further improve MONO's value.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

The key to this attack is the swapExactTokenForToken function in Monoswap.sol, where the attacker ignores the MONO token so that the tokenIn and the tokenOut are the same token.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

Follow the swapIn function.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

You can see that the swapIn function calls the getAmountOut function to calculate the value. Then follow the getAmountOut function to see if the _getNewPrice function is used to calculate tokenInPrice and tokenOutPrice.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

Follow the _getNewprice function, at this point counting the tokenInPrice, you will see that the txType parameter has exceeded the TxType.SELL.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

The TxType parameter is passed when the tokenOutPrice is calculated as TxType.BUY. Right now:

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

If the entry and exit tokens are the same token, it is easy to determine that the tokenOutPrice is greater than the tokenInPrice because the 4 count differences are equal.

Since tokenIn and tokenOut are the same token, the swapIn function counts the value and then calls the _updateTokenInfo function again, so that the tokenOutPrice update overwrites the tokenInPrice update, which increases the token value. no.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

4. Finally, the attacker calls the swapTokenForExactToken function to exchange the MONO for another token in the pool.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

In the swapTokenForExactToken function, call the swapOut function, and in the swapOut function, call the getAmountIn function to calculate a value.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

In this function, tokenInPoolPrice is the value of MONO tokens in the pool, and since this value has increased in the past, tokenInPrice becomes larger, so the final account value is smaller and the value is the same. is replaced by a smaller MONO. Many tokens in the pool such as WETH, WBTC, MONO, USDC, USDT, DUCK, MIM, IMX and more.

千万美元被盗 —— DeFi 平台 MonoX Finance 被黑分析

5. The attacker finally transfers the results of the strike to the address

0x8f6a86f3ab015f4d03ddb13abb02710e6d7ab31 ib.

The above is an analysis of the Ethereum keychain attacks, In addition to the Ethereum keychain attacks, the attackers carried out the same attacks on Polygon, and the attack is the same as the attack on Ethereum. Since this is a keychain, I won't go back too much here. To analyse.

According to statistics from SlowMist AML, MonoX Financial is around 2.1K WETH, 1.9M WMATIC, 36.1 WBTC, 143.4K MONO, 8.2M USDC, 9.1M USDT, 1.2K LINK, 3.5.1GHST, M DUCK, 4.MX9 and 4.1K. .

concludes

This attack takes advantage of the update rate problem by taking advantage of the fact that the swap contract does not identify tokens entering and leaving the pool. Since the exchange contract controls the cost of incoming and outgoing items, it was changed by a phone call. The same _upTokenInfo function, when the _upTokenInfo function is called the second time when the input and output tokens are the same token, the highest tokenOutPrice counted as the value will override the exchange value. It is used to further increase the value of the tokens in the pool, and finally, you can trade all the other tokens in the pool for a profit and exit the market.

btcfans公众号

Scan QR code with WeChat

Link
Disclaimer:

Tags: DeFi MonoX
Previous: Musk asked about Dogecoin's removal of Binance in a tweet, and the CEO of Binance responded. Next: Top 5 serious gambling dangers in game design. How to prevent and prevent?

Related