Memestake deflation model lightning loan attack analysis
event background
On July 20, Beijing time, it was reported that the Memestake project under the Sanshu project party suffered a flash loan attack, and the loss was as high as more than 100,000 US dollars.Know Chuangyu Blockchain Security LabKnow Chuangyu Blockchain Security Lab
A retrospective analysis of this incident was carried out.
Attack time:
2021-07-20 19:23:20
Attacker address:
0x0333E323E61aa8aFA38A1623604A165dCB9F4fEC
Attack transaction hash:
a):https://etherscan.io/tx/0x628174eccf05e94a3385f882805124b5d8718a0c9906c6cd0c573e5d6f56c9d2
b):https://etherscan.io/tx/0x00edd68087ee372a1b6e05249cc6c992bb7b8478cc0ddc70c2a1453428285808
c):https://etherscan.io/tx/0xa945b1857630e730bd3fac6459c82dee44da45e35cfbbd6dfb7b42146e8dde41
event analysis
event analysis
As shown in the figure above, the attacker launches an attack according to the attack transaction a->b->c process and leaves the market with a profit. The attack review is as follows:
1. As shown in transaction a, the attacker first uses weth to exchange 2091514065454 KEANU tokens from uniswap and mortgages them into the Memestake contract (0x35C674C288577Df3e9b5dafEF945795b741c7810).
2. As shown in transaction b, the attacker borrows KEANU tokens by using the flash loan, and continuously calls the deposit and withdraw functions of the Memestake contract to consume the KEANU tokens of the Memestake contract, and here is the exploit point of the vulnerability: the KEANU token The currency is a deflation model token, that is, each transaction will deduct 2% of the tokens to distribute dividends to other currency holders.
However, the deposit and withdraw functions in Memestake record the value paid by the transfer initiator, that is, the user mortgages 100 KEANU tokens, and only 98 KEANU tokens actually arrive in the contract, but 100 KEANU tokens are still returned to the user when withdrawing KEANU tokens, so as the attacker keeps staking and withdrawing, the KEANU token balance of the contract is getting smaller and smaller.
3. As shown in transaction c, the attacker calls the withdraw function to take out the MFUND token generated by the first mortgage, and returns the KEANU token borrowed in the second step of the flash loan, and then swaps the huge amount of MFUND tokens into WETH and SANSHU Token arbitrage is out.
event summary
event summary







