Skip to content
Smart contracts Audit finding Advanced

Claimers who claim after (slash/inactive + updateRewardPerTokenForValidator which advances validatorLastUpdateTimes to be more than slashTimestamp) will lose rewards for a segment

The reward updater advances the validator's last-update timestamp to the current block time in the slashed and inactive branches without first settling rewards up to the slash or inactive cap. As a result, later claims skip the final pre-cap reward segment, so users and validator commission are underpaid and the unaccrued tokens stay in the treasury.

Plume Network

Originally disclosed on Immunefi

52849 sc high claimers who claim after slash inactive updaterewardpertokenforvalidator which advances validatorlastupdatetimes to be more than slashtimestamp will lose rewards for a segment

Brief / Intro

When a validator becomes slashed or inactive, later admin operations can advance validatorLastUpdateTimes to a time greater than or equal to the effective cap (the slash/inactive timestamp). Because updateRewardPerTokenForValidator's slashed/inactive branches write validatorLastUpdateTimes[validatorId][token] = block.timestamp and return without first settling rewards up to the cap, subsequent calls to claim skip the final pre-cap reward segment. Result: some users (and validator commission) are underpaid; the under-accrued tokens remain in the treasury.

Root cause: in updateRewardPerTokenForValidator, the slashed and inactive branches advance validatorLastUpdateTimes to block.timestamp without settling to the cap time.

Vulnerability details

PoC attack flow

{% stepper %} {% step %}

Step: Setup

  1. Set pUSD rate to 1e18.
  2. user1 stakes 10 ETH to validator v0; user3 stakes 10 ETH to v0.
  3. Advance time vm.warp(+1000). {% endstep %}

{% step %}

Step: Slash validator

  1. voteToSlashValidator(v0, block.timestamp + 1 days) → validator is auto-slashed at Tslash.
  2. user1 immediately claim(pUSD, v0) → receives pre-slash rewards (e.g. ~9500e18). {% endstep %}

{% step %}

Step: Advance last update past cap

  1. vm.warp(+10). Anyone calls forceSettleValidatorCommission(v0) → this invokes updateRewardPerTokenForValidator which (in slashed branch) writes validatorLastUpdateTimes[v0][pUSD] = now (post-cap). {% endstep %}

{% step %}

Step: Victim claim

  1. user3 calls claim(pUSD, v0) → returns 0 because the pre-slash segment is skipped.
  2. Outcome: user3 receives 0 rewards while user1 already received their payout; under-accrued tokens remain. {% endstep %} {% endstepper %}

Flows that cause the bug

{% stepper %} {% step %}

Validator gets slashed

  • ValidatorFacet.voteToSlashValidator(vId, expiry) sets slashedAtTimestamp = Tslash.
  • Later, admin calls ValidatorFacet.forceSettleValidatorCommission(vId) (or RewardsFacet.removeRewardToken(token) / RewardsFacet.setRewardRates(tokens, rates)).
  • Those call PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId) → slashed branch writes validatorLastUpdateTimes[vId][token] = now.
  • Subsequent RewardsFacet.claim(token, vId) → calculateRewardsWithCheckpoints computes effectiveEndTime = Tslash <= lastUpdateTime → final pre-slash accrual skipped. {% endstep %}

{% step %}

Validator set inactive

  • Admin calls ValidatorFacet.setValidatorStatus(vId, false) → records slashedAtTimestamp = Tinactive and pushes 0-rate checkpoints.
  • Any later admin op calls updateRewardPerTokenForValidator($, token, vId), which (inactive branch) writes validatorLastUpdateTimes[vId][token] = now.
  • Subsequent RewardsFacet.claim(token, vId) → final pre-inactive accrual skipped. {% endstep %}

{% step %}

Token removal during/after slash/inactive

  • Admin calls RewardsFacet.removeRewardToken(token).
  • Loop calls PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId) then createRewardRateCheckpoint($, token, vId, 0).
  • For slashed/inactive validators, updater writes validatorLastUpdateTimes[vId][token] = now (> cap).
  • Later claims skip the pre-cap delta. {% endstep %}

{% step %}

Set reward rates after slash/inactive

  • Admin calls RewardsFacet.setRewardRates(tokens, rates) (or setMaxRewardRate(token, newMax)).
  • createRewardRateCheckpoint first calls updateRewardPerTokenForValidator.
  • Updater on slashed/inactive writes validatorLastUpdateTimes[vId][token] = now.
  • Later claims skip the last pre-cap segment. {% endstep %} {% endstepper %}

Impact details

  • Users are underpaid for the final pre-cap time segment.
  • Validator commission for that segment is under-accrued.
  • Treasury retains more tokens than intended.
  • Magnitude: missed_time_segment × applicable_rate × stake / precision, aggregated over affected users/tokens.
  • Likelihood and impact are high because common admin actions (settlement, rate updates, token removal) occur often and call the updater.

Recommended remediation

  • In updateRewardPerTokenForValidator, do not advance validatorLastUpdateTimes in slashed/inactive branches.
  • Alternatively, when transitioning a validator to slashed/inactive, immediately settle rewards up to the cap and set validatorLastUpdateTimes to exactly that cap time; thereafter prevent any advancement past the cap while the validator remains slashed/inactive.
  • Ensure checkpoint creation paths that invoke the updater either skip calling it when slashed/inactive, or use updater logic that respects the cap and never moves lastUpdateTimes beyond it.

