Skip to content
Business logic Audit finding Intermediate

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.

Anurag Jain Follow

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

  1. Admin has added reward which made reward rate as 10 reward per second using notifyRewardAmount function
rewardRate = reward.div(rewardsDuration);
  1. For initial 10 seconds there were no deposits which means total supply was 0
  2. So no reward were distributed for initial 10 seconds and reward for this duration which is 10*10=100 will remain in contract
  3. 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

HickupHH3 (judge) commented:

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.


The original report as published on Code4rena, by csanuragjain. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Admin adds a reward with a rate of 10 per second using notifyRewardAmount.
  2. For the first 10 seconds, total supply is zero, so no rewards are distributed.
  3. The 100 rewards for that period remain in the contract.
  4. 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.

More by Anurag Jain

View all

63 more disclosed reports, best first.

More from Y2k Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.