Inflated earned() / UI rewards when validator stake is zero due to missing totalStaked guard in view logic
The view function that calculates rewards keeps accruing reward-per-token during periods when a validator has zero total stake, while the state-changing path correctly stops accrual. As a result, earned() and UI displays show users more rewards than they can actually claim.
- Disclosed after under an hour
51455 sc low inflated earned ui rewards when validator stake is zero due to missing totalstaked guard in view logic
Submitted on Aug 3rd 2025 at 00:12:53 UTC by @Rhaydden for Attackathon | Plume Network
- Report ID: #51455
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/lib/PlumeRewardLogic.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
calculateRewardsWithCheckpointsView keeps accruing reward-per-token during any period where a validator’s totalStaked is zero, whereas the state-changing path (updateRewardPerTokenForValidator) correctly stops accrual. The mismatch causes earned() and all UI displays to show rewards users can never claim.
Vulnerability Details
In PlumeRewardLogic.sol (view path):
// VIEW path
uint256 rptIncreaseInSegment = segmentDuration * rateForSegment;
simulatedCumulativeRPT += rptIncreaseInSegment;
The loop runs for every time segment with a non zero reward rate. There is no check that the validator actually has stake during the segment.
Opposite of what the state-changing path does:
// STATE-CHANGING path
if (totalStaked > 0) {
uint256 rewardPerTokenIncrease = timeSinceLastUpdate * effectiveRewardRate;
$.validatorRewardPerTokenCumulative[validatorId][token] += rewardPerTokenIncrease;
}
When totalStaked == 0, the cumulative value on chain is frozen and only validatorLastUpdateTimes is advanced. Because the view function starts its simulation from that stored timestamp, it integrates reward rate across the zero-stake window, inflating simulatedCumulativeRPT. _calculateRewardsCore then computes an overstated user delta, so earned() differs from the value that will be paid by claim().
Conditions required for the discrepancy:
{% stepper %} {% step %} Validator is active but has momentarily zero stake (all delegators withdrew). {% endstep %}
{% step %} Reward rate for the token > 0. {% endstep %}
{% step %}
No transaction hits updateRewardPerTokenForValidator during that interval (common when there is no stake).
{% endstep %}
{% endstepper %}
Every second that passes, the gap between displayed and claimable rewards widens.
Impact Details
{% hint style="info" %} Low – contract fails to deliver promised returns, but doesn't lose value. Users see larger rewards than they can claim. {% endhint %}
Fix
Add a stake guard identical to the state-changing path:
if ($.validatorTotalStaked[validatorId] > 0 && rateForSegment > 0) {
simulatedCumulativeRPT += segmentDuration * rateForSegment;
}
References
Proof of Concept
{% stepper %} {% step %} Add validator V with reward rate R > 0. {% endstep %}
{% step %}
Delegate 100 tokens to V. Wait 1 hour; call earned(user, V) -> returns E1.
{% endstep %}
{% step %} User withdraws entire stake (totalStake becomes 0). Do nothing else for 2 hours. {% endstep %}
{% step %}
Call earned(user, V) again -> returns E2 where E2 - E1 ≈ 2 h * R.
{% endstep %}
{% step %}
Now call claim(user, V); the user only receives E1 (plus small rounding), proving the extra 2 hours of rewards were never claimable.
{% endstep %}
{% endstepper %}
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
The view path lacks a check that the validator has non-zero total stake before accruing reward-per-token, unlike the state-changing path.
Impact
Users see larger rewards than they can claim, but no funds are lost; the contract fails to deliver promised returns.
What the attacker needed
Validator has zero total stake; reward rate for the token is positive; no update transaction during the interval
The fix
Add a stake guard identical to the state-changing path so the view only accrues rewards when totalStaked is greater than zero.
How it was found
- Add a validator with a positive reward rate.
- Delegate tokens to the validator and wait, then call earned() to get a baseline value.
- Withdraw the entire stake so totalStaked becomes zero, then wait without any transactions.
- Call earned() again and observe the value has increased by roughly the reward rate times the elapsed time.
- Call claim() and see the user only receives the original baseline amount, proving the extra rewards were never claimable.
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 smart contract has two ways to calculate rewards: one that actually updates the stored value (state-changing) and one that only simulates it for display (view). The simulation forgot to stop counting rewards when nobody has staked with the validator, so the displayed number grows even though the real claimable amount does not. Users see inflated rewards in the interface that they cannot withdraw.
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.