Skip to content
Business logic Audit finding Intermediate

Booster’s shutdownPool can freeze user funds

The shutdownPool function marks a pool as shut down even if the attempt to withdraw all funds from the gauge fails. This can permanently freeze user funds because subsequent withdrawals assume the pool is already shut down and do not attempt to retrieve the funds.

hyh Follow

Originally disclosed on Code4rena

Submitted by hyh, also found by jonatascm

shutdownPool() marks shutdown successful even if it’s not (i.e. when withdrawAll() call wasn’t successful). As withdrawing logic expect that the pool in shutdown has already provided the funds, and makes no additional attempts to retrieve them, user funds will be frozen permanently as there are no mechanics in place to turn shutdown off for a pool.

Setting severity to medium as that’s user principal funds freeze scenario conditional on any issues in withdrawAll().

Proof of Concept

In the case of unsuccessful withdrawAll() call the pool nevertheless will be marked as shutdown:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L312-L320

        //withdraw from gauge
        try IStaker(staker).withdrawAll(pool.lptoken, pool.gauge) {} catch {}

        pool.shutdown = true;
        gaugeMap[pool.gauge] = false;

        emit PoolShuttedDown(_pid);
        return true;
    }

It will block the withdrawals as there will be not enough funds to fulfil the claim:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L408-L422

        //pull from gauge if not shutdown
        // if shutdown tokens will be in this contract
        if (!pool.shutdown) {
            IStaker(staker).withdraw(lptoken, gauge, _amount);
        }

        //some gauges claim rewards when withdrawing, stash them in a seperate contract until next claim
        //do not call if shutdown since stashes wont have access
        address stash = pool.stash;
        if (stash != address(0) && !isShutdown && !pool.shutdown) {
            IStash(stash).stashRewards();
        }

        //return lp tokens
        IERC20(lptoken).safeTransfer(_to, _amount);

This way user funds will be frozen as the system will not attempt to withdraw from the pool, while there will be no funds to transfer to the user and _withdraw() will be reverting on L422 safeTransfer call.

Recommended Mitigation Steps

The shutdownPool logic can to be updated:

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L307-L320

Consider unifying the logic with shutdownSystem() and marking the pool shutdown only if withdraw was successful, for example:

//shutdown pool
function shutdownPool(uint256 _pid, bool forced) external returns (bool){
    require(msg.sende == poolManager, "!auth");
    PoolInfo storage pool = poolInfo[_pid];

    bool withdrawSuccess = false;

    //withdraw from gauge
    try IStaker(staker).withdrawAll(pool.lptoken,pool.gauge){
    	withdrawSuccess = true;
    } catch {}

    if (withdrawSuccess || forced) {
	    pool.shutdown = true;
	    gaugeMap[pool.gauge] = false;
        emit PoolShuttedDown(_pid);
    	return true;
    }

    return false;
}

jetbrain10 (veToken Finance) acknowledged, but disagreed with severity and commented:

Convex has the same, and we may need force shutdown.

Alex the Entreprenerd (judge) commented:

My issue with the submission is that it makes the following statement: Setting severity to medium as that's user principal funds freeze scenario conditional on any issues in withdrawAll().

Without mentioning any possible scenario in which withdrawAll could fail

Given the information that I have we could have reverts if:

  • Token is paused (e.g. Tether Blacklist)
  • Gauge breaks (not much you can do there, pausing probably won’t help recover funds)
  • Misterious bugs in the code, none were mentioned above.

Will think about severity.

Alex the Entreprenerd (judge) commented:

After reviewing the rest of the contest, I remember marking a finding about Paused tokens with Medium Severity, so while I think the submission could have been made stronger by providing real-world examples of how the tokens could be stuck, to maintain consistency I’ll mark this finding as valid as well.

As while it’s unspecified how a revert could happen, the try catch irreversible system does mean that a failed rescue bricks the tokens, perhaps a governance only secondary rescue system may be helpful for emergency scenarios.


The original report as published on Code4rena, by hyh. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 shutdownPool function does not check the success of the withdrawAll call before setting the pool's shutdown flag to true.

Impact

User principal funds could be permanently frozen if the withdrawAll call fails, as there is no mechanism to reverse the shutdown.

What the attacker needed

WithdrawAll() call fails

The fix

The shutdownPool function should only mark the pool as shut down if the withdrawAll call succeeds, or provide a forced shutdown option with additional safeguards.

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 a pool is shut down, the contract tries to withdraw all user funds from an external gauge. If that withdrawal fails, the contract still marks the pool as shut down. Later, when users try to withdraw, the contract thinks the funds are already available but they are not, so the withdrawal fails and the funds are stuck.

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 hyh

View all

137 more disclosed reports, best first.

More from veToken Finance contest

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.