Skip to content
Business logic Audit finding Intermediate

Using the current time in geteffectiverewardrateat will result in incorrect reward calculation for an entire duration of a time segment

The reward calculation function uses the current block timestamp instead of the segment start time to fetch the effective reward rate, so if the rate changes mid-segment, the wrong rate is applied to the entire interval. This can under- or over-accrue rewards, leading to users and validators receiving less or more yield than intended.

WinSec Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52422 sc low using the current time in geteffectiverewardrateat will result in incorrect reward calculation for an entire duration of a time segment

Submitted on Aug 10th 2025 at 14:46:28 UTC by @WinSec for Attackathon | Plume Network

Description

Brief/Intro

Using block.timestamp, instead of the older timestamp, in getEffectiveRewardRateAt can under/over-accrue rewards for the entire interval when rates change mid-interval. This could result in users and validators being paid less than intended.

Vulnerability Details

In updateRewardPerTokenForValidator:

Solidity
        uint256 totalStaked = $.validatorTotalStaked[validatorId];
        uint256 oldLastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];

        if (block.timestamp > oldLastUpdateTime) {
            if (totalStaked > 0) {
                uint256 timeDelta = block.timestamp - oldLastUpdateTime; 
                // Get the reward rate effective for the segment ending at block.timestamp 
                PlumeStakingStorage.RateCheckpoint memory effectiveRewardRateChk =
                    getEffectiveRewardRateAt($, token, validatorId, block.timestamp);
                uint256 effectiveRewardRate = effectiveRewardRateChk.rate;

                if (effectiveRewardRate > 0) {
                    uint256 rewardPerTokenIncrease = timeDelta * effectiveRewardRate; 
                    $.validatorRewardPerTokenCumulative[validatorId][token] += rewardPerTokenIncrease;

                    // Accrue commission for the validator for this segment
                    // The commission rate should be the one effective at the START of this segment (oldLastUpdateTime)
                    uint256 commissionRateForSegment = getEffectiveCommissionRateAt($, validatorId, oldLastUpdateTime);
                    uint256 grossRewardForValidatorThisSegment =
                        (totalStaked * rewardPerTokenIncrease) / PlumeStakingStorage.REWARD_PRECISION; 

                    // Use regular division (floor) for validator's accrued commission
                    uint256 commissionDeltaForValidator = (
                        grossRewardForValidatorThisSegment * commissionRateForSegment
                    ) / PlumeStakingStorage.REWARD_PRECISION; 

                    if (commissionDeltaForValidator > 0) {
                        $.validatorAccruedCommission[validatorId][token] += commissionDeltaForValidator;
                    }
                }
            }
        }
        // Update last global update time for this validator/token AFTER all calculations for the segment
        $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;

block.timestamp is passed as an argument to the getEffectiveRewardRateAt function which gets the reward rate for the validator and token at the given timestamp (here, block.timestamp) instead of using oldLastUpdateTime. This is inconsistent with how this function is being used in other parts of the codebase.

For example in _calculateRewardsCore:

Solidity
            // What is the validator's RPT at segmentEndTime?
            // This requires calculating the RPT increase *within this specific segment*.
            PlumeStakingStorage.RateCheckpoint memory rewardRateInfoForSegment =
                getEffectiveRewardRateAt($, token, validatorId, segmentStartTime); // Rate at START of segment
            uint256 effectiveRewardRate = rewardRateInfoForSegment.rate;
            uint256 segmentDuration = segmentEndTime - segmentStartTime;

segmentStartTime is accurately being used here and not segmentEndTime.

Using block.timestamp (end of segment) in updateRewardPerTokenForValidator will use the wrong reward rate for the entire duration of the segment. Hence, rewardPerTokenIncrease is calculated incorrectly:

Solidity
                    uint256 rewardPerTokenIncrease = timeDelta * effectiveRewardRate;
                    $.validatorRewardPerTokenCumulative[validatorId][token] += rewardPerTokenIncrease;

So, validatorRewardPerTokenCumulative is incremented with a wrong value. This incorrect value is used in other calculations as well:

Solidity
                    uint256 commissionRateForSegment = getEffectiveCommissionRateAt($, validatorId, oldLastUpdateTime);
                    uint256 grossRewardForValidatorThisSegment =
                        (totalStaked * rewardPerTokenIncrease) / PlumeStakingStorage.REWARD_PRECISION; //@audit - what if reward has 6 decimals?

                    // Use regular division (floor) for validator's accrued commission
                    uint256 commissionDeltaForValidator = (
                        grossRewardForValidatorThisSegment * commissionRateForSegment
                    ) / PlumeStakingStorage.REWARD_PRECISION; //@audit - why not ceil?

                    if (commissionDeltaForValidator > 0) {
                        $.validatorAccruedCommission[validatorId][token] += commissionDeltaForValidator;
                    }

grossRewardForValidatorThisSegment, commissionDeltaForValidator and hence validatorAccruedCommission will be incorrectly updated.

Also, notice that in contrast getEffectiveCommissionRateAt in the above code block is using oldLastUpdateTime, which is the expected behaviour.

Impact Details

  • If the reward rate changed between oldLastUpdateTime and now (block.timestamp), using the end-of-segment rate applies the wrong rate to the entire timeDelta.
  • If end rate < start rate, accrual for the entire interval can be understated or even zeroed.
  • If end rate > start rate, accrual can be overstated for the interval.

This can lead to loss of yield for the users and the validator, especially when end rate < start rate. Therefore this issue warrants a high severity.

References

https://github.com/plumenetwork/contracts/blob/fe67a98fa4344520c5ff2ac9293f5d9601963983/plume/src/lib/PlumeRewardLogic.sol#L170-L171

Proof of Concept

{% stepper %} {% step %}

Step

updateRewardPerTokenForValidator is called internally, for example when a new user stakes funds. {% endstep %}

{% step %}

Step

updateRewardPerTokenForValidator fetches the getEffectiveRewardRateAt at the current timestamp instead of the old timestamp. {% endstep %}

{% step %}

Step

Rewards calculated will be based on the newer rate than the older one for the entire duration of the time segment. {% endstep %}

{% step %}

Step

If the end rate was lower than the start rate, accrual will be understated. {% endstep %}

{% step %}

Step

If the end rate was greater, the accrual of rewards will be overstated. {% endstep %} {% endstepper %}

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

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 function passes the current block timestamp to getEffectiveRewardRateAt instead of the previous update time, so the rate at the end of the segment is applied to the whole segment.

Impact

If the reward rate changes mid-segment, users and validators could receive less yield than intended (or more), depending on whether the end rate is lower or higher than the start rate.

What the attacker needed

Reward rate changes mid-segment; updateRewardPerTokenForValidator is called

The fix

The function should use oldLastUpdateTime instead of block.timestamp when calling getEffectiveRewardRateAt, consistent with other parts of the codebase.

How it was found

  1. updateRewardPerTokenForValidator is called internally, for example when a new user stakes funds.
  2. updateRewardPerTokenForValidator fetches the getEffectiveRewardRateAt at the current timestamp instead of the old timestamp.
  3. Rewards calculated will be based on the newer rate than the older one for the entire duration of the time segment.
  4. If the end rate was lower than the start rate, accrual will be understated.
  5. If the end rate was greater, the accrual of rewards will be overstated.

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.

This is a smart contract bug where a function calculates rewards for a period but uses the reward rate from the end of the period instead of the start. If the rate changed during that period, everyone gets the wrong amount. It's like being paid at today's exchange rate for work you did last month.

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 WinSec

View all

8 more disclosed reports, best first.

More from Plume Network

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.