-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop in ERC20Gauges::_decrementWeightUntilFree
when one of the user's gauges has a zero weight
#152
Comments
0xSorryNotSorry marked the issue as sufficient quality report |
0xSorryNotSorry marked the issue as primary issue |
eswak marked the issue as disagree with severity |
While this is a valid issue, I think it should be QA because I don't think there is a way to exploit this. The user would need to purposefully increment 0 weight on a gauge (through etherscan directly and not through our UI), and then it would only prevent them from transferring their tokens until they decrement 0 weight. I initially thought this could be used to prevent slashing (which would have higher severity), but this is not the case because |
eswak (sponsor) confirmed |
Agree with the sponsor that this issue should be a QA/low since it can't prevent slashing. |
Trumpero changed the severity to QA (Quality Assurance) |
Trumpero marked the issue as grade-a |
Trumpero marked the issue as grade-c |
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/tokens/ERC20Gauges.sol#L532-L534
Vulnerability details
Impact
The position of
++i
in the loop of theERC20Gauges::_decrementWeightUntilFree
function is incorrect, and can result in an infinite loop.https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/tokens/ERC20Gauges.sol#L500-L539
When
userGaugeWeight == 0
,i
is not incremented and will not break out of the for loop. This would only happen if a user increments their gauge to zero. If they then transfer or burn their tokens, the transaction would fail.Proof of Concept
Test case in
ERC20Gauges.t.sol
Tools Used
Foundry
Recommended Mitigation Steps
Move
++i
outside of theif (userGaugeWeight != 0)
blockAssessed type
Loop
The text was updated successfully, but these errors were encountered: