Y2k Finance contest - rokinot'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: 34/110

Findings: 3

Award: $169.47

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: rbserver

Also found by: 0x1f8b, cccz, eierina, rokinot, unforgiven

Labels

bug
duplicate
2 (Med Risk)
satisfactory

Awards

116.6703 USDC - $116.67

External Links

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L287-L289

Vulnerability details

Impact

The protocol is open to an administrator's maliciousness.

Proof of Concept

As we can see in this line, the contracts in this project has some sanity checks even for admin only calls.

However, the administrator is free to change a hedge/risk pair timewindow whenever he wants in VaultFactory.sol. This allows him to manipulate when deposits can be done due to this modifier, as long as the period is lower than the epoch begin. An admin could either re-open deposits by lowering the timewindow (which I assume is done by design) but can also block deposits altogether by increasing the timewindow to at least block.timestamp - idEpochBegin[id]

Tools Used

Code reading

Add a custom error to revert the code if the timewindow is too large

error TimewindowTooLarge(); ... if( _timewindow <= block.timestamp ) revert TimewindowTooLarge();

#0 - HickupHH3

2022-10-31T14:27:51Z

dup #60

Low

Market index 0 is skipped

The first market index is number 1, rather than 0. https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/VaultFactory.sol#L195

Non-critical

Open TODO comment

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L196

StakingRewards.sol is using the SafeMath library

Standard mathematical operations reverts if an invalid operation occurs in solidity ^0.8, which means the library is deprecated.

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/StakingRewards.sol#L4

Missing _name dev parameter

Function takes 7 arguments, however the @dev comment for _name is missing

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/VaultFactory.sol#L169-L174

#0 - HickupHH3

2022-11-07T00:08:53Z

Market index 0 is skipped

This is NC, not a biggie if 1-indexed instead of 0-indexed.

Missing _name dev parameter

Highlighted the specific param that was missing for incomplete natspec. Thus, low issue, and a satisfactory rating

Solmate's reentrancy guard is cheaper than OZ's.

Since the project is already using some solmate libraries, it may save some gas by using their reentrancy guard as well.

https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L10

#0 - HickupHH3

2022-11-08T15:47:51Z

Surprisingly about 3.8k gas saved minimally. Unique find too! Example of some test gas diffs:

testControllerZeroAddress() (gas: -22863 (-0.131%)) testAllMarketsCreation() (gas: -114315 (-0.132%)) testVaultMarketEpochDoesNotExist() (gas: -11434 (-0.134%)) testFailMarketEpochExists() (gas: -3813 (-0.134%)) testEpochEndMustBeAfterBegin() (gas: -3813 (-0.140%)) testVaultAddressNotController() (gas: -3813 (-0.140%)) testFeeMoreThan() (gas: -3813 (-0.140%))
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