In onAfterRemoveLiquidity function, there is a potential for arithmetic underflow in the loop iterating over the feeDataArray when processing liquidity removal. This issue arises from the use of a decrementing loop that does not properly handle the underflow condition for a uint256 variable. This can lead to unintended behavior, including infinite loops and out-of-bounds access.
In the onAfterRemoveLiquidity the issue is found in the line of code below
The loop initializes i to localData.feeDataArrayLength - 1, which is the last valid index of the feeDataArray.
When i reaches 0, the next decrement (--i) causes i to underflow, wrapping around to 2^256 - 1.
This results in an infinite loop, as the condition i >= 0 will always evaluate to true for unsigned integers.
The contract may become unresponsive, consuming gas indefinitely, which can lead to denial of service for users attempting to interact with the contract.
Manual Review
Modify the loop to start from localData.feeDataArrayLength and check that i is greater than 0 to prevent underflow.
That’s definitely not the best way to handle that but there is indeed no impact. If someone tries to get more than their deposits, it must revert, and thanks to that "fancy mistake"(or genius code ?), it does.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.