Canto Dex Oracle contest - cryptphi's results

Execution layer for original work.

General Information

Platform: Code4rena

Start Date: 07/09/2022

Pot Size: $20,000 CANTO

Total HM: 7

Participants: 65

Period: 1 day

Judge: 0xean

Total Solo HM: 3

Id: 159

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 32/65

Findings: 1

Award: $39.22

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Lines of code

https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-core.sol#L271-L289 https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-core.sol#L261

Vulnerability details

Impact

In BaseV1Pair contract, when calling sampleSupply(), a zero value for window argument , it will always return empty fixed sized array.

When window argument is 0, the for loop will be bypassed and sampleSupply() will return _totalSupply which is an empty array of n-points number of empty arrays.

Proof of Concept

https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-core.sol#L271-L289

  1. Call BaseV1Pair.sampleSupply() with inputs: points - 5 window - 0
  2. _totalSupply is now an array of fixed size 5.
  3. assume observations.length is 6.
  4. Then calculation of i will be: i = 5 - 0 = 5
  5. Since 5 is not less than 5, for loop is bypassed
  6. _totalSupply which is still list of empty arrays is returned.
  7. Additionally, this will also affect the result of totalSupplyAvg() and return 0 always

Tools Used

Manual review

A require check for zero value may be necessary to resolve this.

#0 - nivasan1

2022-09-10T18:07:01Z

It is unclear how the function / availability of the protocol is at risk here as a sample with window 0 is a no-op (no observations are being sampled).

#1 - 0xean

2022-09-12T14:21:07Z

downgrading to QA, wardens fails to show the impact of the issue.

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