The BaseGauge.sol contract contains a potential arithmetic overflow vulnerability in the boost calculation logic. This occurs because the initial values for maxBoost and minBoost are set incorrectly in the constructor, leading to an underflow when calculating the boost range. While a function (setBoostParameters) exists to fix this issue, the contract will revert on most operations if this function is not called before any staking actions occur. This vulnerability is classified as medium severity due to the existence of a mitigation function, but it can still cause significant disruption if not addressed promptly.
The constructor for BaseGauge.sol contains the following code:
The potential overflow can occur in the following lines:
This is because when BaseGauge::_updateReward is called, it calls BaseGauge::earned which in turn calls BaseGauge::getUserWeight which then calls BaseGauge::_applyBoost. BaseGauge::_applyBoost calls BoostCalculator.calculateBoost which contains the following:
As seen above, if:
and minBoost > maxBoost which it is in the constructor, then there is an overflow which stops most operations in the contract from running.
The following function does exist in the contract:
This allows any address with the controller role to reset the boost parameters and prevent the overflow but if this function is not called by anyone before any staking operations begin, all operations will revert due to overflow. The existence of this function reduces the impact of this to a medium.
This test was run in the RAACGauge.test.js file. For this test to display the desired results, go into the initial beforeEach in the "RAACGauge" describe block and comment out the following block of code
This will assume that no controller has called raacGauge.setBoostParameters yet and the initial boost parameters in the constructor are still used. After this, any test you run in the file will overflow as expected.
Contract Functionality Broken: Most operations in the contract (e.g., staking, reward distribution, reward claims) will revert due to the arithmetic underflow, rendering the contract unusable.
Medium Severity:The existence of the setBoostParameters function reduces the severity of this issue, as the contract can be fixed by calling this function. However, the impact is still significant if the function is not called promptly.
Manual Review, Hardhat
To fix this issue, the following steps should be taken:
Fix Initial Boost Parameters in Constructor:
Ensure that minBoost is less than or equal to maxBoost in the constructor. For example:
This prevents the arithmetic underflow from occurring during boost calculations.
Add Validation in setBoostParameters:
Add a validation check in the setBoostParameters function to ensure that minBoost is always less than or equal to maxBoost:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
View preliminary resultsAppeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.