Y2k Finance contest - kv'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: 87/110

Findings: 1

Award: $36.62

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Unbounded Loop can lead to DOS due to out of gas.

Vulnerability Detail:

As this array can grow quite large, the transaction’s gas cost could exceed the block gas limit and make it impossible to call this function at all (see @Audit):

Impact

It can lead to DOS due to being out of gas and it will cause the transfer to revert.

Code Snippet

epochs array is defined here. We can see that it is dynamic array: https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L40

uint256[] public epochs;

Here addresses are pushed into accounts array: https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L322

epochs.push(epochEnd);

Here loop is unbounded, there is no upperbound, which can lead to out of gas situation. https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443-L446

function getNextEpoch(uint256 _epoch) public view returns (uint256 nextEpochEnd) { for (uint256 i = 0; i < epochsLength(); i++) { //@audit Unbounded Loop if (epochs[i] == _epoch) { if (i == epochsLength() - 1) { return 0; }

Tool used

Manual Review

Recommendations

Consider introducing a reasonable upper limit based on block gas limits and/or adding a remove method to remove elements in the array.

#0 - MiguelBits

2022-09-30T00:02:45Z

removing this function

#1 - HickupHH3

2022-10-29T16:04:50Z

dup #457

user's primary QA

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