-
Notifications
You must be signed in to change notification settings - Fork 7
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
Gauge will be unusable if it has been inactive for too long. #301
Comments
141345 marked the issue as duplicate of #129 |
141345 marked the issue as duplicate of #384 |
alcueca marked the issue as not a duplicate |
@OpenCoreCH, would you have a look at this one? |
Known issue from the Curve codebase that the function has to be called at least once every ~5 years, was stated in the contest description (to be fair it was only stated for |
alcueca marked the issue as unsatisfactory: |
Hey, just wanted to add that as stated in the original issue, this would be the case not only if no one has called the function for ~5 years, but also if the gauge has previously been removed and has been re-added ~5+ years later. If the gauge has been removed it cannot be expected that the updating function will be called, so this is a realistic scenario where the gauge is re-added after a long time and it doesn't work properly. |
To remove and then add the same gauge after 5 years is a remote edge case which would nonetheless be easily found while testing such a governance action. Accepting it as QA to be added to the documentation. |
alcueca changed the severity to QA (Quality Assurance) |
alcueca marked the issue as grade-b |
Lines of code
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L152
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L91-#L114
Vulnerability details
Impact
Gauge will will be unusable if inactive for too long as its relative weight will always remain 0.
Proof of Concept
With the current implementation of the code,
get_weight
is responsible for updating the gauge weight for every week. The problem is that the loop responsible for doing so has limited iterations (500) and only updates the value oftime_weight[_gauge_addr]
if the value oft > block.timestamp
. This means that if it goes through all 500 iterations andt <= block.timestamp
, the value oftime_weight
will never be updated so any calls in the future to_get_weight
will just iterate over the old timestamps and values and will never set new ones.This could be caused by 2 different situations - 1. The gauge simply has been inactive for 500 weeks and 2. The Gauge has been previously removed and is now readded 500 weeks later.
In both scenarios
_get_weight
will be unable to update the new values and any users trying to claim rewards viaLendingLedger
will get 0, despite having put their votes towards a gauge.Foundry test
Logs:
Tools Used
Manual review
Recommended Mitigation Steps
In
get_weight
even ift < block.timestamp
, still settime_weight[_gauge_addr] = t;
Assessed type
Error
The text was updated successfully, but these errors were encountered: