Incorrect reward duration extension in notifyRewardAmount function
The notifyRewardAmount function always extends the reward period by the full rewardsDuration when new rewards are added, even if a period is already ongoing. This causes rewards to be distributed over a longer time than intended, giving users smaller rewards per time.
Submitted by bytes032, also found by J4de.
This issue can lead to extending the reward duration beyond the intended time period, causing rewards to be distributed over a longer duration than initially planned. This could result in users receiving smaller rewards over time, which may not align with the project’s goals or user expectations.
Proof of Concept
The notifyRewardAmount function updates the reward rate and the period finish time for a given rewards token.
It first checks if the current block timestamp is greater than or equal to the period finish time for the given rewards token. If the reward period has passed, the reward rate is set by dividing the reward amount by the rewardsDuration for the rewards token. If the reward period has not yet passed, the remaining time and the leftover reward amount are calculated based on the current reward rate. The new reward rate is then set by adding the leftover amount to the new reward amount and dividing by the rewardsDuration.
Finally, the function then updates the lastUpdateTime for the rewards token to the current block timestamp and increments the periodFinish time by adding the rewardsDuration.
This means if there’s an ongoing reward duration and its halfway done, adding new rewards will automatically increase the reward duration by the initial time period.
// @audit always increments
periodFinish[address(rewardsToken)] = block.timestamp.add(
rewardsDuration[address(rewardsToken)]
);
After discussing with the sponsor, they acknowledged that this behavior was not expected.
Recommended Mitigation Steps
Modify the notifyRewardAmount function to only extend the reward duration when necessary.
After discussing with the sponsor, they acknowledged that this behavior was not expected.
I’m quite surprised by this, given how
notifyRewardAmount()is supposed to work when topping up rewards. It will require significant modifications to a battle-tested codebas,e which could introduce new bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the function unconditionally sets the period finish to the current time plus the full rewards duration, rather than only extending when the previous period has ended or proportionally.
Impact
Rewards could be distributed over a longer duration than planned, so users may receive smaller rewards over time.
What the attacker needed
Ongoing reward period; new rewards added via notifyRewardAmount
The fix
The notifyRewardAmount function should be modified to only extend the reward duration when necessary.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A reward pool pays out tokens over a set time. When someone adds more tokens, the code should keep the same end time or extend it only as needed. Instead, it always adds the full original duration, so the payout is stretched out and everyone gets less per day.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.