References / Relevant code excerpts

  • The slashed and inactive branches currently set validatorLastUpdateTimes[validatorId][token] = block.timestamp and return without settling to the cap time — the root cause.
  • In calculateRewardsWithCheckpoints, the slashed path sets effectiveEndTime = validator.slashedAtTimestamp and only accrues a final segment if effectiveEndTime > validatorLastUpdateTime. Advancing validatorLastUpdateTimes to now (≥ cap) causes that condition to be false and the pre-cap segment to be skipped.
  • Common admin flows that call the updater after slash/inactive will systematically cause underpayment.

Code excerpts (lines referenced in original report):

Solidity
File: attackathon-plume-network/plume/src/lib/PlumeRewardLogic.sol
135:

136:     function updateRewardPerTokenForValidator(
137:         PlumeStakingStorage.Layout storage $, address token, uint16 validatorId
140:     ) internal {
141:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId]; // Get validator info
142:
143:         // --- REORDERED SLASHED/INACTIVE CHECKS ---
144:         // Check for slashed state FIRST since slashed validators are also inactive
145:         if (validator.slashed) {
146:             // For slashed validators, no further rewards or commission accrue.
147:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
148:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
149:
150:             // Add a defensive check: A slashed validator should never have any stake. If it does, something is
151:             // wrong with the slashing logic itself.
152:             if ($.validatorTotalStaked[validatorId] > 0) {
153:                 revert InternalInconsistency("Slashed validator has non-zero totalStaked");
154:             }
155:             return;
156:         } else if (!validator.active) {
157:             // For inactive (but not slashed) validators, no further rewards or commission accrue.
158:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
159:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
160:             return;
161:         }
164:         // --- END REORDERED CHECKS ---
...
203:         // Update last global update time for this validator/token AFTER all calculations for the segment
204:         $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
205:     }

400:   function calculateRewardsWithCheckpoints(
401:         PlumeStakingStorage.Layout storage $,
402:         address user,
403:         uint16 validatorId,
404:         address token,
405:         uint256 userStakedAmount
406:     ) internal returns (uint256 totalUserRewardDelta, uint256 totalCommissionAmountDelta, uint256 effectiveTimeDelta) {
407:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId];
408:
411:         if (!validator.slashed) {
412:             // Normal case: update and use the updated cumulative.
413:             updateRewardPerTokenForValidator($, token, validatorId);
414:             uint256 finalCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
415:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, finalCumulativeRewardPerToken);
416:         } else {
417:             // Slashed validator case: calculate what cumulative should be up to the slash timestamp.
418:             // We DO NOT call updateRewardPerTokenForValidator here because its logic is incorrect for slashed validators.
419:             uint256 currentCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
420:  >>>        uint256 effectiveEndTime = validator.slashedAtTimestamp;
421:
422:             uint256 tokenRemovalTime = $.tokenRemovalTimestamps[token];
423:             if (tokenRemovalTime > 0 && tokenRemovalTime < effectiveEndTime) {
424:                 effectiveEndTime = tokenRemovalTime;
425:             }
426:
427:   >>>       uint256 validatorLastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
428:
429:   >>>       if (effectiveEndTime > validatorLastUpdateTime) {
430:                 uint256 timeSinceLastUpdate = effectiveEndTime - validatorLastUpdateTime;
431:
432:                 if (userStakedAmount > 0) {
433:                     PlumeStakingStorage.RateCheckpoint memory effectiveRewardRateChk =
434:                         getEffectiveRewardRateAt($, token, validatorId, validatorLastUpdateTime); // Use rate at start of segment
435:                     uint256 effectiveRewardRate = effectiveRewardRateChk.rate;
436:
437:                     if (effectiveRewardRate > 0) {
438:                         uint256 rewardPerTokenIncrease = timeSinceLastUpdate * effectiveRewardRate;
439:                         currentCumulativeRewardPerToken += rewardPerTokenIncrease;
440:                     }
441:                 }
442:             }
443:
444:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, currentCumulativeRewardPerToken);
445:         }
446:     }

Proof of Concept

Follow the steps in the provided gist: https://gist.github.com/IronsideSec/8b8eb5d9c902d7fd91ef9190f2bbecce

(Original report PoC steps included above.)


If you want, I can prepare a suggested patch diff that implements the recommended fix (e.g., settling to the cap and avoiding advancing validatorLastUpdateTimes in slashed/inactive branches) based strictly on the code excerpts.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

Plume Network's staking contracts keep track of rewards for stakers and validators. The file at the centre of this report is PlumeRewardLogic.sol, which contains the accounting logic that decides how much reward has accrued to a validator and its stakers for a given token. Two functions matter here:

  • updateRewardPerTokenForValidator, which advances a per-validator, per-token cumulative reward figure and records the time it last updated in validatorLastUpdateTimes[validatorId][token].
  • calculateRewardsWithCheckpoints, which is called on claim and works out the reward delta for a user, including a special path for validators that have been slashed.

Normally the updater settles rewards up to block.timestamp and then writes that timestamp into validatorLastUpdateTimes. For a validator that has been slashed or set inactive, the updater takes an early branch that writes block.timestamp and returns without settling anything. The report shows that this early write can move the last-update time past the slash or inactive timestamp, and that later claims then skip the final segment of rewards that accrued before the cap.

Setup

The report describes a Foundry-style test setup (it uses vm.warp). The preconditions are:

  1. The pUSD reward rate is set to 1e18.
  2. user1 stakes 10 ETH to validator v0.
  3. user3 stakes 10 ETH to validator v0.
  4. Time is advanced by 1000 (vm.warp(+1000)).

The report's PoC uses two stakers on the same validator: one claims before the last-update time is pushed past the cap and another claims afterwards.

Finding it

