Skip to content
Smart contracts Audit finding Intermediate

Double effective stake decrement freezes unstake permanently after validator exit

Calling requestDelegationExit decrements the effective stake for a period, and when the validator later reaches EXITED status, unstake applies a second decrement for the same period. This causes an arithmetic underflow so every unstake attempt reverts, permanently freezing the user's staked VET.

TianYu4n Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

60311 sc high double effective stake decrement freezes unstake permanently after validator exit

Submitted on Nov 21st 2025 at 08:45:14 UTC by @TianYu4n for Audit Comp | Vechain | Stargate Hayabusa

Description

Brief/Intro

Calling requestDelegationExit records a first effective-stake decrement, util validator status changed to EXITED, USER try to call unstake , and enters the EXITED/PENDING branch and applies a second decrement for the same period, causing an underflow (panic 0x11) before any transfers.

Vulnerability Details

  • First decrement: requestDelegationExit calls _updatePeriodEffectiveStakefor the next period (Stargate.sol #L568).
  • Second decrement: unstake in the currentValidatorStatus == EXITED || status == PENDING branch calls _updatePeriodEffectiveStake again Stargate.sol (#L266-#L283), leading to underflow when the checkpointed value is already zero.

Impact Details

Once triggered, every unstake attempt reverts; delegations cannot be changed, so the user’s staked VET remains locked in the staking contract. Funds are not stolen but are permanently frozen.

Affected flow: stake + delegate → requestDelegationExit (first decrement) → validator becomes EXITED → any unstake reverts on second decrement.

References

add a status judge before call _updatePeriodEffectiveStake in unstake.

Solidity
bool shouldDecrement = (delegation.status == DelegationStatus.PENDING) ||
    (currentValidatorStatus == VALIDATOR_STATUS_EXITED && delegation.status == DelegationStatus.NONE); // or some other scenery can do decreament
if (shouldDecrement) {
    _updatePeriodEffectiveStake(..., false);
} else {
    // status == EXITED has been decreased in requestDelegationExit, skip
}

Link to Proof of Concept

https://gist.github.com/2298233831/6f45209c73b685fd619c933c08abe16b

Proof of Concept

Proof of Concept

TypeScript
it("poc: double decrement keeps reverting unstake even on repeated attempts", async () => {
        const userAddress = user.address;
        const fmt = (wei: bigint) => ethers.formatEther(wei);

        const balUserStart = await ethers.provider.getBalance(userAddress);
        const balContractStart = await ethers.provider.getBalance(stargateContract);
        console.log(
            `start balances => user: ${fmt(balUserStart)} VET, contract: ${fmt(balContractStart)} VET`
        );

        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();
        console.log(`tokenId minted: ${tokenId.toString()}`);

        tx = await stargateContract.connect(user).delegate(tokenId, validator.address);
        await tx.wait();
        console.log("delegated to validator");

        tx = await protocolStakerMock.helper__setValidationCompletedPeriods(validator.address, 2);
        await tx.wait();
        console.log("validator completedPeriods set to 2 (delegation ACTIVE)");

        tx = await stargateContract.connect(user).requestDelegationExit(tokenId);
        await tx.wait();
        console.log("requested exit (first decrement applied)");

        tx = await protocolStakerMock.helper__setValidatorStatus(
            validator.address,
            VALIDATOR_STATUS_EXITED
        );
        await tx.wait();
        console.log("validator forced to EXITED before unstake");

        const balUserPreUnstake = await ethers.provider.getBalance(userAddress);
        const balContractPreUnstake = await ethers.provider.getBalance(stargateContract);
        console.log(
            `before unstake => user: ${fmt(balUserPreUnstake)} VET, contract: ${fmt(balContractPreUnstake)} VET`
        );

        for (let i = 1; i <= 3; i++) {
            try {
                console.log(`unstake attempt ${i}`);
                await stargateContract.connect(user).unstake(tokenId);
                console.log("unexpectedly succeeded");
            } catch (error: any) {
                console.log(`unstake attempt ${i} reverted: ${error.shortMessage || error.message}`);
            }
        }

        const balUserAfter = await ethers.provider.getBalance(userAddress);
        const balContractAfter = await ethers.provider.getBalance(stargateContract);
        console.log(
            `after failed unstakes => user: ${fmt(balUserAfter)} VET, contract: ${fmt(balContractAfter)} VET`
        );
    });

The original report as published on Immunefi, by TianYu4n. 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 the unstake function does not check whether the effective-stake decrement was already applied by requestDelegationExit, so it decrements the same period twice.

Impact

Every unstake attempt reverts, so the user's staked VET remains locked in the staking contract and cannot be recovered; funds are not stolen but are permanently frozen.

What the attacker needed

User has staked VET and delegated; validator reaches EXITED status; user calls requestDelegationExit first

The fix

The unstake function should skip the effective-stake decrement when the delegation status is EXITED, because requestDelegationExit already applied it.

How it was found

  1. Stake VET and delegate the resulting token to a validator.
  2. Advance the validator so the delegation becomes active.
  3. Call requestDelegationExit, which applies the first effective-stake decrement.
  4. Force the validator status to EXITED.
  5. Call unstake, which applies a second decrement and reverts with an underflow.

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 staking contract tracks how much stake is active in each period. When a user asks to leave a validator, the contract lowers that count once. Later, when the user tries to withdraw, the contract lowers the same count again even though it is already zero, so the maths fails and the withdrawal is blocked. The user's tokens are not stolen, but they cannot get them back.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by TianYu4n

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.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.