Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: low
Valid

Underflow of the boost leading to the contstant failure of the calculateBoost function in BaseGauge.

Summary

The BaseGauge.sol contract defines minBoost and maxBoost to calculate user boosts. When users stake, withdraw, or getreward, the updateReward(msg.sender) function updates their reward state using the minBoost and maxBoost values. If the boostRange is improperly set, it causes underflow or overflow, leading to reward calculation failures.

Vulnerability Details

RAACGauge and RWAGauge both inherits BaseGauge.sol defines minBoost and maxBoost which helps in calculating boost for the user in the BaseGauge. where minBoost should be lower than maxBoost. When user create checkpoint for reward Calculation SLOC#599-604 , stake SLOC#257-267, withdraw SLOC#269-280 or try to claim reward with getReward SLOC#323-347 it will first execute the updateReward(msg.sender) helps in user to Update reward state for an account state.reward is calculate for user to get users current weight including boost SLOC#584, SLOC#594.

This function _applyBoost() will use the minBoost and maxBoost value stored in the boostState at the contract deployment (in constructor) SLOC#140-143

// File: contracts/core/governance/gauges/BaseGauge.sol
// Initialize boost parameters
boostState.maxBoost = 25000; // 2.5x
boostState.minBoost = 1e18; // <@ root cause
boostState.boostWindow = 7 days;

and will calculate the Boost With Provided Params set in the function call of the _calculateBoost() SLOC#246

// File: contracts/core/governance/gauges/BaseGauge.sol
// Create BoostParameters struct from boostState
BoostCalculator.BoostParameters memory params = BoostCalculator.BoostParameters({
maxBoost: boostState.maxBoost,
minBoost: boostState.minBoost,
boostWindow: boostState.boostWindow,
totalWeight: boostState.totalWeight,
totalVotingPower: boostState.totalVotingPower,
votingPower: boostState.votingPower
});
uint256 boost = BoostCalculator.calculateBoost(
veBalance,
totalVeSupply,
params
);

After that BoostCalculator::calculateBoost does this calculation SLOC#89.

// File: contracts/libraries/governance/BoostCalculator.sol
uint256 boostRange = params.maxBoost - params.minBoost;

in our case maxboost: 25000 and minBoost: 1e18 contract is deployed with version ^0.8.19 this already checks for the underflow and overflow value in contract and revert. boostRange value will lead to underflow and calculation fails. Reward can't be calculated due constantly failing of the function.

Impact

If any user try to execute any of this stake, withdraw, getReward, notifyReward, voteDierction, checkPoint functions it will revert due to undeflow of the boost calculation.

Tools Used

  • Manual Review

Recommended Mitigation

  • minBoost should be lower than maxBoost.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

boostState.minBoost is set to 1e18

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!