Skip to content
Business logic Audit finding Intermediate

Off-by-one in Stargate.sol _claimableDelegationPeriods lets exited NFTs siphon validator rewards, leading to protocol insolvency

An off-by-one error in the _claimableDelegationPeriods function of Stargate.sol allows an exited NFT to continue claiming validator rewards for periods after its delegation ended. An attacker could repeatedly claim these rewards, diverting other delegators' unclaimed yield and potentially draining the reward pool to insolvency.

ElouJoe Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

60019 sc high off by one in stargate sol claimabledelegationperiods lets exited nfts siphon validator rewards leading to protocol insolvency

Submitted on Nov 17th 2025 at 15:40:21 UTC by @ElouJoe for Audit Comp | Vechain | Stargate Hayabusa

Description

Brief/Intro

An off-by-one in Stargate.sol’s _claimableDelegationPeriods allows an exited NFT to keep claiming future validator rewards after its delegation ended, diverting other delegators’ VTHO and ultimately draining the reward pool to insolvency.

Vulnerability Details

When an exit is requested, endPeriod is set. After the user claims through the true endPeriod, lastClaimedPeriod = endPeriod, so nextClaimablePeriod becomes endPeriod + 1 and the check endPeriod > nextClaimablePeriod fails. The code falls back to (nextClaimablePeriod, completedPeriods) and treats the NFT as still active. This lets post-exit periods be claimed indefinitely.

Affected code: _claimableDelegationPeriods in packages/contracts/contracts/Stargate.sol.

Impact Details

  • Theft of other delegators’ unclaimed yield each completed period (misrouted to the exited NFT).
  • Persistent drain escalates to Critical: Protocol insolvency as the reward stream is continuously siphoned.

References

Link to Proof of Concept

https://gist.github.com/eloufirjawad/283c7077fdccd6eee3953ff4125a5be6

Proof of Concept

{% stepper %} {% step %}

Step 1

Stake and delegate an NFT (attacker) to a valid validator; also stake and delegate a second NFT (honest user) so the validator has a non-zero denominator. {% endstep %}

{% step %}

Step 2

Advance validator completed periods until the delegation is ACTIVE and claimable. {% endstep %}

{% step %}

Step 3

Call requestDelegationExit(attackerTokenId); advance until exit finalizes (endPeriod set and currentValidatorPeriod > endPeriod). {% endstep %}

{% step %}

Step 4

Claim once to bring lastClaimedPeriod up to endPeriod (this makes nextClaimablePeriod = endPeriod + 1). {% endstep %}

{% step %}

Step 5

Advance one or more periods; observe claimableRewards(attackerTokenId) > 0 even though status is EXITED, because endPeriod > nextClaimablePeriod is false and the function falls back to (nextClaimablePeriod, completedPeriods). {% endstep %}

{% step %}

Step 6

Call claimRewards(attackerTokenId); attacker receives VTHO for post‑exit periods. Repeat steps 5–6 indefinitely. {% endstep %} {% endstepper %}

What proves the bug

  • After claiming through endPeriod, claimableRewards remains positive for each new completed period and claimRewards continues paying the exited NFT.
  • Root cause: once lastClaimedPeriod == endPeriod, nextClaimablePeriod = endPeriod + 1, making endPeriod > nextClaimablePeriod false; _claimableDelegationPeriods falls back to (nextClaimablePeriod, completedPeriods), treating the NFT as still active and enabling post‑exit claims.

How to run the in-repo PoC

One-liner (copy/paste):

Bash
cd /Users/jawad/Documents/Python/Crypto/Immunefi/vechain/stargate-contracts-jose-update-contracts-to-hayabusa/packages/contracts && VITE_APP_ENV=local yarn hardhat test --network hardhat test/unit/Stargate/DelegationBugGhostRewards.test.ts

Two-step:

Bash
cd /Users/jawad/Documents/Python/Crypto/Immunefi/vechain/stargate-contracts-jose-update-contracts-to-hayabusa/packages/contracts

export VITE_APP_ENV=local

yarn hardhat test --network hardhat test/unit/Stargate/DelegationBugGhostRewards.test.ts

If you want, I can:

  • Extract the exact vulnerable code snippet from the referenced repository and include a minimal annotated excerpt,
  • Suggest a minimal patch (preserving original semantics) to fix the off-by-one logic.

The original report as published on Immunefi, by ElouJoe. 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 error in the condition `endPeriod > nextClaimablePeriod` causes the function to fall back to treating the NFT as active when `lastClaimedPeriod` equals `endPeriod`.

Impact

The attacker could steal other delegators' unclaimed yield each period, and persistent draining could lead to protocol insolvency.

What the attacker needed

Attacker stakes and delegates an NFT; Honest user stakes and delegates an NFT; Validator has completed periods

The fix

The off-by-one condition should be corrected so that exited NFTs cannot claim rewards for periods after their endPeriod.

How it was found

  1. Stake and delegate an NFT (attacker) to a valid validator; also stake and delegate a second NFT (honest user) so the validator has a non-zero denominator.
  2. Advance validator completed periods until the delegation is ACTIVE and claimable.
  3. Call `requestDelegationExit(attackerTokenId)`; advance until exit finalizes (`endPeriod` set and `currentValidatorPeriod > endPeriod`).
  4. Claim once to bring `lastClaimedPeriod` up to `endPeriod` (this makes `nextClaimablePeriod = endPeriod + 1`).
  5. Advance one or more periods; observe `claimableRewards(attackerTokenId) > 0` even though status is EXITED, because `endPeriod > nextClaimablePeriod` is false and the function falls back to `(nextClaimablePeriod, completedPeriods)`.
  6. Call `claimRewards(attackerTokenId)`; attacker receives VTHO for post‑exit periods. Repeat steps 5–6 indefinitely.

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.

This report describes a bug in a smart contract that manages staking rewards. When a user exits their delegation, the contract is supposed to stop paying them rewards for future periods. However, due to a small mistake in the code, the contract still thinks the exited NFT is active and keeps paying it rewards that belong to other users. This can slowly drain the reward pool and make the protocol insolvent.

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