Double-calling _updatePeriodEffectiveStake during the exit flow makes unstake revert, trapping staked VET.
When a delegator requests an exit while their validator is still active and the validator then exits before the delegator calls unstake, the contract subtracts the delegator's effective stake twice. The second subtraction underflows, so unstake always reverts and the staked VET is locked.
- Disclosed after under an hour
59564 sc high double calling updateperiodeffectivestake during the exit flow makes unstake revert trapping staked vet
Submitted on Nov 13th 2025 at 15:30:43 UTC by @niffylord for Audit Comp | Vechain | Stargate Hayabusa
- Report ID: #59564
- 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 funds
Description
Brief / Intro
If a delegator signals exit while their validator is still active and the validator subsequently exits before the delegator calls unstake, Stargate.sol subtracts the delegator’s effective stake twice. The second subtraction underflows, so unstake reverts forever and the user’s VET remains locked.
Vulnerability Details
requestDelegationExitimmediately reduces the validator checkpoint for the exiting token via_updatePeriodEffectiveStake(..., false)to ensure future rewards omit the delegator.【F:packages/contracts/contracts/Stargate.sol†L523-L569】- Later,
unstakechecks the validator status. If it seesVALIDATOR_STATUS_EXITED, it runs_updatePeriodEffectiveStake(..., false)again, assuming the reduction has not yet happened.【F:packages/contracts/contracts/Stargate.sol†L260-L283】 - Because checkpoints store deltas, the second subtraction reuses the same
(validator, tokenId, period)entries. When the validator had little remaining stake, the subtraction underflows and Solidity panics (0x11), reverting the entire transaction. No retry can succeed because the same branch keeps triggering.
Impact Details
{% hint style="danger" %}
- Any delegator whose validator exits between
requestDelegationExitandunstakeloses the ability to withdraw the principal VET;unstakereverts every time. - Rewards also remain unclaimable because the contract burns the NFT only after a successful
unstake. - Multiple users delegating to the same validator can be griefed as soon as that validator decides to exit, causing a protocol-wide denial of service on capital.
- Chosen impact category: Permanent freezing of funds (Critical) — user-controlled VET becomes unreachable indefinitely. {% endhint %}
Suggested Mitigations
- Track whether
_updatePeriodEffectiveStakealready ran for the exiting delegation (e.g., store a boolean flag per token or delegation) and skip the second decrease inunstake. - Alternatively, recompute the current checkpoint value in
unstakeand only subtract when the stored amount is greater than or equal to the token’s effective stake. - Refactor the flow so validator status transitions trigger the checkpoint adjustment once, removing duplicate calls from user entry points.
References
Stargate.solrequestDelegationExit: first checkpoint decrease.【F:packages/contracts/contracts/Stargate.sol†L523-L569】Stargate.solunstake: second checkpoint decrease on exited validators.【F:packages/contracts/contracts/Stargate.sol†L260-L283】_updatePeriodEffectiveStake: raw subtraction without underflow guard.【F:packages/contracts/contracts/Stargate.sol†L993-L1012】- Unit test reproducer:
Delegation.test.ts“should revert unstake after requesting exit if validator exits before unstake.”【F:packages/contracts/test/unit/Stargate/Delegation.test.ts†L205-L231】
Proof of Concept
{% stepper %} {% step %}
Step
Stake an NFT and delegate it to a validator that is currently active. {% endstep %}
{% step %}
Step
Advance periods so the delegation is active, then call requestDelegationExit.
{% endstep %}
{% step %}
Step
Advance one more period and mark the validator status as EXITED.
{% endstep %}
{% step %}
Step
Call unstake; it attempts the second subtraction and reverts with panic 0x11.
{% endstep %}
{% endstepper %}
Relevant test from packages/contracts/test/unit/Stargate/Delegation.test.ts:
205:243:packages/contracts/test/unit/Stargate/Delegation.test.ts
it("should revert unstake after requesting exit if validator exits before unstake", async () => {
const levelSpec = await stargateNFTMock.getLevel(LEVEL_ID);
tx = await stargateContract.connect(user).stake(LEVEL_ID, {
value: levelSpec.vetAmountRequiredToStake,
});
await tx.wait();
const tokenId = await stargateNFTMock.getCurrentTokenId();
// Delegate to an active validator
tx = await stargateContract.connect(user).delegate(tokenId, validator.address);
await tx.wait();
// Make the delegation active
tx = await protocolStakerMock.helper__setValidationCompletedPeriods(
validator.address,
2
);
await tx.wait();
// Request exit while validator is still active (first decrease)
tx = await stargateContract.connect(user).requestDelegationExit(tokenId);
await tx.wait();
// Advance one more period so the delegation can exit and then force the validator to exit too
tx = await protocolStakerMock.helper__setValidationCompletedPeriods(
validator.address,
3
);
await tx.wait();
tx = await protocolStakerMock.helper__setValidatorStatus(
validator.address,
VALIDATOR_STATUS_EXITED
);
await tx.wait();
// Unstake attempts to decrease the effective stake a second time and underflows
await expect(stargateContract.connect(user).unstake(tokenId)).to.be.revertedWithPanic(0x11);
});
// ... existing code ...
Testing
- Regression covered by
packages/contracts/test/unit/Stargate/Delegation.test.ts. - To reproduce:
yarn contracts:test:unit(fails before fix with panic0x11, passes once mitigation is applied).
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 exit checkpoint adjustment is applied in both requestDelegationExit and unstake without tracking that it already ran, so the second raw subtraction underflows.
Impact
Any delegator whose validator exits between requesting exit and unstaking could permanently lose access to their principal VET, and rewards also remain unclaimable, potentially affecting multiple users of the same validator.
What the attacker needed
A staked and delegated NFT; validator exits before unstake
The fix
The flow should record that the checkpoint adjustment already ran (for example a per-token flag) and skip the second decrease in unstake, or only subtract when the stored amount is at least the token's effective stake.
How it was found
- Stake an NFT and delegate it to an active validator.
- Advance periods so the delegation is active, then call requestDelegationExit.
- Advance one more period and mark the validator status as EXITED.
- Call unstake; it attempts the second subtraction and reverts with panic 0x11.
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 user stakes VET (a cryptocurrency) through a smart contract and assigns it to a validator, a party that helps run the network. When the user asks to leave, the contract already removes their stake from the validator's totals once. If the validator also leaves before the user finishes withdrawing, the contract removes the same stake a second time, which is impossible because the number is already zero, so the withdrawal fails every time and the money stays stuck.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.