Grim Finance Hack

Reported loss $30.0M
Fantom
Nested reentrancy through an attacker-controlled token callback; flash loan used for liquidity

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.

Technical root cause

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

  1. The vulnerable depositFor function accepted a caller-selected token address.
  2. 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.
  3. The attacker's token contract re-entered depositFor several times.
  4. In the last nested call, genuine LP tokens increased the vault balance.
  5. As the nested calls returned, several frames treated that one increase as their own deposit and minted shares repeatedly.
  6. The attacker redeemed the inflated shares, removed liquidity, repaid borrowed liquidity, and moved the remainder.

Protocol details

Classification Reentrancy / unvalidated token parameter
Protocol Type Yield
Affected asset / contract GRIM
Implementation language Solidity
Protocol links Website @financegrim

Security review history

Build your security review skills

Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.