Core Contracts

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

`updatePeriod` will skip periods, as it starts them 2 weeks later

Summary

updatePeriod will skip periods

Vulnerability Details

updatePeriod will skip periods as his newly created one will start 2 weeks later.

https://github.com/Cyfrin/2025-02-raac/blob/main/contracts/core/governance/gauges/BaseGauge.sol#L452

function updatePeriod() external override onlyController {
// ...
//@audit this get the start of 2 periods in the future, as +1 will be end of current and start of next
uint256 nextPeriodStart = ((currentTime / periodDuration) + 2) * periodDuration;
// Reset period state
periodState.distributed = 0;
periodState.periodStartTime = nextPeriodStart;
// Create new voting period
TimeWeightedAverage.createPeriod(
periodState.votingPeriod,
nextPeriodStart,
periodDuration,
avgWeight,
WEIGHT_PRECISION
);
}

That is due to the +2 instead of +1. The different can be easily seen when compared to its constructor:

// ((currentTime / periodDuration) + 1) * periodDuration
uint256 nextPeriod = ((currentTime / _periodDuration) * _periodDuration) + _periodDuration;

Example:

  1. Periods start from Monday and last up to Sunday

  2. updatePeriod is called on a Thursday and the new period is set to start Monday, not the next week, but the one after that, 10 days later...

  3. Next week will be empty with no period

Impact

updatePeriod will skip one period
Internal accounting will be messed up
The function does not work if connected with the GaugeController (due to a another bug described in another report), however if connected to admin address or another controller it will still be faulty.

Tools Used

Manual review

Recommendations

Change the math to

- uint256 nextPeriodStart = ((currentTime / periodDuration) + 2) * periodDuration;
+ uint256 nextPeriodStart = ((currentTime / periodDuration) + 1) * periodDuration;
Updates

Lead Judging Commences

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

BaseGauge::updatePeriod uses ((currentTime / periodDuration) + 2) calculation causing entire reward periods to be skipped, resulting in permanent loss of user rewards

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

BaseGauge::updatePeriod uses ((currentTime / periodDuration) + 2) calculation causing entire reward periods to be skipped, resulting in permanent loss of user rewards

Support

FAQs

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

Give us feedback!