Skip to content
DoS Audit finding Intermediate

A delegator who signals exit and waits for the validator to finish its period can no longer withdraw in the unstake function causing permanent loss of funds

A delegator who requests exit while the validator is active has their effective stake removed immediately, but when the validator later exits, the unstake function attempts to remove the same stake again, causing an arithmetic underflow and reverting. This permanently locks the user's staked VET and pending rewards.

demonhat Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

60534 sc high a delegator who signals exit and waits for the validator to finish its period can no longer withdraw in the unstake function causing permanent loss of funds

Submitted on Nov 23rd 2025 at 21:08:28 UTC by @demonhat for Audit Comp | Vechain | Stargate Hayabusa

Description

Brief/Intro

A delegator who signals exit and waits for the validator to finish its period can no longer withdraw: when the validator eventually transitions to EXITED, calling unstake() underflows during the internal checkpoint update and reverts in panic 0x11. This permanently freezes the user’s staked VET and any pending rewards, so every NFT that exits after its validator leaves the set becomes stuck.

Vulnerability Details

Stargate records effective stake per future period using checkpoints. Entering a delegation writes an increase at completedPeriods + 2, and requestDelegationExit() already removes that weight immediately so the next period excludes the exiting token.

        $.protocolStakerContract.signalDelegationExit(delegationId);
        (, , , uint32 completedPeriods) = $.protocolStakerContract.getValidationPeriodDetails(
            delegation.validator
        );
        _updatePeriodEffectiveStake($, delegation.validator, _tokenId, completedPeriods + 2, false);

Later, when the owner calls unstake() after the validator has exited, the code runs the same decrement again simply because currentValidatorStatus == VALIDATOR_STATUS_EXITED, even though the stake was already removed:

        if (
            currentValidatorStatus == VALIDATOR_STATUS_EXITED ||
            delegation.status == DelegationStatus.PENDING
        ) {
            (, , , uint32 oldCompletedPeriods) =
                $.protocolStakerContract.getValidationPeriodDetails(delegation.validator);

            _updatePeriodEffectiveStake(
                $,
                delegation.validator,
                _tokenId,
                oldCompletedPeriods + 2,
                false
            );
        }

_updatePeriodEffectiveStake subtracts the token’s effective stake from whatever the validator’s checkpoint holds. After the earlier removal, the value is already zero, so the subtraction underflows and triggers panic code 0x11, reverting the entire unstake() call.

My poc test reproduces the failure end-to-end.

Impact Details

  1. Permanent freezing of funds

Users who exit while the validator is still active cannot ever reclaim their staked VET once that validator later exits; every unstake() attempt reverts due to the double decrease. This effectively locks their principal and any unclaimed rewards forever in the Stargate contract.

  • Because exit-and-redelegate is a normal lifecycle step, any validator churn can strand all delegators who requested exits before the validator left, leading to widespread fund loss and protocol deadlock.

References

Add any relevant links to documentation or code

Proof of Concept

Proof of Concept

Add this to the stake.test.ts file and run the test;


    it("should revert when unstaking after validator exit because of double effective stake decrease", async () => {
        const levelSpec = await stargateNFTMockContract.getLevel(LEVEL_ID);
        await stargateContract.connect(user).stake(LEVEL_ID, {
            value: levelSpec.vetAmountRequiredToStake,
        });
        const tokenId = await stargateNFTMockContract.getCurrentTokenId();

        // set an initial completed period so the delegation start period is deterministic
        await (
            await protocolStakerMockContract.helper__setValidationCompletedPeriods(
                validator.address,
                10
            )
        ).wait();

        await (await stargateContract.connect(user).delegate(tokenId, validator.address)).wait();

        // fast forward one period so the delegation becomes active before requesting exit
        await (
            await protocolStakerMockContract.helper__setValidationCompletedPeriods(
                validator.address,
                11
            )
        ).wait();

        await (await stargateContract.connect(user).requestDelegationExit(tokenId)).wait();

        // advance periods and mark validator as exited to trigger the additional decrease inside unstake()
        await (
            await protocolStakerMockContract.helper__setValidationCompletedPeriods(
                validator.address,
                13
            )
        ).wait();
        await (await protocolStakerMockContract.helper__setValidatorStatus(
            validator.address,
            VALIDATOR_STATUS_EXITED
        )).wait();

        await expect(stargateContract.connect(user).unstake(tokenId)).to.be.revertedWithPanic(
            0x11
        );
    });

The original report as published on Immunefi, by demonhat. 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

The unstake function unconditionally decrements the effective stake when the validator status is EXITED, even though requestDelegationExit already removed that stake, leading to a double subtraction and underflow.

Impact

Users who exit while the validator is active cannot ever reclaim their staked VET once that validator later exits; every unstake() attempt reverts, permanently freezing their principal and any unclaimed rewards.

What the attacker needed

User has staked VET and received an NFT; user delegates to a validator; user requests delegation exit while validator active; validator later exits

How it was found

  1. Stake VET to receive an NFT.
  2. Set the validator's completed periods to a known value.
  3. Delegate the NFT to the validator.
  4. Advance one period so the delegation becomes active.
  5. Request delegation exit.
  6. Advance periods and set the validator status to EXITED.

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 stake tokens, the contract tracks how much each person has staked for future periods. If you ask to leave while the validator is still running, the contract removes your stake from future periods right away. But if the validator later exits, the contract tries to remove your stake again, which is impossible because it's already zero, so the transaction fails and your tokens stay stuck.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by demonhat

View all

1 more disclosed report, 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.