Skip to content
Business logic Audit finding Intermediate

Re-adding a removed reward token causes inconsistent userRewardPerTokenPaid accounting

When a reward token is removed and later re-added, users who staked during the removal period have a stale userRewardPerTokenPaid value of zero, while the token's rewardPerTokenStored retains its previous value. This inconsistency can let some users claim excess rewards, leave others with unclaimable rewards, or cause claimRewards to revert.

0x23r0 Follow with 0x37, 0xAlipede and 22 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-summer-fi-governance-v2-judging/issues/23

This issue has been acknowledged by the team but won't be fixed at this time.

Found by

0x23r0, 0x37, 0xAlipede, 0xFlare, 0xShoonya, 0xxAristos, AestheticBhai, Bigsam, FalseGenius, MoonShadow, Olami_ooo, PratRed, SafetyBytes, coffiasd, cu5t0mPe0, dimulski, farismaulana, makarov, n1ikh1l, ni8mare, radevweb3, silver_eth, t.aksoy, theweb3mechanic, werulez99

Summary

When a reward token is removed from the staking contract, users who deposit afterwards never have their userRewardPerTokenPaid value updated for that token, so it remains 0. If the same token is later re-added, the rewardPerTokenStored for that token is not reset, since it retains its previous state.

Root Cause

Solidity
   /// @notice Removes a reward token from the list of reward tokens
    /// @param rewardToken The address of the reward token to remove
    function removeRewardToken(address rewardToken) external onlyGovernor {
        if (!_isRewardToken(rewardToken)) {
            revert RewardTokenDoesNotExist();
        }

        if (block.timestamp <= rewardData[rewardToken].periodFinish) {
            revert RewardPeriodNotComplete();
        }

        // Check if all tokens have been claimed, allowing a small dust balance
        uint256 remainingBalance = IERC20(rewardToken).balanceOf(address(this));
        uint256 dustThreshold;

        try IERC20Metadata(address(rewardToken)).decimals() returns (
            uint8 decimals
        ) {
            // For tokens with 4 or fewer decimals, use a minimum threshold of 1
            // For tokens with more decimals, use 0.01% of 1 token
            if (decimals <= 4) {
                dustThreshold = 1;
            } else {
                dustThreshold = 10 ** (decimals - 4); // 0.01% of 1 token
            }
        } catch {
            dustThreshold = 1e14; // Default threshold for tokens without decimals
        }

        if (remainingBalance > dustThreshold) {                     // donstion attack
            revert RewardTokenStillHasBalance(remainingBalance);
        }

@auidt>>         // Remove the token from the rewardTokens map
@auidt>>        bool success = _rewardTokensList.remove(address(rewardToken));
@auidt>>         if (!success) revert RewardTokenDoesNotExist();

        emit RewardTokenRemoved(address(rewardToken));
    }

Solidity
    /**
     * @dev Internal implementation of notifyRewardAmount
     * @param rewardToken The token to distribute as rewards
     * @param reward The amount of reward tokens to distribute
     * @param newRewardsDuration The duration for new reward tokens (only used for first time)
     */
    function _notifyRewardAmount(
        address rewardToken,
        uint256 reward,
        uint256 newRewardsDuration
    ) internal {
        RewardData storage rewardTokenData = rewardData[rewardToken];
        if (newRewardsDuration == 0) {
            revert RewardsDurationCannotBeZero();
        }

        if (newRewardsDuration > MAX_REWARD_DURATION) {
            revert RewardsDurationTooLong();
        }

        // For existing reward tokens, check if current period is complete.  // bug no check.
        if (_isRewardToken(rewardToken)) {
            if (newRewardsDuration != rewardTokenData.rewardsDuration) {
                revert CannotChangeRewardsDuration();
            }
        } else {

            // First time setup for new reward token

@auidt>>             bool success = _rewardTokensList.add(rewardToken);
@auidt>>             if (!success) revert RewardTokenAlreadyExists();

@auidt>>             rewardTokenData.rewardsDuration = newRewardsDuration;
@auidt>>             emit RewardTokenAdded(rewardToken, rewardTokenData.rewardsDuration);
        }

        // Transfer exact amount needed for new rewards
        IERC20(rewardToken).safeTransferFrom(msg.sender, address(this), reward);

        // Calculate new reward rate
        rewardTokenData.rewardRate =
            (reward * Constants.WAD) /
            rewardTokenData.rewardsDuration;
        rewardTokenData.lastUpdateTime = block.timestamp;
        rewardTokenData.periodFinish =
            block.timestamp +
            rewardTokenData.rewardsDuration;

        emit RewardAdded(address(rewardToken), reward);
    }
}
Solidity

    struct RewardData {
        uint256 periodFinish;
        uint256 rewardRate;
        uint256 rewardsDuration;
        uint256 lastUpdateTime;
        uint256 rewardPerTokenStored;
    }
