Skip to content
DoS Audit finding Intermediate

An Exited delegator who has not unstaked or delegated to a validator, will be DOS'ed if a validator exits.

A delegator who has requested to exit but not yet unstaked can be blocked from unstaking if their validator also exits, because the contract subtracts the delegator's effective stake from the validator's total a second time, causing an underflow panic. This can permanently freeze the delegator's funds if the validator never returns.

HalalAudits Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

60548 sc high an exited delegator who has not unstaked or delegated to a validator will be dos ed if a validator exits

Submitted on Nov 24th 2025 at 00:47:20 UTC by @HalalAudits for Audit Comp | Vechain | Stargate Hayabusa

Description

Brief/Intro

The checks in unstake and delegate will subtract a delegator's effective stake from the delegatorsEffectiveStake[_validator] if the delegation is still pending or the validator has exited.

An issue arises incase a delegator has exited and before unstaking or redelegating to a new validator, the validator also exits, which will lead to subtracting an already subtracted value leading to a panic due to underflow hence preventing the delegator from recovering their amount.

Vulnerability Details

Before unstaking or delegating to a new validator, a delegator must first call requestDelegationExit to show his exit intent and his effective stake is subtracted from the validtaor's delegatorsEffectiveStake[_validator] for the next period.

Solidity
   // decrease the effective stake
   _updatePeriodEffectiveStake($, delegation.validator, _tokenId, completedPeriods + 2, false);
Solidity
    function _updatePeriodEffectiveStake(
        StargateStorage storage $,
        address _validator,
        uint256 _tokenId,
        uint32 _period,
        bool _isIncrease
    ) private {
        // calculate the effective stake
        uint256 effectiveStake = _calculateEffectiveStake($, _tokenId);

        // get the current effective stake
        uint256 currentValue = $.delegatorsEffectiveStake[_validator].upperLookup(_period);

        // calculate the updated effective stake
        uint256 updatedValue = _isIncrease
            ? currentValue + effectiveStake
            : currentValue - effectiveStake;

        // push the updated effective stake
        $.delegatorsEffectiveStake[_validator].push(_period, SafeCast.toUint224(updatedValue));
    }

But if this previous validator exits( which is possible since a validator can exit anytime) before the delegator unstakes or redelegates (a delegator is not given any period in which to unstake or redelegate so it can also be a longer period), the effectiveStake will be subtracted again from the validator's delegatorsEffectiveStake[_validator] due to these checks in unstake and delegate:

Solidity
        if (
            currentValidatorStatus == VALIDATOR_STATUS_EXITED ||
            delegation.status == DelegationStatus.PENDING
        ) {
            // get the completed periods of the previous validator
            (, , , uint32 oldCompletedPeriods) = $
                .protocolStakerContract
                .getValidationPeriodDetails(delegation.validator);

            // decrease the effective stake of the previous validator
            _updatePeriodEffectiveStake(
                $,
                delegation.validator,
                _tokenId,
                oldCompletedPeriods + 2,
                false // decrease
            );
        }

As you can see in the above check will be true if the validator has exited regardless of whether the delegator had exited before the validator's exit hence guaranteeing a re-subtraction of the validator's delegatorsEffectiveStake[_validator].

Yet this amount was already subtracted in the call to requestDelegationExit before.

VulnerabiltyPath

  • Delegator A has delegated his stake to validator B, and he is the only delegator to this validator.
  • After sometime Delegator A wants to unstake so he calls requestDelegationExit.
  • But before Delegator A calls unstake, validator B also exits.
  • So when Delegator A tries to call unstake, the function just reverts with a panic due to underflow.
  • Delegator A will lose his funds forever if validator B does not become a validator again.

Impact Details

This will prevent users from being able to unstake or redelegate their funds due to the underflow panic hence a total loss of funds.

Some such exited delegators will be able to collect their funds if the funds are still huge but it will be inevitable for the last unstakers from this exited validator to lose their funds as with each unstake the delegatorsEffectiveStake[_validator] reduces upto the last one where it will underflow.

This can also be done by a malicious validator to prevent delegators from unstaking their funds.

References

Proof of Concept

Proof of Concept

Paste the test below and run yarn contracts:test:unit -- -- --grep "For an exited delegaotor, cannot unstake if validator exited"

JavaScript
it("For an exited delegaotor, cannot unstake if validator exited", async () => {
        // stake the token
        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();
        log("\n🎉 Staked token with id:", tokenId);

        // delegate the token to the validator
        tx = await stargateContract.connect(user).delegate(tokenId, validator.address);
        await tx.wait();
        log("\n🎉 Delegated token to validator", validator.address);

        tx = await protocolStakerMock.helper__setValidationCompletedPeriods(validator.address, 2);
        await tx.wait();
        log("\n🎉 Set validator completed periods to 2 so the delegation is active");
        
        //@audit user requests an exit
        const pendingTx = stargateContract.connect(user).requestDelegationExit(tokenId);

        tx = await protocolStakerMock.helper__setValidationCompletedPeriods(validator.address, (2 + 2));
        await tx.wait();
        log("\n🎉 Set validator completed periods to 2 + 2 so the delegation should be able to unstake");

        //@audit but before completing the exit the validator also exits
        await protocolStakerMock.helper__setValidatorStatus(
            validator.address,
            VALIDATOR_STATUS_EXITED
        );

        //@audit the user will not be able to unstake or even delegate, due to a panic in resubtacting,
        //effective stake which is zero hence an underflow
        //Panic code 0x11 represents overflow or underflo
        await expect(stargateContract.connect(user).unstake(tokenId)).to.be.revertedWithPanic(0x11);

    });

The original report as published on Immunefi, by HalalAudits. 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 and delegate functions unconditionally subtract the delegator's effective stake from the validator's total when the validator has exited, even if that stake was already subtracted during requestDelegationExit.

Impact

The delegator cannot unstake or redelegate, leading to a temporary or permanent freezing of funds; the report notes that some may recover funds if the validator's total stake is large enough, but the last unstakers will lose funds.

What the attacker needed

Delegator has delegated to a validator; delegator calls requestDelegationExit; validator exits before delegator unstakes

The fix

The contract should track whether a delegator's effective stake has already been subtracted and avoid subtracting it again when the validator exits.

How it was found

  1. Delegator stakes tokens and delegates to a validator.
  2. Delegator calls requestDelegationExit to signal exit intent.
  3. Before the delegator unstakes, the validator exits.
  4. Delegator calls unstake, which reverts with a panic due to 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.

When you delegate tokens to a validator, the contract tracks how much stake each validator has from all delegators. If you ask to exit, your stake is removed from that total. But if the validator also exits before you actually unstake, the contract tries to remove your stake again, which makes the total go negative and the transaction fails. This means you cannot get your tokens back unless the validator becomes active again.

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