The researcher looked at the slashed and inactive branches of updateRewardPerTokenForValidator and noticed that both write validatorLastUpdateTimes[validatorId][token] = block.timestamp and then return. The comment in the code says this marks the state as "settled" up to now, but nothing is actually settled: no reward is accrued up to the slash or inactive time before the timestamp is moved.

The slashed path in calculateRewardsWithCheckpoints only accrues a final segment when effectiveEndTime > validatorLastUpdateTime, where effectiveEndTime is the slash timestamp (or the token removal timestamp if that is earlier). If the updater has already written a block.timestamp that is greater than or equal to the slash timestamp, that condition is false and the pre-cap segment is never counted. That mismatch between the two functions is the bug.

Exploitation

Step 1: Slash the validator

The validator is slashed with an expiry one day in the future:

Text
voteToSlashValidator(v0, block.timestamp + 1 days)

This auto-slashes the validator at Tslash.

Step 2: First staker claims before the cap is passed

user1 immediately calls:

Text
claim(pUSD, v0)

and receives the pre-slash rewards (the report gives roughly 9500e18 as an example). The report says user1 receives the pre-slash rewards.

Step 3: Push the last-update time past the cap

Time is advanced by 10 (vm.warp(+10)), and then anyone calls:

Text
forceSettleValidatorCommission(v0)

This invokes updateRewardPerTokenForValidator, which takes the slashed branch and writes validatorLastUpdateTimes[v0][pUSD] = now, a time after Tslash.

Step 4: Second staker claims and gets nothing

user3 calls:

Text
claim(pUSD, v0)

and receives 0, because effectiveEndTime (Tslash) is no longer greater than validatorLastUpdateTime, so the pre-slash segment is skipped. user1 has already been paid, and the under-accrued tokens stay in the treasury.

The report lists several admin flows that reach the same state:

  1. Validator gets slashed. ValidatorFacet.voteToSlashValidator(vId, expiry) sets slashedAtTimestamp = Tslash. A later admin call to ValidatorFacet.forceSettleValidatorCommission(vId), RewardsFacet.removeRewardToken(token) or RewardsFacet.setRewardRates(tokens, rates) calls PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId), whose slashed branch writes validatorLastUpdateTimes[vId][token] = now. A subsequent RewardsFacet.claim(token, vId) then computes effectiveEndTime = Tslash <= lastUpdateTime and skips the final pre-slash accrual.
  2. Validator set inactive. ValidatorFacet.setValidatorStatus(vId, false) records slashedAtTimestamp = Tinactive and pushes 0-rate checkpoints. Any later admin operation calls the updater, whose inactive branch writes validatorLastUpdateTimes[vId][token] = now, and later claims skip the final pre-inactive accrual.
  3. Token removal during or after slash/inactive. RewardsFacet.removeRewardToken(token) loops over validators calling PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId) and then createRewardRateCheckpoint($, token, vId, 0). For slashed or inactive validators the updater writes a time greater than the cap, and later claims skip the pre-cap delta.
  4. Set reward rates after slash/inactive. RewardsFacet.setRewardRates(tokens, rates) (or setMaxRewardRate(token, newMax)) calls createRewardRateCheckpoint, which first calls updateRewardPerTokenForValidator. The updater writes validatorLastUpdateTimes[vId][token] = now for slashed or inactive validators, and later claims skip the last pre-cap segment.

Root cause

The slashed and inactive branches of updateRewardPerTokenForValidator advance validatorLastUpdateTimes to block.timestamp without first settling rewards up to the cap time. The relevant code is:

Solidity
File: attackathon-plume-network/plume/src/lib/PlumeRewardLogic.sol
135:

136:     function updateRewardPerTokenForValidator(
137:         PlumeStakingStorage.Layout storage $, address token, uint16 validatorId
140:     ) internal {
141:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId]; // Get validator info
142:
143:         // --- REORDERED SLASHED/INACTIVE CHECKS ---
144:         // Check for slashed state FIRST since slashed validators are also inactive
145:         if (validator.slashed) {
146:             // For slashed validators, no further rewards or commission accrue.
147:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
148:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
149:
150:             // Add a defensive check: A slashed validator should never have any stake. If it does, something is
151:             // wrong with the slashing logic itself.
152:             if ($.validatorTotalStaked[validatorId] > 0) {
153:                 revert InternalInconsistency("Slashed validator has non-zero totalStaked");
154:             }
155:             return;
156:         } else if (!validator.active) {
157:             // For inactive (but not slashed) validators, no further rewards or commission accrue.
158:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
159:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
160:             return;
161:         }
164:         // --- END REORDERED CHECKS ---
...
203:         // Update last global update time for this validator/token AFTER all calculations for the segment
204:         $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
205:     }

