57799 sc low retroactive lock period changes affect existing stakes

Submitted on Oct 28th 2025 at 23:16:49 UTC by @Another for Audit Comp | Belongarrow-up-right

  • Report ID: #57799

  • Report Type: Smart Contract

  • Report severity: Low

  • Target: https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/periphery/Staking.sol

  • Impacts:

    • Contract fails to deliver promised returns, but doesn't lose value

Description

Brief/Intro

The setMinStakePeriod function allows the contract owner to change the minimum stake period, which retroactively affects all existing stakes.

Vulnerability Details

The setMinStakePeriod function allows the contract owner to change the minimum stake period:

Staking.sol — setMinStakePeriod
    /// @dev Reverts if `period == 0`.
    /// @param period New minimum stake period in seconds.
    function setMinStakePeriod(uint256 period) external onlyOwner {
        require(period > 0, MinStakePeriodShouldBeGreaterThanZero());
        minStakePeriod = period;/
        emit MinStakePeriodSet(period);
    }

Each stake recorded in the deposit function only sets a timestamp without storing the minStakePeriod that was in effect at deposit time. During withdrawal, the _consumeUnlockedSharesOrRevert function uses the current global minStakePeriod for all stake validation:

Because the contract uses a single global minStakePeriod for validation, changing minStakePeriod retroactively affects all existing stakes and can either shorten or extend their effective lock times.

Recommendation: store an explicit end timestamp (unlock time) for each stake at deposit time, and validate against that stored value when withdrawing. This prevents retroactive changes to lock lengths for already-created stakes.

Impact Details

If the minStakePeriod is increased after a user deposited, users who would otherwise be able to withdraw their shares can be prevented from withdrawing until the new (longer) period elapses — effectively extending the lock on already existing stakes.

Proof of Concept

chevron-rightTest demonstrating that increasing minStakePeriod blocks withdrawal for existing stakeshashtag

Add the following test to staking.test.ts

References

chevron-rightSource lines referencedhashtag
  • https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/periphery/Staking.sol#L128-L134

  • https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/periphery/Staking.sol#L245

  • https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/periphery/Staking.sol#L260

Was this helpful?