Skip to content
Business logic Audit finding Intermediate

Inconsistency in how stake cooldown is handled due to off by one error

The staking contract uses inconsistent boundary comparisons for withdrawal eligibility and slash eligibility, so a stake whose cooldown end equals the slash timestamp can be both withdrawable and slashable in the same block. Depending on transaction ordering, a user could withdraw tokens that were still slashable, or a user's stake could be locked because the slash logic still treats it as slashable.

silver_eth Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52865 sc high inconsistency in how stake cooldown is handled due to off by one error

Submitted on Aug 13th 2025 at 19:12:10 UTC by @silver_eth for Attackathon | Plume Network

Description

Brief/Intro
Inconsistency in how the cooldown / slash logic is handled causes a stake to be simultaneously withdrawable and slashable in the same block due to an off-by-one style comparison mismatch.

Vulnerability Details

The staking logic treats a stake as withdrawable when:

Solidity
block.timestamp >= cooldownEndTime

However, the cooldown is considered fully processed only if:

Solidity
cooldownEndTime < slashTimestamp

This creates a conflict when:

Solidity
cooldownEndTime == slashTimestamp

In that case:

  • Because block.timestamp == cooldownEndTime, the cooldown is considered fulfilled and the stake can be withdrawn.
  • But since cooldownEndTime !< slashTimestamp, the slash logic still considers the stake slashable.

Thus a stake can be concurrently withdrawable and slashable within the same block.

Impact Details

Two possible undesirable outcomes exist depending on how transactions are ordered within the same block:

  • Premature withdrawals / protocol loss: If the intended invariant is cooldownEnd < slashTimestamp, a user can withdraw a stake that is still slashable, effectively removing tokens that the protocol intended to keep available for slashing (protocol loss/theft).
  • Permanent lock-up: If the intended invariant is block.timestamp >= cooldownEndTime for withdrawal, a user’s stake can become permanently locked because the slash logic still treats it as slashable and the user cannot withdraw if the slash occurs in the same block.

These outcomes can lead to permanent freezing of funds or direct theft of user funds (other than unclaimed yield).

Proof of Concept

{% stepper %} {% step %}

Setup / Conditions

  1. Two users (User A and User B) unstake in block A. Both receive the same cooldownEndTime.
  2. At block B (B == cooldownEndTime), the validator is slashed. {% endstep %}

{% step %}

Transaction ordering in block B

  • If User A’s withdrawal transaction is processed before the slash transaction:
    • User A successfully withdraws their stake (because block.timestamp >= cooldownEndTime).
    • The subsequent slash cannot affect User A’s withdrawn tokens, resulting in protocol loss / theft.
  • If User B’s withdrawal transaction is processed after the slash transaction:
    • The slash marks the stake as slashable and the withdrawal may be prevented, potentially leaving User B’s stake locked or lost. {% endstep %}

{% step %}

Outcome

Both users had identical cooldownEndTime, yet only one could successfully withdraw depending on intra-block ordering. This results in either:

  • A user withdrawing tokens that were still slashable (stealing from the protocol), or
  • A user being unable to withdraw despite their cooldown being reached (permanent lock-up). {% endstep %} {% endstepper %}

References

Notes / Suggested focus for remediation

{% hint style="info" %} Align the comparison semantics for "withdrawable" and "cooldown fully processed" so the same boundary (<= or <) is used consistently. Typical fixes include:

  • Making both checks inclusive (e.g., use <= consistently where appropriate), or
  • Adjusting the slash timestamp logic so it differs by at least one second from cooldownEndTime in a deterministic manner. Carefully consider expected invariants and document the intended ordering to avoid intra-block ambiguity. {% endhint %}

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

Impact

Depending on intra-block ordering, a user could withdraw tokens that were still slashable (protocol loss) or be unable to withdraw despite reaching the cooldown end (permanent lock-up).

What the attacker needed

A staking position with a cooldown; validator slashed at the cooldown boundary block; favourable transaction ordering in that block

The fix

The comparison semantics for withdrawal and slash eligibility should be aligned so the same boundary is used consistently, or the slash timestamp should be deterministically offset from the cooldown end time.

How it was found

  1. Two users unstake in the same block and receive the same cooldown end time.
  2. At the block where the cooldown end time is reached, the validator is slashed.
  3. If a user's withdrawal is processed before the slash, the user withdraws tokens that were still slashable.
  4. If a user's withdrawal is processed after the slash, the stake may be marked slashable and the withdrawal prevented.

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 lets people lock tokens and later take them back after a waiting period called a cooldown. The code checks 'can I withdraw?' and 'can this still be punished (slashed)?' using slightly different rules at the exact same moment, so one check says yes and the other also says yes. That means the same tokens can be taken out and also marked for punishment, and which happens first depends on transaction order in a block.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by silver_eth

View all

8 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.