The short analysis of the flashloan attack to the APE AirDrop
As reported by Will Sheehan, the APE token has been attacked by the MEVor. After the analysis, we think it’s due to the vulnerability that the AirDrop process of the APE token only considers the spot state, which can be manipulated by the attacker.
In particular, the attacker can borrow BYAC tokens that can be redeemed to NFTs, and then use these NFTs to claim the AirDrop. After that, the attacker mint the BYAC tokens using the BYAC NFTs to return the flashloan. However, the attacker got the AirDrop APE tokens through this process. We think this is similar to the flashloan based price manipulation attack, where a contract only consider the spot price of an asset (which can be manipulated.)
In the following, we will use the attack transaction to illustrate this process.
Step I: prepare the NFT for the fee of the flashloan
The attacker transferred 1060 NFT to the attack contract 0x7797. Note that, this NFT is not borrowed from the flashloan, but is brought with 106 ETH.
Step II: Borrow the BYAC tokens through flashloan
Step III: Use the NFTs to claim the APE tokens
Note that, during this process, the attacker has six NFTs. One is the 1060 he/she bought, and five ones that are redeemed using the borrowed BYAC tokens (in step II). In total, it gets 60,564 APE tokens.
Step IV: Mint the NFT to get BYAC tokens
The attacker minted the six NFTs to get the BYAC tokens. Note that, the attacker also minted his own NFT (1060) to pay the fees for flash loan. Since there are still BYAC tokens remained after paying back the flash loan (since he minted his own BYAC NFT 1060), the attacker swapped the remaining BYAC tokens for around 14 ETH.
In total, the attacker got 60,564 APE token, which worthed around 500K USD (at the time of writing this blog, the price of APE is $8 ). The cost is one NFT (106 ETH — 14 ETH), which is around 270K USD.
We think the issue here is that the AirDrop of APE token only considers the spot state that whether NFTs are hold by someone. This is fragile since the attacker can manipulate the spot state using flashloan. If the cost of the flashloan is smaller than the value of the AirDrop token, then it creates an attack opportunity that has shown in the attack.
Credit to Will Sheehan, who reported the transaction.
The BlockSec Team focuses on the security of the blockchain ecosystem, and collaborates with leading DeFi projects to secure their products. The team is founded by top-notch security researchers and experienced experts from both academia and industry. The core founder of the team has been recognized as the Most Influential Scholar Award (Rank 4 from 2012–2021), in the field of security and privacy. They have published multiple blockchain security papers in prestigious conferences, reported several zero-day attacks of DeFi applications, and released detailed analysis reports of high impact security incidents.