Process
Potential Integrations Review
Last updated:
April 28, 2022

Smart contract auditing does not only rely on the quality of the code being analyzed, it's also important to consider risks that could arise from other integrations.

For example, if a function in your contract could be used as a price oracle by other protocols, it could lead to vulnerabilities in those protocols. Notably, C.R.E.A.M. finance used Yearn vault functions as a price oracle for collateral valuation and suffered a flash loan exploit detailed here.

Classes of integration risks to consider

  • Using your protocol as an oracle
  • Using your protocol in a flash loan based attack (related to the above)
  • Using your protocol in a MEV/sandwich attack (also related to the above)

Using your protocol as an oracle

If your protocol produces assets according to a standard interface (e.g., ERC20 tokens, ERC4626 vaults), other protocols may attempt to price these assets using your public interface. Lending markets, derivatives issuers, linear AMM pools and other protocols use oracles to add assets to their system which may expose certain risks if your oracle price is manipulable.

Ideally, if you intend for other contracts to use an external function to price your asset, review if the function can be manipulated in malicious ways by depositors/users of your protocol and document accordingly. For example, the new ERC4626 standard explicitly cautions against using preview functions on its implementations as a price oracle.

Using your protocol in a flash loan based attack

Flash loan attacks involve a market participant minting a large number of assets from a protocol that supports flash lending or flash minting and then using those funds to manipulate prices or conditions on other protocols. Aside from oracle price considerations, flash loans can also break certain assumptions (for example, it is dangerous to assume that a user's token holding cannot reach a certain value if the token can be minted in the full possible range of values using a flash loan.

Using your protocol in a MEV/sandwich attack

MEV refers to Maximal Extractable Value and is well detailed here. It is important to consider how manipulating transaction ordering could impact your protocol and users as well as other protocols using it and their users.

See Also: