Off-by-one in _claimableDelegationPeriods allows claimRewards() to pay for periods after delegation end — Over-claim / Theft of unclaimed yield
An off-by-one comparison in the claimable-period calculation lets a token owner claim VTHO rewards for periods after their delegation ended. An attacker can arrange the delegation end to equal the next claimable period, let the validator's completed periods advance, and then claim rewards for the extra periods.
- Disclosed after under an hour
59361 sc high off by one in claimabledelegationperiods allows claimrewards to pay for periods after delegation end over claim theft of unclaimed yield
Submitted on Nov 11th 2025 at 14:25:06 UTC by @daxun for Audit Comp | Vechain | Stargate Hayabusa
- Report ID: #59361
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-vechain-stargate-hayabusa/tree/main/packages/contracts/contracts/Stargate.sol
- Impacts:
- Theft of unclaimed yield
Description
Brief / Intro
Stargate.sol computes the range of claimable periods for a delegated token and then pays VTHO rewards for every claimable period. Due to an off-by-one conditional in _claimableDelegationPeriods, when the delegation endPeriod equals the token's nextClaimablePeriod, the function fails to cap the last claimable period at endPeriod. If the validator’s completedPeriods later advances past endPeriod, claimRewards() will allow claims up to completedPeriods — including periods after the delegation ended — causing the contract to pay rewards the token wasn’t entitled to.
Vulnerability Details
Location: packages/contracts/contracts/Stargate.sol — function _claimableDelegationPeriods(...).
https://github.com/immunefi-team/audit-comp-vechain-stargate-hayabusa/blob/e9c0bc9b0f24dc0c44de273181d9a99aaf2c31b0/packages/contracts/contracts/Stargate.sol#L879-L934
Problematic code fragment:
if (
endPeriod != type(uint32).max &&
endPeriod < currentValidatorPeriod &&
endPeriod > nextClaimablePeriod
) {
return (nextClaimablePeriod, endPeriod);
}
endPeriodis the period when the delegation ends (set totype(uint32).maxwhen no exit requested).nextClaimablePeriodislastClaimedPeriod + 1, adjusted to delegationstartPeriodif needed.currentValidatorPeriod = completedPeriods + 1(the ongoing period).
When endPeriod == nextClaimablePeriod (the equal case), the endPeriod > nextClaimablePeriod check fails. Execution falls through and later the function may return (nextClaimablePeriod, completedPeriods) (the validator's completedPeriods) if nextClaimablePeriod < currentValidatorPeriod. If completedPeriods > endPeriod, the claimable window now includes periods after endPeriod. The reward calculation _claimableRewardsForPeriod() uses stored effectiveStake values and does not verify per-period participation; therefore, the token owner receives VTHO for those extra periods.
This is a pure logic bug (off-by-one) — no race conditions, no privileged access, and reproducible with protocol state manipulation.
Impact Details
- Category: Theft of unclaimed yield (in-scope, High severity).
- Concrete impact: Token owners can receive VTHO for periods during which their token was not delegated. The attacker can:
- Create a delegation with
startPeriod = X,endPeriod = X(equal tonextClaimablePeriod), or otherwise arrange state soendPeriod == nextClaimablePeriod. - Let
completedPeriodsadvance beyondendPeriod(natural protocol progression). - Call
claimRewards()and receive rewards throughcompletedPeriods, including periods afterendPeriod.
- Create a delegation with
- Financial impact: Any amount of VTHO paid per period × number of over-claimable periods. Depending on production reward sizes and multiple tokens this can be materially high. This is direct protocol loss (funds transfer out of protocol-controlled VTHO).
- Exploit prerequisites: None privileged. Requires only an attacker-controlled token and normal protocol progression of
completedPeriods. Fully reproducible via local test harness or mainnet fork.
References
- Contract:
packages/contracts/contracts/Stargate.sol(function_claimableDelegationPeriods) - Relevant functions:
_claimRewards,_claimableRewards,_claimableRewardsForPeriodin same file. - Program scope:
Stargate.solis explicitly in-scope per the audit competition.
Proof of Concept
{% stepper %} {% step %}
Setup
- Deploy contracts (or use a mock):
Stargate(initialize withprotocolStakerContractpointing to a mockProtocolStakerandstargateNFTContractpointing to a mockStargateNFT).MockProtocolStakershould allow controllingcompletedPeriodsand provide delegation period responses.MockStargateNFTshould allow minting a token whosevetAmountStakedandlevelare known. {% endstep %}
{% step %}
Create delegation
- Create a delegation for token T:
- Ensure at delegation time
completedPeriods = N. - On delegation, Stargate sets
lastClaimedPeriod = completedPeriods + 1(which equalsN+1), sonextClaimablePeriod = N+2normally — but craft mocks so that the delegation start/end results innextClaimablePeriod == endPeriod. Achieve this by configuring the mockProtocolStakerto set delegationstartPeriodandendPeriodappropriately during PoC. {% endstep %}
- Ensure at delegation time
{% step %}
Signal exit
- Signal an exit on the delegation such that
endPeriod == nextClaimablePeriod(the equal case). For example, setendPeriodto the delegation’s start period. {% endstep %}
{% step %}
Advance validator periods
- Advance
completedPeriodson the mock to a value greater thanendPeriod. Example: setcompletedPeriods = endPeriod + 2. {% endstep %}
{% step %}
Claim rewards
- Call
Stargate.claimRewards(tokenId). {% endstep %}
{% step %}
Observe over-claim
- Observe that
claimRewards()computeslastClaimablePeriod = completedPeriodsand transfers VTHO rewards for periods including those >endPeriod. On a mock, assert that transfer amount corresponds to number of over-claimed periods. {% endstep %} {% endstepper %}
Minimal deterministic test skeleton (conceptual)
- Use a
MockProtocolStakerthat:- Returns controlled
completedPeriodsviagetValidationPeriodDetails. - When
addDelegationis called, returns a delegation id withstartPeriod = completedPeriods + 1andend = type(uint32).max. - When
signalDelegationExit(delegationId)is called, setsend = start(soend == nextClaimablePeriod). getDelegatorsRewards(validator, period)returns fixed reward per period (e.g.,1e18) so the PoC can assert transfer amounts.
- Returns controlled
- Use a
MockStargateNFTthat:mint()returns a token withvetAmountStakedandlevelthat produce a stableeffectiveStake.ownerOfreturns the attacker address.
- Run the sequence:
stakeAndDelegate()->signalDelegationExit()-> advancecompletedPeriods->claimRewards()-> assert VTHO transfer includes periods afterendPeriod.
Notes
- The root cause is an off-by-one comparison: the
>check onendPeriodexcludes the equal case, which should be capped atendPeriodto avoid paying out periods after delegation end. - Fix should ensure
endPeriod >= nextClaimablePeriod(or equivalently adjust comparisons) so the returned last claimable period is at mostendPeriodwhenendPeriodis nottype(uint32).max.
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 in the comparison that caps the last claimable period: the strict greater-than check excludes the case where the delegation end equals the next claimable period, so the cap is not applied.
Impact
A token owner could receive VTHO rewards for periods when their token was not delegated, causing direct loss of protocol-controlled VTHO; the text does not mention any defence that would limit this.
What the attacker needed
An attacker-controlled token; normal protocol progression of completed periods
The fix
The comparison should be changed so that the last claimable period is capped at the delegation end period whenever the end period is not the maximum value.
How it was found
- Deploy the Stargate contract with mock staker and NFT contracts that allow controlling completed periods and token details.
- Create a delegation for a token and configure the mock so that the delegation end period equals the next claimable period.
- Signal an exit on the delegation so that the end period equals the next claimable period.
- Advance the validator's completed periods to a value greater than the delegation end period.
- Call claimRewards for the token.
- Observe that the contract pays rewards for periods after the delegation end.
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 pays rewards for each period a token is delegated to a validator. A mistake in the code that decides which periods can be claimed means that, in one specific situation, the contract also pays for periods after the delegation has already ended. Someone can set up that situation and collect rewards they should not get.
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.