Immunefi
Published in

Immunefi

Hack Analysis: Omni Protocol, July 2022

Introduction

Background

Root Cause

Snippet 1: safeTransferFrom function from solmate’s ERC721
Snippet 2: From Omni Pool code, SupplyLogic.sol
Snippet 3: From Omni Pool code, LiquidationLogic.sol
Snippet 4: From Omni Pool code, LiquidationLogic.sol

Proof of Concept

The Attack

Snippet 5: the start of our attack contracts.
Snippet 6: Flashloan from Balancer
Snippet 7: Flashloan from Doodles NFTX vault.
Snippet 8: Swap some WETH for vTokens on SushiSwap.
Snippet 9: Taking debt upon DebtTaker.
Snippet 10: Supply collateral to the Pool, and borrow
Snippet 11: Withdraw some collateral to Liquidator
Snippet 12: First stages of onERC721Received
Snippet 13: Use liquidation callback to reenter
Snippet 14: Borrow as much as possible, because it will all be forgiven.
Snippet 15: Withdraw all collateral.

Conclusion

Snippet 16: full attack contract.

--

--

Immunefi is the premier bug bounty platform for smart contracts and DeFi projects, where security researchers review code, disclose vulnerabilities, get paid, and make crypto safer. Immunefi removes security risk through bug bounties and comprehensive security services.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Immunefi

Immunefi is the premier bug bounty platform for smart contracts, where hackers review code, disclose vulnerabilities, get paid, and make crypto safer.