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.
Case & protocol details
Attack Timeline
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.
Evidence & learning
Attack pattern
Compare incidents →Proof of concept
1 availableSources and on-chain records
- report Post-mortem rekt.news
- report Report twitter.com
- report Post-mortem medium.com
- transaction Transaction ftmscan.com
- transaction Transaction sharkteam.org
- analysis Website reference cointelegraph.com
- analysis Website reference twitter.com
- analysis Website reference twitter.com
- analysis Website reference twitter.com
- analysis Explained: The Grim Finance Hack (December 2021) halborn.com
Practice this exploit pattern safely
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.