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
Rank: 87/110
Findings: 1
Award: $36.62
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Respx
Also found by: 0x1f8b, 0xDecorativePineapple, 0xNazgul, 0xPanas, 0xSmartContract, 0xc0ffEE, 0xmuxyz, Aymen0909, Bahurum, Bnke0x0, CodingNameKiki, Deivitto, Jeiwan, Lambda, Picodes, PwnPatrol, R2, RaymondFam, Rolezn, Ruhum, Saintcode_, SooYa, Tointer, V_B, ajtra, ak1, async, auditor0517, brgltd, c3phas, carrotsmuggler, cccz, csanuragjain, datapunk, djxploit, durianSausage, eierina, erictee, gogo, imare, joestakey, jonatascm, kv, ladboy233, leosathya, lukris02, oyc_109, pashov, pauliax, rbserver, robee, rokinot, rvierdiiev, scaraven, simon135, unforgiven, wagmi, zzzitron
36.6223 USDC - $36.62
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
Unbounded Loop can lead to DOS due to out of gas.
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):
It can lead to DOS due to being out of gas and it will cause the transfer to revert.
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; }
Manual Review
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