Y2k Finance contest - auditor0517's results

A suite of structured products for assessing pegged asset risk.

General Information

Platform: Code4rena

Start Date: 14/09/2022

Pot Size: $50,000 USDC

Total HM: 25

Participants: 110

Period: 5 days

Judge: hickuphh3

Total Solo HM: 9

Id: 162

League: ETH

Y2k Finance

Findings Distribution

Researcher Performance

Rank: 58/110

Findings: 2

Award: $73.23

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

36.6124 USDC - $36.61

Labels

bug
duplicate
3 (High Risk)
satisfactory

External Links

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/oracles/PegOracle.sol#L78

Vulnerability details

Impact

Wrong calculation of nowPrice in PegOracle.latestRoundData.

PegOracle.latestRoundData always returns nowPrice = 0 for normal 18 decimals tokens.

Proof of Concept

From the below formula, we can see nowPrice <= 10000.

File: 2022-09-y2k-finance\src\oracles\PegOracle.sol 67: if (price1 > price2) { 68: nowPrice = (price2 * 10000) / price1; 69: } else { 70: nowPrice = (price1 * 10000) / price2; 71: }

After that, it's divided by 1e6 here and it will be 0 for normal 18 decimals tokens.

Tools Used

Manual Review

We should change nowPrice / 1000000 to nowPrice / 10000.

#0 - 3xHarry

2022-09-21T12:27:21Z

@MiguelBits seems to be valid

#1 - HickupHH3

2022-10-17T10:41:35Z

dup of #195

Low Risk Issue

[L-01] Check address(0) before transfer funds (onlyAdmin functions)

[L-02] require() should be used instead of assert()

Non-critical Issues

[N-01] Typo

0.5% = multiply by 1000 then divide by 5 => 0.5% = multiply by 5 then divide by 1000.

[N-02] Open TODOs

[N-03] Event is missing indexed fields

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