Platform: Code4rena
Start Date: 07/09/2022
Pot Size: $20,000 CANTO
Total HM: 7
Participants: 65
Period: 1 day
Judge: 0xean
Total Solo HM: 3
Id: 159
League: ETH
Rank: 24/65
Findings: 1
Award: $107.40
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xhunter
Also found by: BipinSah, Rohan16, Sm4rty, Tomo, fatherOfBlocks, m_Rassska, oyc_109, prasantgupta52, rokinot
https://github.com/code-423n4/2022-09-canto/tree/main/src/Swap/BaseV1-core.sol#L96 https://github.com/code-423n4/2022-09-canto/tree/main/src/Swap/BaseV1-core.sol#L149 https://github.com/code-423n4/2022-09-canto/tree/main/src/Swap/BaseV1-core.sol#L608
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):
Observation array: BaseV1-core.sol:L96 BaseV1-core.sol:L149 BaseV1-core.sol:L242 BaseV1-core.sol:L248 BaseV1-core.sol:L249
src/Swap/BaseV1-core.sol:96: observations.push(Observation(block.timestamp, 0, 0,0)); //@audit low: a push exist but there's no pop in the solution. src/Swap/BaseV1-core.sol:149: observations.push(Observation(blockTimestamp, reserve0CumulativeLast, reserve1CumulativeLast, totalSupplyCumulativeLast)); //@audit low: a push exist but there's no pop in the solution. src/Swap/BaseV1-core.sol:242: uint lastIndex = observations.length-1; .. src/Swap/BaseV1-core.sol:248: for(; i < lastIndex; i+=window) { //@audit low: poolInfo is unbounded src/Swap/BaseV1-core.sol:249: nextIndex = i + window;
allPairs array: BaseV1-core.sol:L608 BaseV1-core.sol:L564 BaseV1-core.sol:L565 BaseV1-core.sol:L566
src/Swap/BaseV1-core.sol:608: allPairs.push(pair); //@audit low: a push exist but there's no pop in the solution. src/Swap/BaseV1-core.sol:564: for (uint i; i < allPairs.length; ) { //@audit low: poolInfo is unbounded src/Swap/BaseV1-core.sol:565: BaseV1Pair(allPairs[i]).setPeriodSize(newPeriod); src/Swap/BaseV1-core.sol:566: unchecked {++i;}
Consider introducing a reasonable upper limit based on block gas limits and/or adding a remove method to remove elements in the array.
https://code4rena.com/reports/2022-04-phuture/#l-03-unbounded-loops-with-external-calls
#0 - nivasan1
2022-09-10T16:23:26Z
duplicate #8