StakingRewards.setRewardsDuration allows setting near zero or enormous rewardsDuration , which breaks reward logic
The setRewardsDuration function lacks bounds checking, allowing an admin to set the rewards duration to zero, near zero, or an enormous value. This breaks the reward logic: a zero duration makes notifyRewardAmount inoperable, and extreme values cause meaningless results.
Submitted by hyh
notifyRewardAmount will be inoperable if rewardsDuration is set to zero. If will cease to produce meaningful results if rewardsDuration is too small or too big.
Proof of Concept
The setter does not control the value, allowing zero/near zero/enormous duration:
Division by the duration is used in notifyRewardAmount:
Recommended Mitigation Steps
Check for min and max range in the rewardsDuration setter, as too small or too big rewardsDuration breaks the logic.
Alex the Entreprenerd (judge) commented:
Finding is valid. Ultimately contingent on admin privilege so I believe Medium Severity to be appropriate.
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
Impact
Reward distribution could be disrupted: with zero duration notifyRewardAmount becomes inoperable, and with extreme durations rewards become meaningless, though this requires admin privilege.
What the attacker needed
Admin privilege to call setRewardsDuration
The fix
The setRewardsDuration setter should enforce a minimum and maximum range for the duration to prevent zero or extreme values.
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.
In a staking contract, rewards are spread over a set time called the rewards duration. If that duration is set to zero, the code that calculates rewards per second divides by zero and fails. If it is set extremely small or large, the reward calculations become meaningless, so users may not get fair rewards.
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.