Skip to content
Write-up Advanced

Hack Analysis The Hundred Finance Heist March 2022

Hundred Finance, a Compound fork on Gnosis Chain, sent borrowed tokens before updating the borrower's debt, and the bridged tokens triggered a callback on transfer. An attacker used that callback to reenter the protocol and borrow again before the first debt was recorded, draining about $6m of liquidity.

immunefi.com

Published on immunefi.com

Hundred Finance and Agave, lending protocols on the Gnosis Chain, were hit by reentrancy attacks on March 15 this year. These attacks drained the protocols of all collateral.

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The protocol transferred borrowed tokens before updating the borrower's debt, and the non-standard bridged token invoked a callback on the recipient during that transfer, allowing reentrancy.

Impact

The attacker drained about $6m of available liquidity from Hundred Finance's Gnosis deployment, as the text states the attack drained the protocols of all collateral.

What the attacker needed

Gnosis Chain deployment; bridged tokens with transfer callback; flash loan capital available

The fix

The text does not state a specific fix but implies that following the checks-effects-interactions pattern and using reentrancy guards would prevent the issue.

How it was found

  1. Take a flash loan of USDC from a SushiSwap pair.
  2. Deposit the borrowed USDC as collateral in Hundred Finance's USDC market.
  3. Borrow USDC against that collateral.
  4. When the borrowed USDC transfer triggers the token callback, reenter and borrow xDai from another market before the debt is recorded.
  5. Swap the xDai for USDC on Curve.
  6. Repay the flash loan with its fee and keep the remaining USDC as profit.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A lending protocol lets you deposit collateral and borrow other tokens against it. Here, the protocol handed over the borrowed tokens before writing down that you owed them, and the token itself called back into the attacker's contract during that handover. The attacker used that moment to borrow again, so the protocol lost track of how much was owed and was drained.

Similar reports

Same bug class and techniques, clearest first.