Open c4-bot-2 opened 8 months ago
MarioPoneder marked the issue as primary issue
Related to #2 (same mitigation measures)
Not duplicating for now.
zjesko (sponsor) confirmed
MarioPoneder marked the issue as satisfactory
MarioPoneder marked the issue as selected for report
Selected for report due to coded PoC
Lines of code
https://github.com/code-423n4/2024-03-neobase/blob/d6e6127e6763b93c23ee95cdf7622fe950d9ed30/src/GaugeController.sol#L226-L227
Vulnerability details
Impact
GaugeController::remove_gauge
will always revert when it is called for gauges with weight that is != 0Proof of Concept
The current implementation of the
GaugeController::remove_gauge
function has a major flaw within it. Because it erases the gauge type of the gauge being removed prior to calling_remove_gauge_weight
, it will always revert whenever it is called for gauges that have a weight value different from 0. This is due to the fact that in_remove_gauge_weight
there are subtractions being made to gauge type mappings (where the gauge type key being used will be -1, since the gauge type for the gauge has already been erased) using values from gauge mappings.Although an argument can be made that this issue can be avoided by calling
GaugeController::remove_gauge_weight
prior to callingGaugeController::remove_gauge
, it can still prove to be quite problematic in an event where an urgent removal of a given gauge is required, but the initialremove_gauge
call for doing so gets reverted, since the governance didn't know about the issue and the proper way of bypass it up until that point. In that case, a separate new governance proposal will have to be executed in order to remove the gauge, which will take a significant amount of time.The following short coded PoC demonstrates the issue:
Tools Used
Manual Review
Recommended Mitigation Steps
Call
_remove_gauge_weight
prior to erasing the gauge type of the gauge:Assessed type
Under/Overflow