Rewards are not rolled over
Rewards distributed during periods with no deposits are not rolled over and remain stuck in the contract. An attacker could potentially withdraw these stuck rewards if the sweeper function is available, but the report does not claim direct theft.
Originally disclosed on Code4rena
Submitted by csanuragjain
If there is no deposit for sometime in start then rewards for those period are never used.
Proof of Concept
- Admin has added reward which made reward rate as 10 reward per second using notifyRewardAmount function
rewardRate = reward.div(rewardsDuration);
- For initial 10 seconds there were no deposits which means total supply was 0
- So no reward were distributed for initial 10 seconds and reward for this duration which is
10*10=100will remain in contract - Since on notifying contract of new rewards, these stuck rewards are not considered, these 100 rewards will remain in contract with no usage
Recommended Mitigation Steps
On very first deposit, better to have (block.timestamp-startTime) * rewardRate amount of reward being marked unused which can be used in next notifyrewardamount.
MiguelBits (Y2K Finance) disputed
I see this as protocol leaked value since the rewards would be “lost” and isn’t attributed to anyone.
Currently, the sweeper function allows the reward token to be withdrawn, thus providing a form of recovery. However, #49 and its dups points out that this is a vuln, and if fixed, will remove this recovery.
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 reward calculation does not account for periods when total supply is zero, so rewards allocated for those periods are never distributed and remain in the contract.
Impact
The protocol leaks value because rewards are lost and not attributed to anyone; the sweeper function currently allows recovery, but if that function is fixed as per another issue, recovery would be removed.
What the attacker needed
No deposits at start of reward period
The fix
On the first deposit, mark the rewards for the period before that deposit as unused so they can be included in the next notifyRewardAmount call.
How it was found
- Admin adds a reward with a rate of 10 per second using notifyRewardAmount.
- For the first 10 seconds, total supply is zero, so no rewards are distributed.
- The 100 rewards for that period remain in the contract.
- When new rewards are notified, the stuck rewards are not considered and remain unused.
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 reward contract, rewards are paid out over time based on how much people have deposited. If nobody has deposited yet, those rewards are not given to anyone and stay in the contract. This report says those leftover rewards are not added back to future rewards, so they are effectively lost.
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.