Owed rewards could be lost for some users for periods before slashing time due to incorrect logic.
The slashing reward calculation can skip accruing rewards for the period between the last update and the slash, because another flow can push the validator's last update timestamp past the slash time. Affected users then see no reward delta and cannot claim yield they were owed.
- Disclosed after under an hour
53018 sc high owed rewards could be lost for some users for periods before slashing time due to incorrect logic
Submitted on Aug 14th 2025 at 17:07:58 UTC by @valkvalue for Attackathon | Plume Network
- Report ID: #53018
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/facets/ValidatorFacet.sol
Impacts:
- Theft of unclaimed yield
- Permanent freezing of funds
Description
Brief/Intro
Rewards could be lost for some users, for owed periods, before slashing time, due to wrong logic.
Vulnerability Details
Currently _performSlash doesn't call updateRewardPerTokenForValidator for each token <-> slashed validator pair to ensure the reward cumulative value is properly up to date before the slash.
There is logic in calculateRewardsWithCheckpoints intended to handle this case and to accrue and properly increase the global validatorRewardPerTokenCumulative prior to calling the core reward calculation. However, that logic assumes validatorLastUpdateTimes are correct. An attacker (or some legitimate flow) can cause validatorLastUpdateTimes to be updated after the slashing time by calling updateRewardPerTokenForValidator in other flows, which sets validatorLastUpdateTimes to block.timestamp even for slashed validators. The code even contains a comment acknowledging the issue and intentionally avoids calling updateRewardPerTokenForValidator in the slashed branch:
// Slashed validator case: calculate what cumulative should be up to the slash timestamp.
// We DO NOT call updateRewardPerTokenForValidator here because its logic is incorrect for slashed validators.
updateRewardPerTokenForValidator sets validatorLastUpdateTimes to block.timestamp for slashed validators:
function updateRewardPerTokenForValidator(...) internal {
PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId];
...
if (validator.slashed) {
// For slashed validators, no further rewards or commission accrue.
// We just update the timestamp to the current time to mark that the state is "settled" up to now.
$.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
if ($.validatorTotalStaked[validatorId] > 0) {
revert InternalInconsistency("Slashed validator has non-zero totalStaked");
}
return;
}
...
}
Flows that can trigger this include RewardsFacet.removeRewardToken (which settles for all validators, including slashed ones) and ValidatorFacet.forceSettleValidatorCommission.
The problematic flow in calculateRewardsWithCheckpoints is:
function calculateRewardsWithCheckpoints( ...) internal returns {
if (!validator.slashed) {
...
} else {
// Slashed validator case: calculate what cumulative should be up to the slash timestamp.
// We DO NOT call updateRewardPerTokenForValidator here because its logic is incorrect for slashed validators.
uint256 currentCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
uint256 effectiveEndTime = validator.slashedAtTimestamp;
uint256 tokenRemovalTime = $.tokenRemovalTimestamps[token];
if (tokenRemovalTime > 0 && tokenRemovalTime < effectiveEndTime) {
effectiveEndTime = tokenRemovalTime;
}
uint256 validatorLastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
if (effectiveEndTime > validatorLastUpdateTime) {
uint256 timeSinceLastUpdate = effectiveEndTime - validatorLastUpdateTime;
if (userStakedAmount > 0) {
PlumeStakingStorage.RateCheckpoint memory effectiveRewardRateChk = getEffectiveRewardRateAt($, token, validatorId, validatorLastUpdateTime); // Use rate at start of segment
uint256 effectiveRewardRate = effectiveRewardRateChk.rate;
if (effectiveRewardRate > 0) {
uint256 rewardPerTokenIncrease = timeSinceLastUpdate * effectiveRewardRate;
currentCumulativeRewardPerToken += rewardPerTokenIncrease;
}
}
}
return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, currentCumulativeRewardPerToken);
}
}
Because updateRewardPerTokenForValidator can set validatorLastUpdateTimes[validatorId][token] to a timestamp after the slashing time, effectiveEndTime > validatorLastUpdateTime will be false and the cumulative reward per token will not be increased for the period between the previous last update and the slash. As a result, user rewards covering that period are not accounted for.
When entering _calculateRewardsCore(), the following check may return (0, 0, 0):
if (
effectiveEndTime <= lastUserRewardUpdateTime
|| currentCumulativeRewardPerToken <= lastUserPaidCumulativeRewardPerToken
) {
return (0, 0, 0);
}
If a user's userValidatorRewardPerTokenPaid was last updated exactly at the block.timestamp where the validator was last (incorrectly) updated, then currentCumulativeRewardPerToken may be equal to that paid value and thus the function returns zero rewards, even though the user should be owed rewards for the period prior to the slash.
Normal flows like stake() and unstake() update both the token<->validator pair data and the token<->validator<->user data (including userValidatorRewardPerTokenPaid and validatorRewardPerTokenCumulative), so it's plausible for a user to have userValidatorRewardPerTokenPaid equal to the (incorrectly) stale validatorRewardPerTokenCumulative, causing permanent loss of owed rewards.
Example code reference: https://github.com/plumenetwork/contracts/blob/fe67a98fa4344520c5ff2ac9293f5d9601963983/plume/src/lib/PlumeRewardLogic.sol#L122-L124
// Update paid pointers AFTER calculating delta to correctly checkpoint the user's state.
$.userValidatorRewardPerTokenPaid[user][validatorId][token] =
$.validatorRewardPerTokenCumulative[validatorId][token];
$.userValidatorRewardPerTokenPaidTimestamp[user][validatorId][token] = block.timestamp;
Impact Details
Lost yield and permanently frozen yield funds that cannot be claimed by affected users.
References
- updateRewardPerTokenForValidator snippet: https://github.com/plumenetwork/contracts/blob/fe67a98fa4344520c5ff2ac9293f5d9601963983/plume/src/lib/PlumeRewardLogic.sol#L144-L154
Proof of Concept
Step-by-step reproduction:
{% stepper %} {% step %}
Step
Cumulative reward value for validator isn't updated for some period. Suppose it was last updated at T = 50. {% endstep %}
{% step %}
Step
Validator gets slashed at T = 100. {% endstep %}
{% step %}
Step
At T = 110, validatorLastUpdateTime is (incorrectly) updated to T = 110 via updateRewardPerTokenForValidator.
{% endstep %}
{% step %}
Step
Because validatorLastUpdateTime is now > slashedAtTimestamp, the slashing flow in calculateRewardsWithCheckpoints does not update validatorRewardPerTokenCumulative for the period T = 50..100.
{% endstep %}
{% step %}
Step
A user who last updated their userValidatorRewardPerTokenPaid at T = 50 will have userValidatorRewardPerTokenPaid equal to the stale cumulative value. When they attempt to claim, calculateRewardsCore sees no delta and returns (0, 0, 0), preventing the user from claiming owed rewards.
{% endstep %}
{% endstepper %}
Additional notes
- The report includes an illustrative image showing the timeline and the missing accounted period: https://i.imgur.com/3QKHhji.png
- Do not change or remove the referenced links in this report.
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 slashing path relies on a last-update timestamp that other flows overwrite with the current time even for slashed validators, so the pre-slash period is never accrued.
Impact
Affected users could permanently lose unclaimed yield for the period before the slash, as the funds cannot be claimed.
What the attacker needed
Validator gets slashed; a later flow updates the validator timestamp; user has unclaimed rewards
The fix
The slashing flow should accrue the reward cumulative up to the slash time before any later update can move the last-update timestamp past it.
How it was found
- The validator's cumulative reward value is last updated at an earlier time.
- The validator is slashed at a later time.
- After the slash, another flow updates the validator's last update time to the current time.
- The slashing calculation sees the last update time is past the slash time and skips accruing rewards for the gap.
- A user whose paid pointer matches the stale cumulative value gets zero rewards on claim.
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.
Staking contracts track rewards with running totals and timestamps. If a validator is punished (slashed), the contract is supposed to freeze the reward total at the slash moment. Here a later bookkeeping update moves the timestamp forward, so the gap before the slash is never counted and users lose that yield.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.