TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: high
Invalid

Reward Rate Dilution by Repeated `_notifyReward` Calls

Summary

Malicious actors can repeatedly call distributeRewards with a reward of 0 to gradually reduce the rewardRate, which will dilute stakers' rewards.

Vulnerability Details

distributeRewards makes a call to _notifyReward. Inside the _notifyReward(), If the current time is past rewardData.periodFinish, the reward rate is calculated simply as:

rewardData.rewardRate = uint216(amount / rewardDuration);

If not, it takes the remaining time and leftover rewards into account:

uint256 remaining = uint256(rewardData.periodFinish) - block.timestamp;
uint256 leftover = remaining * rewardData.rewardRate;
rewardData.rewardRate = uint216((amount + leftover) / rewardDuration);

A malicious actor can repeatedly call distributeRewards with nextRewardAmount set to 0 .
By doing so, they can manipulate the rewardRate calculation, causing it to decrease gradually over time.

PoC

Suppose rewardData.rewardRate is initially 1000.
After 20% of the rewardDuration has passed, a malicious actor calls distributeRewards with nextRewardAmount set to 0.
The remaining time is 0.8 * rewardDuration and leftover rewards are 0.8 * rewardDuration * 1000 = 800.

rewardData.rewardRate = uint216((0 + 800) / rewardDuration) = 800 / rewardDuration;

The rewardRate drops from 1000 to 800.
Similarly if second Call is made to distributeRewards with nextRewardAmount = 0, then rewardRate drops from 800 to 640.

Impact

if the function is called repeatedly, the rewards for stakers will be diluted over time.

Tools Used

Manual review, Vs Code

Recommendations

Ensure nextRewardAmount is managed carefully and cannot be set to 0 or a very low value maliciously so that the reward rate can be prevented from decreasing unfairly when new rewards are added.

Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

oxwhite Submitter
12 months ago
inallhonesty Lead Judge
12 months ago
inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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