Hack Analysis Omni Protocol July 2022
Omni Protocol's NFT money market contracts lacked reentrancy locks and did not follow the checks-effects-interactions pattern, so the ERC721 safeTransferFrom callback could reenter the pool during withdrawal and liquidation. An attacker used two contracts to make the market forget a user's collateral and borrow against it, stealing about $1.4M.
immunefi.com
Published on immunefi.com
Omni, an NFT money market platform, was the victim of a $1.4M hack on July 10, 2022, which exploited a reentrancy vulnerability on its Ethereum smart contracts.
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 pool's withdrawal and liquidation functions called the ERC721 safeTransferFrom (which hands execution to the receiver) before updating the user's collateral configuration, and had no reentrancy guard.
What the attacker needed
Flashloan access; NFTX vault with Doodles NFTs; attacker contracts deployed
How it was found
- Flashloan WETH from Balancer.
- Flashloan vTokens from a Doodles NFTX vault.
- Swap some WETH for more vTokens on SushiSwap.
- Redeem vTokens for 4 Doodles NFTs on the NFTX vault.
- Create a malicious DebtTaker contract and transfer the NFTs to it.
- DebtTaker supplies 3 NFTs as collateral, borrows WETH, then withdraws 2 NFTs to the Liquidator, triggering the reentrancy.
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 reentrancy bug is when a contract calls out to another contract, and that other contract calls back into the first one before it has finished updating its records. Here the pool sent NFTs to the attacker's contract, which immediately called back into the pool while the pool still thought the attacker had collateral. That let the attacker borrow money the pool should never have allowed.