-
Notifications
You must be signed in to change notification settings - Fork 8
ZanyBonzy - Lowering the gauge weight can disrupt accounting, potentially leading to both excessive fund distribution and a loss of funds. #94
Comments
Hello, Thanks a lot for your attention. Thank you for your insightful observation. Upon thorough examination, we acknowledge that such an occurrence could indeed jeopardize the protocol. We are currently exploring multiple solutions to address this issue. Therefore, in conclusion, we must consider your issue as valid. Regards, |
Escalate The severity of this issue is low for two reasons:
|
You've created a valid escalation! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Addressing the escalation points:
|
I think all issues regarding killing and changing weight for gauges (#18, #94, #122,#192), all the arguments are assuming the following:
|
See my comment here. Planning to reject the escalation. |
@0xDetermination @deadrosesxyz @10xhash Do you think this is a duplicate of #192 because they seem similar. I am unsure if fixing one issue will fix another, given at the point of contest, it is intended to invoke both functions. |
@nevillehuang I think any issue with a root cause of 'lowering gauge weight' should be considered the same if I understand the duplication rules correctly. So it seems like these are all dupes. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
Hello, we fixed this issue on this PR. You can see on these comments, description of the fix : |
Fix looks good. _change_gauge_weight has been removed completely |
ZanyBonzy
medium
Lowering the gauge weight can disrupt accounting, potentially leading to both excessive fund distribution and a loss of funds.
Summary
Similar issues were found by users 0xDetermination and bart1e in the Canto veRWA audit, which uses a similar gauge controller type.
Vulnerability Detail
points_weight[addr][next_time].bias
andtime_weight[addr]
are updated - the slope is not.m
is the slope. After the weight is reduced by an amountk
using thechange_gauge_weight
function, the equation becomes f(t) = c - k - mx The slope m remains unchanged, but the t-axis intercept changes from t1 = c/m to t2 = (c-k)/m.changes_sum
hashmap. And is not affected by changes in gauge weight. Consequently, there's a time window t1 - t2 during which the earlier slope changes applied to the global state when user calledvote_for_gauge_weights
function remains applied even though they should have been subtracted. This in turn creates a situation in which the global weightis less than the sum of the individual gauge weights, resulting in an accounting error.CvgRewards
contract when thewriteStakingRewards
function invokes the_checkpoint
, which subsequently triggers thegauge_relative_weight_writes
function for the relevant time period, the calculated relative weight becomes inflated, leading to an increase in the distributed rewards. If all available rewards are distributed before the entire array is processed, the remaining users will receive no rewards."kill_gauge
function.Impact
The way rewards are calculated is broken, leading to an uneven distribution of rewards, with some users receiving too much and others receiving nothing.
Code Snippet
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/GaugeController.vy#L568C1-L590C1
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Rewards/CvgRewards.sol#L189
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Rewards/CvgRewards.sol#L235C1-L235C91
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/GaugeController.vy#L493
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/GaugeController.vy#L456C1-L475C17
https://github.com/sherlock-audit/2023-11-convergence/blob/e894be3e36614a385cf409dc7e278d5b8f16d6f2/sherlock-cvg/contracts/Locking/GaugeController.vy#L603C1-L611C54
Tool used
Manual Review
Recommendation
Disable weight reduction, or only allow reset to 0.
The text was updated successfully, but these errors were encountered: