Connext Amarok contest - cmichel's results

The interoperability protocol of L2 Ethereum.

General Information

Platform: Code4rena

Start Date: 08/06/2022

Pot Size: $115,000 USDC

Total HM: 26

Participants: 72

Period: 11 days

Judge: leastwood

Total Solo HM: 14

Id: 132

League: ETH

Connext

Findings Distribution

Researcher Performance

Rank: 49/72

Findings: 1

Award: $195.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Oracle price from DEX can be manipulated

Lines of code

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/helpers/ConnextPriceOracle.sol#L99

Vulnerability details

Impact

The ConnextPriceOracle.getPriceFromDex function divides the balances of the two token pairs to compute the price. There are several issues with it:

  1. This only returns the spot price which can easily be manipulated through flash loans. This is okay if the price oracle contract is only used off-chain
  2. It only works with specific AMMs like Uniswap that keep both balances in the contract. Also, any fees that are in the contract are used as part of the price computation but they should not.
  3. It uses the balance instead of the reserve data. For many Uniswap-like AMMs, the balance can be manipulated by sending tokens directly to the contract, and then reclaimed later through a skim. The reserve should be used instead.
POC
  • Attacker sends a large amount of base tokens to a Uniswap V2 pool.
  • The getPriceFromDex computes the token price as baseBalance denominated in token / tokenBalance. As the baseBalance is increased, the tokenPrice is increased as well.
  • Attacker calls skim on the pool to get back their balance.

The price from DEX function is not suited for any on-chain queries. For off-chain queries it can also be manipulated as it uses balance instead of reserves - which can be claimed back at a future block although this comes with risk.

#0 - 0xleastwood

2022-08-14T00:19:51Z

This contract is not being actively used in the codebase. I'm downgrading this to QA because it may be integrated in the future.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter