code-423n4 / 2023-08-goodentry-findings

3 stars 2 forks source link

Loop condition that might prevent the function from correctly detecting range overlaps #575

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/RangeManager.sol#L56-L68

Vulnerability details

Impact

The loop iterates through each element in the stepList array and checks whether the new range overlaps with each existing range. However, the revert("Range overlap"); statement is placed inside the loop, which means that the moment any overlap is detected, the function will revert immediately without checking the remaining elements in the array.

Tools Used

Manual review

Recommended Mitigation Steps

To address this issue, you should modify the logic to use a boolean flag to track overlap and then revert outside of the loop if the flag is set. Here's the corrected code: Screenshot in link below

https://ibb.co/mq6s3KC

Assessed type

Loop

c4-pre-sort commented 1 year ago

141345 marked the issue as low quality report

141345 commented 1 year ago

invalid

revert can still see the error msg

c4-judge commented 1 year ago

gzeon-c4 marked the issue as unsatisfactory: Invalid