400:   function calculateRewardsWithCheckpoints(
401:         PlumeStakingStorage.Layout storage $,
402:         address user,
403:         uint16 validatorId,
404:         address token,
405:         uint256 userStakedAmount
406:     ) internal returns (uint256 totalUserRewardDelta, uint256 totalCommissionAmountDelta, uint256 effectiveTimeDelta) {
407:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId];
408:
411:         if (!validator.slashed) {
412:             // Normal case: update and use the updated cumulative.
413:             updateRewardPerTokenForValidator($, token, validatorId);
414:             uint256 finalCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
415:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, finalCumulativeRewardPerToken);
416:         } else {
417:             // Slashed validator case: calculate what cumulative should be up to the slash timestamp.
418:             // We DO NOT call updateRewardPerTokenForValidator here because its logic is incorrect for slashed validators.
419:             uint256 currentCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
420:  >>>        uint256 effectiveEndTime = validator.slashedAtTimestamp;
421:
422:             uint256 tokenRemovalTime = $.tokenRemovalTimestamps[token];
423:             if (tokenRemovalTime > 0 && tokenRemovalTime < effectiveEndTime) {
424:                 effectiveEndTime = tokenRemovalTime;
425:             }
426:
427:   >>>       uint256 validatorLastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
428:
429:   >>>       if (effectiveEndTime > validatorLastUpdateTime) {
430:                 uint256 timeSinceLastUpdate = effectiveEndTime - validatorLastUpdateTime;
431:
432:                 if (userStakedAmount > 0) {
433:                     PlumeStakingStorage.RateCheckpoint memory effectiveRewardRateChk =
434:                         getEffectiveRewardRateAt($, token, validatorId, validatorLastUpdateTime); // Use rate at start of segment
435:                     uint256 effectiveRewardRate = effectiveRewardRateChk.rate;
436:
437:                     if (effectiveRewardRate > 0) {
438:                         uint256 rewardPerTokenIncrease = timeSinceLastUpdate * effectiveRewardRate;
439:                         currentCumulativeRewardPerToken += rewardPerTokenIncrease;
440:                     }
441:                 }
442:             }
443:
444:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, currentCumulativeRewardPerToken);
445:         }
446:     }

The slashed path in calculateRewardsWithCheckpoints sets effectiveEndTime = validator.slashedAtTimestamp and only accrues a final segment if effectiveEndTime > validatorLastUpdateTime. Advancing validatorLastUpdateTimes to now (greater than or equal to the cap) makes that condition false, so the pre-cap segment is skipped.

Impact

The report rates this High, with impact summarised as theft of unclaimed yield: underpayment of users and validator commission. Users are underpaid for the final pre-cap time segment, validator commission for that segment is under-accrued, and the treasury retains more tokens than intended. The magnitude is described as missed_time_segment × applicable_rate × stake / precision, aggregated over affected users and tokens. The report argues that likelihood and impact are high because common admin actions (settlement, rate updates, token removal) occur often and call the updater.

Fix

The report recommends the following:

  1. In updateRewardPerTokenForValidator, do not advance validatorLastUpdateTimes in the slashed or inactive branches.
  2. Alternatively, when transitioning a validator to slashed or inactive, immediately settle rewards up to the cap and set validatorLastUpdateTimes to exactly that cap time, then prevent any advancement past the cap while the validator remains slashed or inactive.
  3. Ensure checkpoint creation paths that invoke the updater either skip calling it when the validator is slashed or inactive, or use updater logic that respects the cap and never moves lastUpdateTimes beyond it.

The report does not state that a patch was applied.

Variants to test

  1. Other early-return branches in reward updaters. Look for functions that write a last-update timestamp and return before accruing. A positive result is a claim path that reads that timestamp and skips a segment it should have counted.
  2. Cap-based reward calculations. Anywhere a reward calculation uses effectiveEndTime (slash time, removal time, deactivation time) and compares it with a stored last-update time, check whether an admin path can move the stored time past the cap. A positive result is a claim that returns zero or less than the expected pre-cap amount after an admin operation.
  3. Token removal loops. Check whether removing a reward token iterates over validators and calls an updater that writes timestamps for slashed or inactive validators. A positive result is a later claim that misses the segment before removal.
  4. Rate-change paths. Check whether setRewardRates or setMaxRewardRate creates a checkpoint that calls the updater first. A positive result is the same skipped segment after a rate change on a slashed or inactive validator.

Hunting notes

This kind of bug tends to hide in accounting code where a state transition (slash, deactivate, remove token, change rate) and a timestamp write happen in different functions. The signal during review is an early-return branch that writes a "last updated" value without first computing the accrual up to the event time, combined with a claim path that compares an event timestamp against that stored value. The report shows impact by running two stakers on the same validator: one claims before the timestamp is advanced and is paid, the other claims after and receives zero, while the tokens stay in the treasury.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 20 min read.

What happened, in plain words

Plume Network runs staking contracts. People put tokens into these contracts, and the contracts pay them rewards over time. A validator is the party that does the work behind the scenes, and stakers back validators with their tokens. The contracts have to keep a running tally of how much reward each staker and each validator has earned so far.

This report is about a mistake in that tally. When a validator is punished ("slashed") or switched off ("inactive"), the contract is supposed to stop counting rewards at the moment of the punishment. Instead, a later routine admin action moves the "last counted" marker forward to the current time, past the punishment moment. When a staker then asks for their rewards, the contract looks at the marker, decides there is nothing left to count, and pays zero for the final stretch of time before the punishment. The tokens that should have gone to that staker stay in the treasury.

The report shows this with two stakers on the same validator: the first one claims before the marker is moved and gets paid, the second one claims after and gets nothing.

Background you need first

A few ideas come up again and again, so here they are from zero.

Smart contract. A program that lives on a blockchain. Once deployed, it runs exactly as written, and anyone can call its functions. Think of it as a vending machine: you press a button, it follows its internal rules, and nobody can reach inside to change the rules afterwards.

Token. A digital unit of value tracked by the blockchain. Here the reward token is called pUSD.

Staking. Locking tokens inside a contract for a period of time. In return the contract pays rewards. It is like a savings account where the interest is calculated by code rather than a bank.

Validator. In this system, the party that stakers delegate their stake to. Rewards are calculated per validator, and the validator also takes a commission, a small cut of the rewards.

Slashing. A penalty. If a validator misbehaves, the system marks it as slashed. From that moment on, no new rewards should accrue for that validator or its stakers. The moment of slashing is a timestamp, a point in time recorded by the contract.

