Skip to content
Business logic Audit finding Intermediate

Incosistent withdrawable amount calculations

The two view functions for withdrawable amounts return different values because one includes matured cooldowns that have not been processed while the other only returns parked funds. This inconsistency could mislead integrations that rely on consistent balance data.

holydevoti0n Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

52960 sc insight incosistent withdrawable amount calculations

Submitted on Aug 14th 2025 at 13:42:08 UTC by @holydevoti0n for Attackathon | Plume Network

Description

Brief/Intro

In StakingFacet, the amountWithdrawable() function returns matured cooldowns that haven't been processed, while totalAmountWithdrawable() only returns processed parked funds, creating inconsistent balance reporting.

Vulnerability Details

The two conflicting functions for the withdrawable returns are totalAmountWithdrawable and amountWithdrawable.

Notice the global calculation returns directly the totalWithdrawable variable:

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L553-L555

Solidity
function totalAmountWithdrawable() external view returns (uint256 amount) {
    return PlumeStakingStorage.layout().totalWithdrawable;
}

Now the amountWithdrawable function considers the matured cooldowns for the user:

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L520-L522

Solidity
function amountWithdrawable() external view returns (uint256 totalWithdrawableAmount) {
    return _calculateTotalWithdrawableAmount(msg.sender);
}

function _calculateTotalWithdrawableAmount(
    address user
) internal view returns (uint256 totalWithdrawableAmount) {
    PlumeStakingStorage.Layout storage $ = PlumeStakingStorage.layout();
    uint16[] storage userAssociatedValidators = $.userValidators[user];

    totalWithdrawableAmount = $.stakeInfo[user].parked; // Same as global method

    // BUT ALSO includes matured cooldowns that haven't been processed yet:
    for (uint256 i = 0; i < userAssociatedValidators.length; i++) {
        uint16 validatorId = userAssociatedValidators[i];
        PlumeStakingStorage.CooldownEntry storage cooldownEntry = $.userValidatorCooldowns[user][validatorId];

        if (cooldownEntry.amount > 0 && block.timestamp >= cooldownEntry.cooldownEndTime) {
            if ($.validatorExists[validatorId] && $.validators[validatorId].slashed) {
                if (cooldownEntry.cooldownEndTime < $.validators[validatorId].slashedAtTimestamp) {
                    totalWithdrawableAmount += cooldownEntry.amount; // NOT in global state
                }
            } else if ($.validatorExists[validatorId] && !$.validators[validatorId].slashed) {
                totalWithdrawableAmount += cooldownEntry.amount; // NOT in global state
            }
        }
    }

    return totalWithdrawableAmount;
}

The global totalWithdrawable state variable is only updated when funds are explicitly moved to parked state via these functions:

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/facets/StakingFacet.sol#L731

Solidity
// @audit increased when unstaking and restaking(matured cooldowns)
function _updateParkedAmounts(address user, uint256 amount) internal {
    PlumeStakingStorage.Layout storage $ = PlumeStakingStorage.layout();
    $.stakeInfo[user].parked += amount;
    $.totalWithdrawable += amount; // Global state updated here
}

Problem is cooldowns become withdrawable immediately when they mature (block.timestamp >= cooldownEndTime), but the global state is not updated until:

  • User calls withdraw() → triggers _processMaturedCooldowns()
  • User calls unstake() → triggers _processCooldownLogic()
  • User calls restake() → triggers _processMaturedCooldowns()

This causes the amount to withdraw to be inconsistent when calling the withdrawable functions.

Example

{% stepper %} {% step %} User stakes 100 PLUME to Validator A {% endstep %}

{% step %} User unstakes 100 PLUME → enters cooldown period {% endstep %}

{% step %} Time passes → cooldown matures {% endstep %}

{% step %} Before the user calls any processing function, current state:

Solidity
// User's actual state:
$.stakeInfo[user].parked = 0                    // No processed funds
$.userValidatorCooldowns[user][validatorA] = {
    amount: 100,
    cooldownEndTime: past_timestamp             // Matured
}
$.totalWithdrawable = 0                         // Global state not updated

{% endstep %}

{% step %} When the user calls totalAmountWithdrawable, the result is 0. {% endstep %}

{% step %} When the same user calls amountWithdrawable, it includes matured cooldown amounts and returns 100. {% endstep %} {% endstepper %}

This discrepancy happens because totalAmountWithdrawable does not account for recently matured cooldowns, so it will always be outdated compared to amountWithdrawable.

Impact Details

Two view functions return different withdrawable amounts for the same user, breaking integrations that rely on consistent balance data.

Recommendation

totalAmountWithdrawable never reflects the actual up-to-date withdrawable amount, it only includes parked amounts. Either update it to reflect the real total withdrawable amount or rename it to something more accurate, such as totalParkedAmount.

Proof of Concept

{% stepper %} {% step %} User stakes 100 PLUME to Validator A {% endstep %}

{% step %} User unstakes 100 PLUME → enters cooldown period {% endstep %}

{% step %} Time passes → cooldown matures {% endstep %}

{% step %} Before the user calls any processing function, current state:

Solidity
// User's actual state:
$.stakeInfo[user].parked = 0                    // No processed funds
$.userValidatorCooldowns[user][validatorA] = {
    amount: 100,
    cooldownEndTime: past_timestamp             // Matured
}
$.totalWithdrawable = 0                         // Global state not updated

{% endstep %}

{% step %} When the user calls totalAmountWithdrawable, the result is 0. {% endstep %}

{% step %} When the same user calls amountWithdrawable, it includes matured cooldown amounts and returns 100. {% endstep %} {% endstepper %}

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

Likely the global totalWithdrawable state variable is only updated when funds are explicitly moved to parked state, while the per-user calculation includes matured cooldowns that have not been processed.

What the attacker needed

User has staked and unstaked tokens; Cooldown period has matured

The fix

The report recommends either updating totalAmountWithdrawable to reflect the real total withdrawable amount or renaming it to something more accurate, such as totalParkedAmount.

How it was found

  1. User stakes 100 PLUME to Validator A
  2. User unstakes 100 PLUME, entering a cooldown period
  3. Time passes and the cooldown matures
  4. Before calling any processing function, totalAmountWithdrawable returns 0
  5. amountWithdrawable returns 100 because it includes the matured cooldown

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 smart contract has two functions that are supposed to tell you how much money you can withdraw. One function counts money that is ready but not yet moved, while the other only counts money that has already been moved. So they give different answers, which can confuse other programs that use these numbers.

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 holydevoti0n

View all

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