Skip to content
Business logic Audit finding Intermediate

StakingRewards reward rate can be dragged out and diluted

The notifyRewardAmount function extends the reward period and recalculates the reward rate, so calling it with zero reward dilutes the rate for all stakers. An attacker with permission to call this function could repeatedly reduce the reward rate, dragging out rewards and reducing yield.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

StakingRewards.sol#L161

The StakingRewards.notifyRewardAmount function receives a reward amount and extends the current reward end time to now + rewardsDuration. It rebases the currently remaining rewards + the new rewards (reward + leftover) over this new rewardsDuration period.

function withdraw(IERC20 _token, address _to) external override {
    require(activated[_token] != 0 && activated[_token] + GRACE_PERIOD < block.timestamp, "shelter not activated");
    // @audit uses `msg.sender`'s share but sets `claimed` for _to! can claim for many `_to`s
    uint256 amount = savedTokens[_token] * client.shareOf(_token, msg.sender) / client.totalShare(_token);
    claimed[_token][_to] = true;
    emit ExitShelter(_token, msg.sender, _to, amount);
    _token.safeTransfer(_to, amount);
}

This can lead to a dilution of the reward rate and rewards being dragged out forever by malicious new reward deposits.

Proof of Concept

Imagine the current rewardRate is 1000 rewards / rewardsDuration. 20% of the rewardsDuration passed, i.e., now = lastUpdateTime + 20% * rewardsDuration. A malicious actor notifies the contract with a reward of 0: notifyRewardAmount(0). Then the new rewardRate = (reward + leftover) / rewardsDuration = (0 + 800) / rewardsDuration = 800 / rewardsDuration. The rewardRate just dropped by 20%. This can be repeated infinitely. After another 20% of reward time passed, they trigger notifyRewardAmount(0) to reduce it by another 20% again: rewardRate = (0 + 640) / rewardsDuration = 640 / rewardsDuration.

Recommended Mitigation Steps

Imo, the rewardRate should never decrease by a notifyRewardAmount call. Consider not extending the reward payouts by rewardsDuration on every call. periodFinish probably shouldn’t change at all, the rewardRate should just increase by rewardRate += reward / (periodFinish - block.timestamp).

Alternatively, consider keeping the rewardRate constant but extend periodFinish time by += reward / rewardRate.

ryuheimat (Concur) disputed and commented:

notifyRewardAmount check msg.sender’s permission.

Alex the Entreprenerd (judge) commented:

The warden is pointing out an admin privilege that would allow the admin to dilute current rewards.

While the sponsor claims this won’t happen, I can only judge based on the code that is available to me. And at this point there seems to be no code for the rewardsDistribution contract that would be calling notifyRewardAmount

Given this, I believe the finding to be valid as the POC works out to demonstrate how a malicious owner could dilute the rewardRate.

This would cause loss of yield for all depositors, which makes the finding of Medium Severity.


The original report as published on Code4rena, by cmichel. 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 notifyRewardAmount function recalculates the reward rate by dividing the remaining rewards plus new rewards by the full rewards duration, which reduces the rate when called with zero reward.

Impact

This could cause loss of yield for all depositors, as the reward rate can be repeatedly diluted.

What the attacker needed

Permission to call notifyRewardAmount

The fix

The reward rate should never decrease from a notifyRewardAmount call; instead, keep the period finish unchanged and increase the rate, or keep the rate constant and extend the period finish.

How it was found

  1. Wait until 20% of the rewards duration has passed.
  2. Call notifyRewardAmount with a reward of 0.
  3. Observe the reward rate drops by 20%.
  4. Repeat after another 20% of the duration to reduce it further.

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 staking contract pays rewards at a certain rate. If someone can call a function that resets the reward schedule, they can make that rate smaller each time, so everyone earns less over a longer period. This is like repeatedly stretching a fixed amount of money over a longer time, making each payment smaller.

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 cmichel

View all

196 more disclosed reports, best first.

More from Concur 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.