Inactive. A softer version of the same idea: an admin switches the validator off. Again, rewards should stop at that moment.

Timestamp. A number representing a moment in time, usually seconds since 1 January 1970. Contracts compare timestamps to work out how much time has passed.

Accrual. The gradual build-up of rewards as time passes. If a reward rate is 5 tokens per second and 10 seconds pass, 50 tokens have accrued. The contract does not pay out every second; it stores a running total and works out the difference when someone claims.

Claim. The action a staker takes to collect the rewards that have accrued to them.

Treasury. The pool of tokens the contract holds and pays rewards from. If rewards are under-counted, the leftover tokens simply stay there.

Function. A named block of code inside a contract that can be called, like claim or voteToSlashValidator. When you see something written as name(arguments), that is a function being called with those inputs.

Admin function. A function only a privileged account can call, used for housekeeping: settling commissions, changing rates, removing tokens.

Foundry and vm.warp. Foundry is a toolkit for testing smart contracts. vm.warp is a test helper that jumps the simulated clock forward, so a test can pretend time has passed without waiting. It exists only in tests, not on the live chain.

1e18. A compact way of writing a very large number: 1 followed by 18 zeros. Tokens on blockchains usually have 18 decimal places, so 1e18 represents one whole token in the smallest units.

Wei and ETH. ETH is the main currency of the Ethereum-style blockchain. A wei is the smallest unit of ETH, and one ETH is a very large number of wei. The report uses ETH to describe how much each staker put in.

Gist. A small page on GitHub used to share a snippet of text or code. The report links to one containing the proof of concept.

Proof of concept (PoC). A concrete demonstration, usually a test, that shows the bug actually happening rather than just describing it.

Severity. A label for how serious a bug is. High means significant loss or a serious break in the rules, but not a total collapse of the system.

Theft of unclaimed yield. The bug category used here. "Yield" means the rewards generated by staking. "Unclaimed" means nobody has collected them yet. The phrase describes a situation where rewards that should reach users are instead left behind or lost.

The two functions at the centre of it

The report points at one file, PlumeRewardLogic.sol, and two functions inside it.

updateRewardPerTokenForValidator is the bookkeeper. It works out how much reward has built up for a validator and a token since the last time it ran, adds that to a running total, and records the current time in a storage slot called validatorLastUpdateTimes[validatorId][token]. That slot is the "last counted up to here" marker. The notation [validatorId][token] simply means the marker is stored separately for every combination of validator and token, like a row and column in a spreadsheet.

calculateRewardsWithCheckpoints is the payer. It runs when someone claims. For a normal validator it calls the bookkeeper and then works out the user's share. For a slashed validator it takes a special path: it does not call the bookkeeper, because the bookkeeper's behaviour for slashed validators is wrong. Instead it works out the reward up to the slash timestamp itself, but only if the slash timestamp is later than the stored marker.

That last condition is where the bug lives. If something has already pushed the marker past the slash timestamp, the condition is false, the final stretch is never counted, and the claim pays nothing for it.

Setting up the demonstration

The report describes a test written with Foundry. The preconditions are:

  1. The pUSD reward rate is set to 1e18.
  2. user1 stakes 10 ETH to validator v0.
  3. user3 stakes 10 ETH to validator v0.
  4. Time is advanced by 1000 (vm.warp(+1000)).

Why two stakers on the same validator? Because the bug only becomes visible when one staker claims before the marker is pushed past the cap and another claims afterwards.

Finding the mistake

The researcher read the slashed and inactive branches of updateRewardPerTokenForValidator and noticed that both do the same thing: they write validatorLastUpdateTimes[validatorId][token] = block.timestamp and then return. The code comment claims this marks the state as "settled" up to now. But nothing has been settled. No reward has been calculated up to the slash or inactive moment before the marker is moved.

Then the researcher looked at the slashed path in calculateRewardsWithCheckpoints. That path only counts a final stretch when effectiveEndTime > validatorLastUpdateTime, where effectiveEndTime is the slash timestamp, or the token removal timestamp if that is earlier. If the bookkeeper has already written a current time that is greater than or equal to the slash timestamp, the condition is false and the stretch before the cap is never counted. The two functions disagree about what the marker means, and that disagreement is the bug.

Exploitation, step by step

Step 1: Slash the validator

The validator is slashed with an expiry one day in the future:

Text
voteToSlashValidator(v0, block.timestamp + 1 days)

Line by line: voteToSlashValidator is the function that starts the slashing process. v0 is the validator being slashed. block.timestamp + 1 days is the expiry, a moment one day after the current block's time. The report says this auto-slashes the validator at a moment it calls Tslash. The expiry is the deadline by which the slashing takes effect; the important part for the bug is that a slash timestamp gets recorded.

Step 2: The first staker claims before the cap is passed

user1 immediately calls:

Text
claim(pUSD, v0)

Line by line: claim is the function a staker calls to collect rewards. pUSD is the token being claimed. v0 is the validator the stake is delegated to. The report says user1 receives the pre-slash rewards, giving roughly 9500e18 as an example figure. At this point the marker validatorLastUpdateTimes[v0][pUSD] is still below Tslash, so the slashed path in calculateRewardsWithCheckpoints sees effectiveEndTime > validatorLastUpdateTime and counts the stretch. This step matters because it shows the system can pay correctly when the marker has not yet been moved. It also sets up the contrast: user1 is now paid.

Step 3: Push the last-update time past the cap

Time is advanced by 10 (vm.warp(+10)), and then anyone calls:

