Y2k Finance contest - R2'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: 21/110

Findings: 5

Award: $544.98

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

36.6124 USDC - $36.61

Labels

bug
duplicate
3 (High Risk)
resolved
sponsor confirmed
satisfactory

External Links

Lines of code

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

Vulnerability details

Impact

Errors in price calculation can lead to false positive unpegging.

  1. Here you calculating nowPrice:
if (price1 > price2) { nowPrice = (price2 * 10000) / price1; } else { nowPrice = (price1 * 10000) / price2; }

So the nowPrice will be less then 1e4

  1. Then you are dividing nowPrice to 1e6:
nowPrice / 1000000

But if priceFeed1.decimals() == 18, nowPrice / 1000000 == 0 So then anyone can trigger unpeg, even if it's not true

  1. Then in Controller.getLatestPrice() you are multiplying price to 10**(18-(priceFeed.decimals())) again It can lead to error too https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Controller.sol#L299

Tools Used

vs code

Use base points instead of strikePrice, e.g. strikeDifferenceBsp = 200 - 2% difference between prices -> unpeg And fix point 1, 2 and 3 above It can help you to prevent math errors

#0 - HickupHH3

2022-10-17T10:44:16Z

dup of #195

Findings Information

🌟 Selected for report: csanuragjain

Also found by: Lambda, R2, bin2chen, datapunk, rbserver, unforgiven

Labels

bug
duplicate
3 (High Risk)
edited-by-warden
satisfactory

Awards

300.0094 USDC - $300.01

External Links

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L203

Vulnerability details

Impact

In Vault.withdraw() you have modifier epochHasEnded(). But it's just checking time, no check if Controller already called triggerDepeg() or triggerEndEpoch()

So anyone can frontrun Controller transactions and withdraw their funds before without losses. For example risker can frontrun trx and withdraw funds in case of triggerDepeg() without funds loss

entitledAmount = // @audit-ok high сначала делим - разве это не приведет к проблемам amount.divWadDown(idFinalTVL[id]).mulDivDown( idClaimTVL[id], 1 ether ) + amount;

So he will save his funds and get amount back

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L203

Tools Used

vs code

Add explicit var, tells that epoch already ended by Controller. And only after that allow users to withdraw funds

#0 - 3xHarry

2022-09-22T10:37:30Z

dup #421

#1 - HickupHH3

2022-10-18T06:37:02Z

dup #69

#2 - Ruslan2702

2022-11-16T03:05:50Z

Hi guys! No 'Confirmed' label here, is it ok? @HickupHH3

#3 - HickupHH3

2022-11-16T04:12:06Z

@Ruslan2702 yes it's ok, it's been marked as a dup.

Findings Information

🌟 Selected for report: Lambda

Also found by: Deivitto, R2, Rolezn, csanuragjain

Labels

bug
duplicate
2 (Med Risk)
sponsor disputed
partial-25

Awards

155.5605 USDC - $155.56

External Links

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/2175c044af98509261e4147edeb48e1036773771/src/Vault.sol#L167

Vulnerability details

Impact

You are sending tokens and then mint the same count of tokens But in case of tokens with fee (e.g. USDT) or deflationary tokens, that logic can lead to problems Because you will receive less tokens then sended

Tools Used

vs code

Check token balances diff to check how much tokens you received

#0 - HickupHH3

2022-10-31T14:19:21Z

partial credit because Vault uses WETH only. It however applies to SemiFungibleVault. dup #221

1. Use entitledShares -= feeValue instead of entitledShares = entitledShares - feeValue

2. PegOracle.decimals is unused

3. No need to duplicate oracle1 and priceFeed1 in PegOracle. Because

priceFeed1 = AggregatorV3Interface(_oracle1)
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