ApeRocket Hack
What happened
On July 14, 2021, ApeRocket Finance, a yield aggregator built on ApeSwap, was hit by two flash loan attacks a few hours apart: one on its BNB Chain vaults and one on its Polygon fork. In both cases the attacker briefly owned more than 99% of a vault, inflated the vault's apparent profit, and collected nearly all of the performance-fee reward tokens the protocol minted in response. The combined loss was about $1.26 million, roughly $260,000 (883 BNB) on BNB Chain and $1 million (521 ETH) on Polygon, and the SPACE token fell about 63%. ApeRocket stopped minting SPACE and announced compensation, including a new token for pSPACE holders and buybacks.
On Polygon, the root cause was that deposit() in ApeSwap's MiniApeV2 (a fork of SushiSwap's MiniChefV2) accepts deposits on behalf of any address, unlike a regular MasterChef v1. The attacker used this to credit a large LP position to ApeRocket's DAI-MATIC vault, which the vault then counted as profit.
Polygon attacker: 0xfabd1c2f4f16f2f6e2007abbed5549c84d82c19d
Polygon attack transaction (July 14, 2021, 08:14 UTC): 0x377fb92f6e04db4bf5a0917a79d171ce27b28deaa23594b7fc498dd080cf9d35
How it happened
- On BNB Chain (about 04:30 UTC), the attacker flash-borrowed CAKE, took over 99% of ApeRocket's CAKE vault, sent a large amount of CAKE to the vault and called
harvest(). The vault treated the CAKE as profit and minted SPACE rewards, almost all of which went to the attacker. - On Polygon (the attack transaction landed at 08:14 UTC), the attacker used flash-loaned DAI and MATIC to create a large amount of DAI-MATIC LP and deposited part of it into ApeRocket's DAI-MATIC vault, taking more than 99% of its shares.
- It then deposited more LP into ApeSwap's MiniApeV2 on behalf of the vault, which MiniApeV2's
deposit()allows for any address. - The vault counted that extra LP as profit and minted pSPACE as a performance reward, almost all of which went to the attacker as the majority shareholder.
- The attacker sold the pSPACE, repaid the flash loans and left with about 521 ETH; SPACE dropped about 63% after the dumps.
Protocol details
Security review history
- PeckShield View report
Evidence
- report Report google.com
- transaction Polygonscan transaction 0x377fb92f6e04db4bf5a0917a79d171ce27b28deaa23594b7fc498dd080cf9d35 polygonscan.com
- address polygonscan.com address 0xfabd…c19d polygonscan.com
- analysis Website reference aperocket.medium.com
- analysis Website reference watchpug.medium.com
- analysis Website reference watchpug.medium.com
- analysis DeFiLlama defillama.com
- analysis DeFi Yield Farming Aggregator ApeRocket Suffers $1.26M 'Flash Loan' Attack coindesk.com
- analysis Jul 2021 - Ape Rocket Finance Reward Bug - $1.26m (Global) quadrigainitiative.com
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.