Text
forceSettleValidatorCommission(v0)

Line by line: vm.warp(+10) moves the simulated clock forward by 10 units, so the current time is now after Tslash. forceSettleValidatorCommission is an admin function that settles the validator's commission. Internally it calls updateRewardPerTokenForValidator, which takes the slashed branch and writes validatorLastUpdateTimes[v0][pUSD] = now, a time after Tslash. This is the harmful write. The marker now claims that everything up to the present has been counted, when in fact the stretch between the previous marker and Tslash was never counted. In the PoC, anyone calls forceSettleValidatorCommission(v0), which triggers the harmful write.

Step 4: The second staker claims and gets nothing

user3 calls:

Text
claim(pUSD, v0)

Line by line: same function, same token, same validator, but a different staker. The report says user3 receives 0, because effectiveEndTime (Tslash) is no longer greater than validatorLastUpdateTime. The stretch before the slash is skipped. user1 has already been paid, and the under-counted tokens stay in the treasury. This is the loss: a staker who did everything right gets nothing for a period during which their stake was earning rewards.

The admin flows that reach the same state

The report lists four common sequences that end in the same broken state. They matter because they are ordinary operations, not exotic attacks.

  1. Validator gets slashed. ValidatorFacet.voteToSlashValidator(vId, expiry) sets slashedAtTimestamp = Tslash. Later, an admin calls ValidatorFacet.forceSettleValidatorCommission(vId), or RewardsFacet.removeRewardToken(token), or RewardsFacet.setRewardRates(tokens, rates). Each of those calls PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId), whose slashed branch writes validatorLastUpdateTimes[vId][token] = now. A later RewardsFacet.claim(token, vId) then computes effectiveEndTime = Tslash <= lastUpdateTime and skips the final pre-slash accrual.
  2. Validator set inactive. An admin calls ValidatorFacet.setValidatorStatus(vId, false), which records slashedAtTimestamp = Tinactive and pushes 0-rate checkpoints. Any later admin operation calls the bookkeeper, whose inactive branch writes validatorLastUpdateTimes[vId][token] = now, and later claims skip the final pre-inactive accrual.
  3. Token removal during or after slash or inactive. An admin calls RewardsFacet.removeRewardToken(token). That loops over validators, calling PlumeRewardLogic.updateRewardPerTokenForValidator($, token, vId) and then createRewardRateCheckpoint($, token, vId, 0). For slashed or inactive validators the bookkeeper writes a time greater than the cap, and later claims skip the pre-cap stretch.
  4. Set reward rates after slash or inactive. An admin calls RewardsFacet.setRewardRates(tokens, rates), or setMaxRewardRate(token, newMax). That calls createRewardRateCheckpoint, which first calls updateRewardPerTokenForValidator. The bookkeeper writes validatorLastUpdateTimes[vId][token] = now for slashed or inactive validators, and later claims skip the last pre-cap stretch.

A word on the names: a "facet" is a module of a larger contract system, so ValidatorFacet groups validator-related functions and RewardsFacet groups reward-related ones. A "checkpoint" is a saved record of a value at a moment in time, so createRewardRateCheckpoint stores the reward rate as it stands now, and a 0-rate checkpoint records that the rate has dropped to zero.

The root cause in the code

The slashed and inactive branches of updateRewardPerTokenForValidator advance validatorLastUpdateTimes to block.timestamp without first settling rewards up to the cap time. Here is the relevant code:

Solidity
File: attackathon-plume-network/plume/src/lib/PlumeRewardLogic.sol
135:

136:     function updateRewardPerTokenForValidator(
137:         PlumeStakingStorage.Layout storage $, address token, uint16 validatorId
140:     ) internal {
141:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId]; // Get validator info
142:
143:         // --- REORDERED SLASHED/INACTIVE CHECKS ---
144:         // Check for slashed state FIRST since slashed validators are also inactive
145:         if (validator.slashed) {
146:             // For slashed validators, no further rewards or commission accrue.
147:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
148:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
149:
150:             // Add a defensive check: A slashed validator should never have any stake. If it does, something is
151:             // wrong with the slashing logic itself.
152:             if ($.validatorTotalStaked[validatorId] > 0) {
153:                 revert InternalInconsistency("Slashed validator has non-zero totalStaked");
154:             }
155:             return;
156:         } else if (!validator.active) {
157:             // For inactive (but not slashed) validators, no further rewards or commission accrue.
158:             // We just update the timestamp to the current time to mark that the state is "settled" up to now.
159:   >>>       $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
160:             return;
161:         }
164:         // --- END REORDERED CHECKS ---
...
203:         // Update last global update time for this validator/token AFTER all calculations for the segment
204:         $.validatorLastUpdateTimes[validatorId][token] = block.timestamp;
205:     }

