Cooldown coalescing bug: Unintended cooldown extension for prior unstakes
The staking contract stores only one cooldown entry per user and validator, so a second unstake before the first matures overwrites the earlier cooldown end time. This re-locks previously unstaked funds until the later timestamp, delaying withdrawal beyond the intended cooldown period.
Originally disclosed on Immunefi
- Disclosed after under an hour
52312 sc low cooldown coalescing bug unintended cooldown extension for prior unstakes
Submitted on Aug 9th 2025 at 19:03:25 UTC by @Ambitious_DyDx for Attackathon | Plume Network
- Report ID: #52312
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/facets/StakingFacet.sol
- Impacts: Temporary freezing of funds for at least 24 hours
Description
Brief/Intro
In StakingFacet.sol, userValidatorCooldowns[user][validatorId] usually stores one {amount, cooldownEndTime} slot. When a user unstakes again for the same validator before that slot matures, _processCooldownLogic (internal function) adds the new amount and overwrites cooldownEndTime = block.timestamp + cooldownInterval. This causes earlier-unstaked funds to be re-locked until the new (later) timestamp — multiple unstakes are not independently timed.
Vulnerability Details
Relevant lines in _processCooldownLogic (lines ~818 - 848) show:
finalNewCooledAmountForSlot = currentCooledAmountInSlot + amount;
cooldownEntrySlot.amount = finalNewCooledAmountForSlot;
cooldownEntrySlot.cooldownEndTime = newCooldownEndTime; // <-- overwrites prior end
_processCooldownLogiccoalesces unstakes into a single slot and always sets a freshcooldownEndTimewhen adding to an unmatured slot.- As a result,
_processMaturedCooldownsand_calculateTotalWithdrawableAmountuse that single timestamp for maturity checks. Overwriting it hides matured portions until the new end, effectively extending their lock.
Impact Details
- Previously-unstaked funds can be re-locked for up to
cooldownIntervalwhen a later unstake occurs. - High user-impact (funds inaccessible for days), even if not stolen — opportunity cost/trust damage.
- Any user doing repeated unstakes to the same validator before the prior cooldown matures won't be able to withdraw prior unstake amounts on time.
References
Proof of Concept
{% stepper %} {% step %}
Scenario — initial unstake
- t0: call
unstake(validatorId, 100) - Resulting slot:
{ amount: 100, cooldownEndTime: t0 + cooldownInterval }{% endstep %}
{% step %}
Second unstake before first matures
- t1 = t0 + cooldownInterval - 1: call
unstake(validatorId, 50) - Code sees unmatured slot and adds amount, then sets
cooldownEndTime = t1 + cooldownInterval - Slot becomes
{ amount: 150, cooldownEndTime: t1 + cooldownInterval }{% endstep %}
{% step %}
Expected vs actual withdrawability
- At t = t0 + cooldownInterval + ε, calling
withdraw()will not include the original 100 — it remains locked untilt1 + cooldownInterval. - Observables:
getUserCooldowns(user)returns a single entry with aggregated amount and the later end.amountWithdrawable(user)att0 + interval + εdoes not include the original 100. {% endstep %} {% endstepper %}
Recommendation
Change storage to allow multiple cooldown entries per (user, validator), and push a new entry on each unstake, so each unstake has its own expiry:
struct CooldownEntry {
uint256 amount;
uint256 cooldownEndTime;
}
mapping(address => mapping(uint16 => CooldownEntry[])) userCooldownQueues;
// In _processCooldownLogic():
userCooldownQueues[user][validatorId].push(CooldownEntry({
amount: amount,
cooldownEndTime: block.timestamp + cooldownInterval
}));
This preserves independent timing for each unstake (no overwriting of earlier cooldownEndTime).
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 contract uses a single cooldown slot per user and validator and overwrites its end time on each new unstake instead of tracking each unstake separately.
Impact
Previously unstaked funds can be re-locked for up to the cooldown interval when a later unstake occurs, causing temporary freezing of funds for at least 24 hours.
What the attacker needed
User has staked tokens; user unstakes twice before first cooldown matures
The fix
The storage should be changed to keep multiple cooldown entries per user and validator, pushing a new entry on each unstake so each has its own expiry.
How it was found
- At time t0, call unstake for a validator with amount 100, creating a cooldown entry ending at t0 plus the cooldown interval.
- At time t1, one second before the first cooldown matures, call unstake again for the same validator with amount 50.
- The contract adds 50 to the existing entry and sets the cooldown end time to t1 plus the cooldown interval.
- At t0 plus the cooldown interval plus a small delay, calling withdraw does not include the original 100, which remains locked until t1 plus the cooldown interval.
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 unstake tokens, the contract normally makes you wait a set cooldown period before you can withdraw them. This report shows that if you unstake again for the same validator before the first wait finishes, the contract merges both amounts and resets the timer, so your first batch of tokens stays locked longer than it should.
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.