Grim Finance Hack
What happened
On December 18, 2021, an attacker drained Grim Finance's Fantom yield vaults through the vault share-minting path. The attacker supplied a malicious token contract to GrimBoostVault.depositFor, then used that token's safeTransferFrom callback to re-enter the function before the outer calls completed. Each nested call observed an earlier pool balance, while the final call introduced the real LP tokens.
When execution unwound, the vault minted shares repeatedly against the same balance increase. Those excess vault shares could be redeemed for more SpiritSwap LP tokens than the attacker had deposited. Contemporary reporting and the project's public statements put the loss at more than, or about, $30 million.
GrimBoostVault.depositFor trusted a caller-provided token contract and made its external safeTransferFrom call before completing share-accounting state. A malicious token re-entered the function, allowing multiple frames to mint shares from one genuine LP-token balance increase.
How it happened
- The vulnerable depositFor function accepted a caller-selected token address.
- It took a pool-balance snapshot, invoked safeTransferFrom on that supplied address, then calculated the received amount from the later balance and minted vault shares.
- The attacker's token contract re-entered depositFor several times.
- In the last nested call, genuine LP tokens increased the vault balance.
- As the nested calls returned, several frames treated that one increase as their own deposit and minted shares repeatedly.
- The attacker redeemed the inflated shares, removed liquidity, repaid borrowed liquidity, and moved the remainder.
Protocol details
Security review history
- Solidity Finance View report
- CertiK View report
Evidence
Proof of concept
1 availableSources
- report Post-mortem rekt.news
- report @RugDocIO incident report twitter.com
- report @financegrim incident report twitter.com
- report @k3mmio incident report twitter.com
- report @peckshield incident report twitter.com
- report Grim Finance Update to Exploit medium.com
- transaction Grim Finance exploit transaction ftmscan.com
- transaction Grim Finance transaction analysis sharkteam.org
- analysis Website reference cointelegraph.com
- analysis DeFiLlama defillama.com
- analysis Explained: The Grim Finance Hack (December 2021) halborn.com
Understand the attack patterns
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.