400:   function calculateRewardsWithCheckpoints(
401:         PlumeStakingStorage.Layout storage $,
402:         address user,
403:         uint16 validatorId,
404:         address token,
405:         uint256 userStakedAmount
406:     ) internal returns (uint256 totalUserRewardDelta, uint256 totalCommissionAmountDelta, uint256 effectiveTimeDelta) {
407:         PlumeStakingStorage.ValidatorInfo storage validator = $.validators[validatorId];
408:
411:         if (!validator.slashed) {
412:             // Normal case: update and use the updated cumulative.
413:             updateRewardPerTokenForValidator($, token, validatorId);
414:             uint256 finalCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
415:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, finalCumulativeRewardPerToken);
416:         } else {
417:             // Slashed validator case: calculate what cumulative should be up to the slash timestamp.
418:             // We DO NOT call updateRewardPerTokenForValidator here because its logic is incorrect for slashed validators.
419:             uint256 currentCumulativeRewardPerToken = $.validatorRewardPerTokenCumulative[validatorId][token];
420:  >>>        uint256 effectiveEndTime = validator.slashedAtTimestamp;
421:
422:             uint256 tokenRemovalTime = $.tokenRemovalTimestamps[token];
423:             if (tokenRemovalTime > 0 && tokenRemovalTime < effectiveEndTime) {
424:                 effectiveEndTime = tokenRemovalTime;
425:             }
426:
427:   >>>       uint256 validatorLastUpdateTime = $.validatorLastUpdateTimes[validatorId][token];
428:
429:   >>>       if (effectiveEndTime > validatorLastUpdateTime) {
430:                 uint256 timeSinceLastUpdate = effectiveEndTime - validatorLastUpdateTime;
431:
432:                 if (userStakedAmount > 0) {
433:                     PlumeStakingStorage.RateCheckpoint memory effectiveRewardRateChk =
434:                         getEffectiveRewardRateAt($, token, validatorId, validatorLastUpdateTime); // Use rate at start of segment
435:                     uint256 effectiveRewardRate = effectiveRewardRateChk.rate;
436:
437:                     if (effectiveRewardRate > 0) {
438:                         uint256 rewardPerTokenIncrease = timeSinceLastUpdate * effectiveRewardRate;
439:                         currentCumulativeRewardPerToken += rewardPerTokenIncrease;
440:                     }
441:                 }
442:             }
443:
444:             return _calculateRewardsCore($, user, validatorId, token, userStakedAmount, currentCumulativeRewardPerToken);
445:         }
446:     }

