Core Contracts

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

Integer Underflow in `GaugeController::_updateGaugeWeight` Leading to Potential DoS

Summary

The GaugeController::_updateGaugeWeight function is vulnerable to an integer underflow when calculating newGaugeWeight. If oldWeight * votingPower / WEIGHT_PRECISION exceeds oldGaugeWeight, the subtraction operation will result in an underflow, causing the transaction to revert. This could lead to a denial-of-service (DoS) condition, preventing the function from executing successfully.

Vulnerability Details

The vulnerability occurs in the following line of code in GaugeController::_updateGaugeWeight function:

uint256 newGaugeWeight = oldGaugeWeight - (oldWeight * votingPower / WEIGHT_PRECISION)
+ (newWeight * votingPower / WEIGHT_PRECISION);

If oldWeight * votingPower / WEIGHT_PRECISION is greater than oldGaugeWeight, the subtraction operation oldGaugeWeight - (oldWeight * votingPower / WEIGHT_PRECISION) will underflow. Since Solidity above 0.8 reverts on underflow, this will cause the entire transaction to fail, potentially disrupting the protocol's functionality.

Scenario:

  • Suppose oldGaugeWeight = 100, oldWeight = 200, votingPower = 1000, and WEIGHT_PRECISION = 1000.

  • The calculation oldWeight * votingPower / WEIGHT_PRECISION results in 200 * 1000 / 1000 = 200.

  • The subtraction oldGaugeWeight - 200 results in 100 - 200 = -100, which causes an underflow and reverts the transaction.

Impact

  • If an underflow occurs, the transaction will revert, leading to a DoS scenario.

  • It prevents updates to gauge weights, impacting voting power allocation.

Tools Used

Manual code review

Recommendations

Explicitly check for potential underflows before performing the subtraction:

require(oldGaugeWeight >= (oldWeight * votingPower / WEIGHT_PRECISION), "Underflow risk");
Updates

Lead Judging Commences

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

GaugeController::_updateGaugeWeight uses current voting power for both old and new vote calculations, causing underflows when voting power increases and incorrect gauge weights

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

GaugeController::_updateGaugeWeight uses current voting power for both old and new vote calculations, causing underflows when voting power increases and incorrect gauge weights

Support

FAQs

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