-
Notifications
You must be signed in to change notification settings - Fork 8
hash - Killing a gague can lead to bricking of the protocol #192
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 Killing a gauge is an admin endpoint, and an exceptional measure. By sherlock rules this is of low severity |
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. |
The ability to kill a gauge is a feature that the protocol team intended to make use of as implemented. Such a use would have resulted in the entire protocol being bricked which includes almost all user's loosing their funds. |
See comments here |
For a misbehaving admin function, we can always say that the admin was supposed to use it only for a set of edge cases for which it accidentally works fine. I believe this is an issue within the admin function and I think it is a valid issue. The issue leads to an unintentional bricking of the protocol, so I think High is an adequate severity. Planning to reject the escalation. |
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. Gauges have been modified to match CRV gauges and prevent this behavior |
hash
high
Killing a gague can lead to bricking of the protocol
Summary
Slopes are not handled correctly when a gauge is killed. This can cause incorrect accounting for
sum
andtotal
weights and lead to bricking the protocol in certain scenarios.Vulnerability Detail
Points are accounted using
bias
,slope
andslope end time
. The bias is gradually decreased by its slope eventually reaching 0 at theslope end time / lock end time
. In case the bias is suddenly reduced without handling/removing its slope, there will reach a time before theslope end time
where the bias will drop below 0.points_sum
uses points to calculate the sum of individual gauge weights of a particular type at any time. The above case of bias dropping below 0 is handled as follows in_get_sum
:Whenever bias drops below 0 the slope is also made 0 without removing the
slope end accounting
inchanges_sum
. Afterwards, if a scenario occurs where the pt.bias regains a value greater than thept.slope * WEEK
, the true part of the if condition executes which can cause it to revert if at any pointself.changes_sum[gauge_type][t]
is greater than the currentpt.slope
.The sudden drop in
points_sum
bias can happen due to the following:change_gauge_weight
with a lower value than currentFrom this moment the accounting of
points_sum
is broken and depending on the currentslope
,changes_sum
,bias
and activity following this, thepoints_sum.bias
can go to 0 ( an attacker wanting to cause grief has the option to accelarate the dropping of bias to 0 by front-running a kill and increasing its slope )Once bias goes to 0, it can regain a value greater than the
pt.slope * WEEK
due to the following:change_gauge_weight
increasing a gauge's weightScenario 2 is almost sure to happen following which all calls to
_get_sum
can revert which will cause the protocol to brick since even the cycle update involves a call to_get_sum
POC
Runnable foundry test gist link:
https://gist.github.com/10xhash/b65867b99841a88e078e34f094fc0554
Impact
Bricking of the protocol,locked user funds , incorrect
sum
andtotal
weight valuesCode Snippet
_change_gauge_weight
sets weight directly without handling slopehttps://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/GaugeController.vy#L568-L582
kill_gauge
calls_change_gauge_weight
https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/GaugeController.vy#L603C5-L609
Tool used
Manual Review
Recommendation
When killing the gauge, decrease its slope from the sum and iterate over all future weeks till the max limit and remove any gauge-associated-slope changes from the
changes_sum
. Handle the user removing a vote from a killed gauge seperately from the general vote function.Duplicate of #94
The text was updated successfully, but these errors were encountered: