60557 sc high double decrement of effective stake in unstake leads to dos and permanent fund lock

Submitted on Nov 24th 2025 at 04:15:28 UTC by @xanony for Audit Comp | Vechain | Stargate Hayabusaarrow-up-right

  • Report ID: #60557

  • 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

A double decrement of effective stake occurs when a user requests to exit a delegation and subsequently the validator exits (or is forced to exit). This causes an arithmetic underflow in the Stargate.sol contract, preventing the user from unstaking their NFT and retrieving their staked VET.

Vulnerability Details

The Stargate contract tracks the "effective stake" of delegators for each validator to calculate rewards. This effective stake is updated (increased or decreased) when users delegate, unstake, or request to exit. When a user requests to exit an active delegation via requestDelegationExit, the contract decreases the effective stake for the validator:

// Stargate.sol
function requestDelegationExit(uint256 _tokenId) external ... {
    // ...
    // decrease the effective stake
    _updatePeriodEffectiveStake($, delegation.validator, _tokenId, completedPeriods + 2, false);
    // ...
}

Later, when the user calls unstake to claim their funds (after the exit period), the contract checks the validator status. If the validator has exited (status VALIDATOR_STATUS_EXITED), the contract attempts to decrease the effective stake again:

The core issue: If the validator exits (voluntarily or forced) after the user has requested an exit but before they unstake, both conditions are met. The effective stake is decremented twice for the same delegation. Since _updatePeriodEffectiveStake performs a subtraction (currentValue - effectiveStake), the second decrement will cause an arithmetic underflow and revert if the currentValue (total effective stake for that validator) is less than the user's effective stake. This is guaranteed to happen if the user is the only delegator or if the remaining effective stake is smaller than the user's stake amount. The unstake function does not verify whether an exit was already requested before attempting to decrement the effective stake when the validator has exited. This oversight leads to the double accounting error.

Impact Details

This vulnerability results in a complete Denial of Service for affected users and permanent loss of their staked funds:

Direct Financial Impact:

  • Users' staked VET tokens become permanently locked in the Stargate contract

  • The staking NFT cannot be retrieved or transferred

  • No recovery mechanism exists once this state is reached

Permanent fund lock: The arithmetic underflow causes unstake() to revert every time it's called, making it impossible for users to ever retrieve their staked VET

No admin recovery: There is no emergency withdrawal or admin function that can rescue locked funds

Predictable occurrence: This is not a rare edge case - validator exits are normal protocol operations, and users may have legitimate reasons for delays between requesting exit and unstaking

Complete loss: Users lose 100% of their staked VET amount plus the NFT itself

Attack Scenario: While this doesn't require malicious intent, the sequence naturally occurs:

  1. User stakes 10,000 VET and receives delegation NFT

  2. User requests to exit delegation (effective stake decremented)

  3. Validator exits or is forced to exit

  4. User attempts to unstake their 10,000 VET

  5. Transaction reverts with Panic(0x11) - arithmetic underflow

  6. User's 10,000 VET is permanently locked

This represents a critical vulnerability where users can lose their entire stake through normal protocol operations with no possibility of recovery.

Proof of Concept

Proof of Concept

Was this helpful?