Line by line, in plain words:

  • The File: line names the file the excerpt comes from. The numbers on the left are line numbers in that file, so you can find the same code in the repository.
  • function updateRewardPerTokenForValidator( starts the bookkeeper function. The $ parameter is a storage pointer, a way of reaching the contract's saved data. token is which reward token, and validatorId is which validator. internal means only other code in the same contract can call it.
  • Line 141 loads the validator's record from storage into a variable called validator, so the code can read its fields.
  • Lines 143 to 144 are comments explaining that the slashed check comes first, because a slashed validator is also inactive and the code must not fall through to the inactive branch.
  • Line 145 checks validator.slashed. If true, the next lines run.
  • Lines 146 to 147 are comments. They say no further rewards accrue and that the timestamp is being updated to mark the state as settled. The second comment is the misleading one: the state is not actually settled, because no reward was calculated first.
  • Line 148, marked with >>> to draw attention, is the harmful write. It sets the marker for this validator and token to the current block's timestamp. This is the line that can jump the marker past the slash time.
  • Lines 150 to 154 are a safety check. If the validator still has stake recorded, the function reverts, meaning it aborts and undoes everything. The comment explains that a slashed validator should have no stake, so a non-zero value would mean the slashing logic itself is broken. This check does not prevent the bug, because the problem is the timestamp write, not the stake balance.
  • Line 155 returns, ending the function early. Nothing after this line runs for a slashed validator.
  • Line 156 handles the other case: the validator is not slashed but is not active either.
  • Lines 157 to 158 are comments with the same claim about settling.
  • Line 159, also marked with >>>, is the same harmful write for the inactive case.
  • Line 160 returns early.
  • Line 164 closes the special-case block.
  • Lines 203 to 204 are the normal path, reached only by validators that are neither slashed nor inactive. Here the marker is written after the reward calculations for the stretch have been done, which is the correct order.
  • Line 205 closes the function.
  • Line 400 starts calculateRewardsWithCheckpoints, the function that runs on a claim. Its parameters are the storage pointer, the user, the validator, the token and how much the user has staked. It returns three numbers: the user's reward, the commission amount and the time stretch used.
  • Line 407 loads the validator record.
  • Line 411 checks whether the validator is not slashed. If so, line 413 calls the bookkeeper to bring the running total up to date, line 414 reads the updated total, and line 415 hands off to a helper that splits the total between the user and the commission.
  • Line 416 begins the slashed case.
  • Lines 417 to 418 are comments. They say the code works out the total up to the slash timestamp and deliberately does not call the bookkeeper, because the bookkeeper's logic is wrong for slashed validators. The comment says the bookkeeper's logic is incorrect for slashed validators, so it is not called here.
  • Line 419 reads the current running total.
  • Line 420, marked with >>>, sets effectiveEndTime to the slash timestamp. This is the cap: rewards should be counted up to here and no further.
  • Lines 422 to 425 adjust the cap if the token was removed earlier than the slash. tokenRemovalTime is when the token was removed; if that is positive and earlier than the current cap, the cap moves back to the removal time. Rewards cannot accrue for a token that no longer exists.
  • Line 427, marked with >>>, reads the stored marker for this validator and token.
  • Line 429, marked with >>>, is the condition that decides whether any final stretch is counted: the cap must be later than the marker. If the marker has been pushed past the cap, this is false and the whole block is skipped.
  • Line 430 works out how much time lies between the marker and the cap.
  • Line 432 checks that the user actually has stake. With zero stake there is nothing to reward.
  • Lines 433 to 435 look up the reward rate that applied at the start of the stretch.
  • Lines 437 to 440 do the arithmetic: time multiplied by rate gives the increase in the running total, which is added on. If the rate is zero, nothing is added.
  • Line 444 hands the updated total to the helper that splits it between the user and the commission.
  • Line 446 closes the function.

The slashed path in calculateRewardsWithCheckpoints sets effectiveEndTime = validator.slashedAtTimestamp and only accrues a final stretch if effectiveEndTime > validatorLastUpdateTime. Advancing validatorLastUpdateTimes to now, which is greater than or equal to the cap, makes that condition false, so the stretch before the cap is skipped. The existing defensive check in the slashed branch, which reverts if validatorTotalStaked[validatorId] > 0, does not help, because the problem is the timestamp write, not the stake balance.

What it costs

The report rates this High, with impact summarised as theft of unclaimed yield: underpayment of users and validator commission. Users are underpaid for the final stretch of time before the cap, validator commission for that stretch is under-counted, and the treasury keeps more tokens than intended. The size of the loss is described as missed_time_segment × applicable_rate × stake / precision, added up over affected users and tokens. In plain words: how long the missed stretch was, multiplied by the reward rate, multiplied by how much the user had staked, divided by a scaling factor the contract uses for precision. The report argues that likelihood and impact are high because common admin actions, such as settlement, rate updates and token removal, happen often and all call the bookkeeper.

The fix the report recommends

The report recommends the following:

  1. In updateRewardPerTokenForValidator, do not advance validatorLastUpdateTimes in the slashed or inactive branches.
  2. Alternatively, when transitioning a validator to slashed or inactive, immediately settle rewards up to the cap and set validatorLastUpdateTimes to exactly that cap time, then prevent any advancement past the cap while the validator remains slashed or inactive.
  3. Ensure checkpoint creation paths that invoke the bookkeeper either skip calling it when the validator is slashed or inactive, or use bookkeeper logic that respects the cap and never moves lastUpdateTimes beyond it.

The report does not state that a patch was applied.

Variants to test

If you are reviewing similar code, these are the places to look. Each one names what to search for and what a positive result looks like.

  1. Other early-return branches in reward updaters. Look for functions that write a last-update timestamp and return before accruing. A positive result is a claim path that reads that timestamp and skips a stretch it should have counted.
  2. Cap-based reward calculations. Anywhere a reward calculation uses effectiveEndTime (slash time, removal time, deactivation time) and compares it with a stored last-update time, check whether an admin path can move the stored time past the cap. A positive result is a claim that returns zero or less than the expected pre-cap amount after an admin operation.
  3. Token removal loops. Check whether removing a reward token iterates over validators and calls an updater that writes timestamps for slashed or inactive validators. A positive result is a later claim that misses the stretch before removal.
  4. Rate-change paths. Check whether setRewardRates or setMaxRewardRate creates a checkpoint that calls the updater first. A positive result is the same skipped stretch after a rate change on a slashed or inactive validator.

Notes for anyone hunting this kind of bug

This kind of bug tends to hide in accounting code where a state change (slash, deactivate, remove token, change rate) and a timestamp write happen in different functions. The signal during review is an early-return branch that writes a "last updated" value without first computing the accrual up to the event time, combined with a claim path that compares an event timestamp against that stored value. The report shows the impact by running two stakers on the same validator: one claims before the timestamp is advanced and is paid, the other claims after and receives zero, while the tokens stay in the treasury.

Glossary

  • Accrual: the gradual build-up of rewards as time passes, stored as a running total rather than paid every second.
  • Admin function: a function only a privileged account can call, used for housekeeping such as settling commissions or changing rates.
  • Blockchain: a shared, tamper-resistant record of transactions maintained by many computers.
  • Block timestamp: the time recorded with the current block, used by contracts to measure how much time has passed.
  • Cap: the moment at which rewards must stop counting, here the slash or inactive timestamp, or the token removal time if earlier.
  • Checkpoint: a saved record of a value at a particular moment, such as the reward rate at a given time.
  • Commission: the validator's cut of the rewards earned by its stakers.
  • Contract: see smart contract.
  • 1e18: shorthand for 1 followed by 18 zeros, the usual way to write one whole token in smallest units.
  • ETH: the main currency of the Ethereum-style blockchain; a wei is its smallest unit.
  • Facet: a module of a larger contract system, grouping related functions such as validator operations or reward operations.
  • Foundry: a toolkit for building and testing smart contracts, including helpers to simulate time passing.
  • Function: a named block of code that can be called with inputs, written as name(arguments).
  • Gist: a small GitHub page for sharing a snippet of text or code.
  • High severity: a label for a serious bug involving significant loss or a serious break in the rules, short of total collapse.
  • Inactive: a validator switched off by an admin, after which no new rewards should accrue.
  • Internal: a Solidity keyword meaning a function can only be called from within the same contract or contracts derived from it.
  • Marker: the stored "last counted up to here" time, held in validatorLastUpdateTimes[validatorId][token].
  • pUSD: the reward token used in the report's example.
  • Proof of concept (PoC): a concrete demonstration, usually a test, that shows a bug actually happening.
  • Revert: abort the current call and undo its changes, usually because a check failed.
  • Reward rate: how many reward tokens accrue per unit of time per unit of stake.
  • Slashing: a penalty that marks a validator as misbehaving, after which no new rewards should accrue.
  • Smart contract: a program deployed on a blockchain that runs exactly as written and can be called by anyone.
  • Staking: locking tokens in a contract for a period in return for rewards.
  • Storage: the part of a contract that keeps data between calls, like a database.
  • Theft of unclaimed yield: a bug category where rewards that should reach users are left behind or lost.
  • Validator: the party that stakers delegate their stake to, earning rewards and taking a commission.
  • vm.warp: a Foundry test helper that jumps the simulated clock forward.
  • Wei: the smallest unit of ETH.
  • Yield: the rewards generated by staking.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.