Solidity
    function _updateReward(address account) internal {
        uint256 rewardTokenCount = _rewardTokensList.length();
        for (uint256 i = 0; i < rewardTokenCount; i++) {
            address rewardTokenAddress = _rewardTokensList.at(i);
            RewardData storage rewardTokenData = rewardData[rewardTokenAddress];
            rewardTokenData.rewardPerTokenStored = rewardPerToken(
                rewardTokenAddress
            );
            rewardTokenData.lastUpdateTime = lastTimeRewardApplicable(
                rewardTokenAddress
            );
            if (account != address(0)) {

@audit>>                rewards[rewardTokenAddress][account] = earned(
                    account,
                    rewardTokenAddress
                );

@audit>>                  userRewardPerTokenPaid[rewardTokenAddress][
                    account
                ] = rewardTokenData.rewardPerTokenStored;
            }
        }
    }

Internal Pre-conditions

https://github.com/sherlock-audit/2025-09-summer-fi-governance-v2/blob/main/summer-earn-protocol/packages/rewards-contracts/src/contracts/StakingRewardsManagerBase.sol#L250-L288

https://github.com/sherlock-audit/2025-09-summer-fi-governance-v2/blob/main/summer-earn-protocol/packages/rewards-contracts/src/contracts/StakingRewardsManagerBase.sol#L391-L431

External Pre-conditions

........

Attack Path

  1. User Stakes
  2. Rweard Notification
  3. After a while, the Reward token removal
  4. New Users Stake
  5. After a while
  6. Same token is readded

Impact

If a reward token is re-added, the staking contract’s reward accounting becomes inconsistent across users:

  • Some users can claim excess rewards they are not entitled to.
  • Other users may be left with stranded or unclaimable rewards.
  • In cases where underpaid users attempt to claim, the entire claimRewards function may revert, preventing them from claiming.

This makes the contract unusable for fair reward distribution after a reward token has been re-added.

PoC

No response

Mitigation

Whitelist all reward tokens, ensuring users update their token stored on entry, especially tokens that can be readded after removal.

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

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

Some users could claim excess rewards, others may have stranded or unclaimable rewards, and claimRewards may revert for underpaid users, making the contract unusable for fair distribution.

What the attacker needed

A reward token is removed; users stake while token is removed; the same token is re-added

The fix

The team acknowledged the issue but stated it won't be fixed at this time; a suggested mitigation is to whitelist all reward tokens so users update their stored token on entry, especially tokens that can be re-added after removal.

How it was found

  1. A user stakes tokens in the contract.
  2. Rewards are notified for a reward token.
  3. After some time, the reward token is removed from the contract.
  4. New users stake tokens while the reward token is removed.
  5. After some time, the same reward token is re-added.
  6. The reward accounting becomes inconsistent across users.

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 tracks how many reward tokens each user has earned. When a reward token is removed, the contract stops updating that token's accounting for new depositors. If the same token is later added back, the contract's internal counter for that token is not reset, so new users appear to have already been paid rewards they never received. This can cause some users to get too much and others to get nothing.

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 0x23r0

View all

23 more disclosed reports, best first.

More from Summer.fi - governance v2

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.