_decrementWeightUntilFree(...) could turn into an infinite loop #353
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-735
partial-50
Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Lines of code
https://github.com/code-423n4/2023-05-maia/blob/54a45beb1428d85999da3f721f923cbf36ee3d35/src/erc-20/ERC20Gauges.sol#L536-L551
Vulnerability details
Impact
_decrementWeightUntilFree(...) can be stuck in an infinite loop and this will potentially cause a DOS for all function calls that depend on it.
Proof of Concept
if the
weight
of thegauge
in the loop is 0 this function will be stuck in an infinite loop because the loop counteri
will not be incremented.For instance, if there are 10 gauges, and the 4th gauge
(i = 3)
has a weight of 0, the loop will continue from i = 3 and be stuck there until the caller runs out of gas this can lead to a denial of serviceTools Used
VS code
Recommended Mitigation Steps
Bring the loop increment counter outside the
if
blockAssessed type
Loop
The text was updated successfully, but these errors were encountered: