The delegator s rewards in period 1 cannot be claimed
The Stargate contract records a delegation to a queued validator as effective from period 2, while the protocol staker treats it as effective from period 1. As a result, the delegator's rewards for period 1 cannot be claimed and remain stuck in the StargateNFT contract.
- Disclosed after under an hour
59866 sc high the delegator s rewards in period 1 cannot be claimed
Submitted on Nov 16th 2025 at 14:41:35 UTC by @shaflow1 for Audit Comp | Vechain | Stargate Hayabusa
- Report ID: #59866
- 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: Permanent freezing of unclaimed yield
Description
Brief / Intro
When a validator is in the Queue rather than Active, completedPeriods will return 0, and CurrentIteration will also return 0. Adding a delegate to a validator in this state should take effect in period 1 (current + 1 = 0 + 1 = 1) and start accruing rewards.
However, the _delegate function in the Stargate contract does not account for this special case and records the delegate as taking effect in period 2 (completedPeriods + 2 = 0 + 2) for reward accrual. This causes the delegator to be unable to claim the delegate rewards for period 1, and the rewards get stuck in the StargateNFT contract.
Vulnerability Details
First, the intended logic in the protocol staker contract (Go code excerpt) for adding a delegation:
func (s *Staker) AddDelegation(...) (*big.Int, error) {
//...
// add delegation on the next iteration - val.CurrentIteration() + 1,
current, err := val.CurrentIteration(currentBlock)
if err != nil {
return nil, err
}
delegationID, err := s.delegationService.Add(validator, current+1, stake, multiplier)
//...
}
func (v *Validation) CurrentIteration(currentBlock uint32) (uint32, error) {
// Unknown, Queued return 0
if v.Status == StatusUnknown || v.Status == StatusQueued {
return 0, nil
}
// Exited, from active or queued
if v.Status == StatusExit {
return v.CompletedPeriods, nil
}
// Active(signaled exit)
// Once signaled exit, complete iterations is set to the current
// iteration of the time that exit is signaled
if v.CompletedPeriods > 0 {
return v.CompletedPeriods, nil
}
// Active
if currentBlock < v.StartBlock {
return 0, errors.New("curren block cannot be less than start block")
}
if v.Period == 0 {
return 0, errors.New("period cannot be zero")
}
elapsedBlocks := currentBlock - v.StartBlock
completedPeriods := elapsedBlocks / v.Period
return completedPeriods + 1, nil
}
Under normal circumstances, completedPeriods + 1 = currentPeriods, and a delegation takes effect in the next period, so the effective period is completedPeriods + 2.
However, there is a special case: if the validator is in the Queue state rather than Active, completedPeriods = currentPeriods = 0. In this case, the effective period of the delegation should be completedPeriods + 1.
In the Stargate contract _delegate function, the special case is not considered and the effective period is always recorded as completedPeriods + 2:
function _delegate(StargateStorage storage $, uint256 _tokenId, address _validator) private {
//...
// if the delegation is pending or the validator is exited or unknown
// decrease the effective stake of the previous validator
if (
currentValidatorStatus == VALIDATOR_STATUS_EXITED ||
status == DelegationStatus.PENDING
) {
// get the completed periods of the previous validator
(, , , uint32 oldCompletedPeriods) = $
.protocolStakerContract
.getValidationPeriodDetails(currentValidator);
// decrease the effective stake of the previous validator
_updatePeriodEffectiveStake(
$,
currentValidator,
_tokenId,
oldCompletedPeriods + 2,
false // decrease
);
}
//...
// Get the latest completed period of the validator
(, , , uint32 completedPeriods) = $.protocolStakerContract.getValidationPeriodDetails(
_validator
);
// update the mappings regarding the delegation
$.delegationIdByTokenId[_tokenId] = delegationId;
// update the last claimed period to the current period of the validator
// (aka: claimable periods will be from the next period)
$.lastClaimedPeriod[_tokenId] = completedPeriods + 1; // current period
// Increase the delegators effective stake in the next period
_updatePeriodEffectiveStake($, _validator, _tokenId, completedPeriods + 2, true);
//...
}
Because of this, when delegating to a validator in the QUEUED state, the Stargate contract sets the effective stake starting in period 2, while lastClaimedPeriod[_tokenId] is set to period 1. This mismatch leaves the rewards for period 1 permanently unclaimable.
Impact Details
If a delegation is made to a validator that is in the Queue:
_updatePeriodEffectiveStakewill set the effective period to period 2,lastClaimedPeriod[_tokenId]is set to period 1.
This results in the user's staking delegation rewards for period 1 being unclaimable. The delegation rewards will become stuck in the Stargate contract (StargateNFT), effectively freezing yield.
Proof of Concept
The following integration test demonstrates the issue by delegating to a queued validator and checking the effective stake periods:
it("Delegation created to a queued validator should result in pending delegation with periodEffectiveStake = 2", async () => {
// --- Stake NFT (Level 1) ---
const levelId = 1;
const levelSpec = await stargateNFTContract.getLevel(levelId);
const levelVetAmountRequired = levelSpec.vetAmountRequiredToStake;
const stakeTx = await stargateContract
.connect(user)
.stake(levelId, { value: levelVetAmountRequired });
await stakeTx.wait();
log("\n🎉 Staked NFT of level", levelId);
const tokenId = await stargateNFTContract.getCurrentTokenId();
// fast-forward to maturity
await mineBlocks(Number(levelSpec.maturityBlocks));
expect(await stargateNFTContract.isUnderMaturityPeriod(tokenId)).to.be.false;
const validatorQueued = (await ethers.getSigners())[5];
// --- Add validator with very small stake so that it remains QUEUED ---
const tx = await protocolStakerContract
.connect(validatorQueued)
.addValidation(
validatorQueued.address,
12,
{ value: ethers.parseEther("25000000") } // insufficient to become Active
);
await tx.wait();
const validationInfo = await protocolStakerContract.getValidation(
validatorQueued.address
);
const status = validationInfo[4];
expect(status).to.equal(1); // 1 = QUEUED
log("\n🎯 Validator is in QUEUED state");
// --- delegate to queued validator ---
const delegateTx = await stargateContract
.connect(user)
.delegate(tokenId, validatorQueued.address);
await delegateTx.wait();
log("\n🎉 Delegated NFT to queued validator", validatorQueued.address);
// fetch delegationId
const delegationId = await stargateContract.getDelegationIdOfToken(tokenId);
expect(delegationId).to.not.equal(0);
// --- Check delegation status is pending ---
const delegationStatus = await stargateContract.getDelegationStatus(tokenId);
expect(delegationStatus).to.equal(1n); // 1 = pending
const EffectiveStake1 = await stargateContract.getDelegatorsEffectiveStake(validatorQueued.address ,1);
const EffectiveStake2 = await stargateContract.getDelegatorsEffectiveStake(validatorQueued.address ,2);
console.log("EffectiveStake1:" + EffectiveStake1);
console.log("EffectiveStake2:" + EffectiveStake2);
const [startPeriod, endPeriod] = await protocolStakerContract.getDelegationPeriodDetails(delegationId);
console.log("StartPeriod in StakingContract:" + startPeriod);
});
To run the POC, add the above code to packages/contracts/test/integration/Delegation.test.ts and run the integration tests.
Based on test logs (attachments), when delegation is performed while the validator is in the QUEUED state, the rewards begin to take effect from period 2 (EffectiveStake = 2) in the Stargate contract, whereas in the protocolStakerContract the delegation is effective from period 1. This discrepancy causes rewards from period 1 to be unclaimable.
References
- Stargate.sol (target): https://github.com/immunefi-team/audit-comp-vechain-stargate-hayabusa/tree/main/packages/contracts/contracts/Stargate.sol
- Protocol staker AddDelegation & CurrentIteration reference: https://github.com/vechain/thor/blob/bffc3378d5d8aa346433ae911495bcc3952b265d/builtin/staker/staker.go#L535
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 _delegate function always sets the effective stake period to completedPeriods + 2, without handling the queued-validator case where completedPeriods is 0 and the correct effective period is 1.
Impact
The delegator's staking rewards for period 1 are permanently unclaimable and become stuck in the StargateNFT contract, freezing yield.
What the attacker needed
A staked NFT past maturity; a validator in the QUEUED state
The fix
The _delegate function should set the effective stake period to completedPeriods + 1 when the validator is queued, matching the protocol staker's logic.
How it was found
- Stake an NFT of level 1 and wait until it is past maturity.
- Add a validator with a stake too small to become active, so it stays in the QUEUED state.
- Delegate the staked NFT to that queued validator.
- Check the delegator's effective stake for periods 1 and 2 and the delegation start period in the protocol staker.
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 you delegate tokens to a validator, the system records which period your rewards start from. For a validator that is still waiting in a queue, the two contracts disagree: one says rewards start in period 1, the other says period 2. Because of that gap, the rewards earned in period 1 are never paid out and stay locked in the contract.
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.