Skip to content
DoS Audit finding Intermediate

Cannot withdraw tokens from all strategies in MultiStrategyVault when one third party is paused

The MultiStrategyVault contract attempts to withdraw from all strategies proportionally, so if any single third-party strategy is paused, the entire withdrawal transaction reverts. This prevents users from withdrawing their funds and also blocks rebalancing and strategy removal, potentially locking all assets permanently.

klau5 Follow

Originally disclosed on Code4rena

Submitted by klau5

https://github.com/code-423n4/2024-12-bakerfi/blob/0daf8a0547b6245faed5b6cd3f5daf44d2ea7c9a/contracts/core/MultiStrategy.sol#L148

https://github.com/code-423n4/2024-12-bakerfi/blob/0daf8a0547b6245faed5b6cd3f5daf44d2ea7c9a/contracts/core/MultiStrategy.sol#L173

https://github.com/code-423n4/2024-12-bakerfi/blob/0daf8a0547b6245faed5b6cd3f5daf44d2ea7c9a/contracts/core/MultiStrategy.sol#L226

https://github.com/code-423n4/2024-12-bakerfi/blob/0daf8a0547b6245faed5b6cd3f5daf44d2ea7c9a/contracts/core/MultiStrategy.sol#L264

Finding description and impact

When even one third party integrated with MultiStrategyVault is paused, withdrawals become impossible from all Strategies. There is no way to remove the paused third party (Strategy).

Proof of Concept

Third parties integrated with this project can be paused according to their circumstances. For example, when the AAVE V3 pool is paused, transactions attempting deposits or withdrawals from this pool will revert (reference). The audit scope explicitly states that third party pausability is included.

While it makes sense for a single strategy vault to be paused when an integrated third party is paused, a multi strategy vault should not halt operations with other third parties just because one is paused. This is because funds invested in other strategies could be put at risk due to a single third party.

Therefore, there needs to be a way to temporarily exclude paused third parties (Strategies). Without this ability, transactions will revert because it attempts deposits/withdrawals from the paused third party.

  • For deposits, the weight of the strategy linked to that third party can be temporarily set to 0 to exclude it from deposit targets.
  • However, for withdrawals, it attempts to withdraw based on the percentage of totalAssets deposited, not weight, so even if weight is 0, it attempts to withdraw to the paused third party. This transaction will be reverted, so the user will not be able to withdraw.
  • Since withdrawals are impossible, asset reallocation through rebalance is also impossible.
  • Attempting to remove the strategy connected to that third party using removeStrategy will try to withdraw asset tokens for redistribution to other strategies. This will revert, making it impossible to remove the problematic strategy.

In other words, while a paused third party can be excluded from deposits, it cannot be excluded from withdrawals. If that third party’s pool becomes permanently paused, all tokens deposited in the MultiStrategyVault will be permanently locked.

function _allocateAssets(uint256 amount) internal returns (uint256 totalDeployed) {
    totalDeployed = 0;
    for (uint256 i = 0; i < _strategies.length; ) {
@>      uint256 fractAmount = (amount * _weights[i]) / _totalWeight;
        if (fractAmount > 0) {
@>          totalDeployed += IStrategy(_strategies[i]).deploy(fractAmount);
        }
        unchecked {
            i++;
        }
    }
}

function _deallocateAssets(uint256 amount) internal returns (uint256 totalUndeployed) {
    uint256[] memory currentAssets = new uint256[](_strategies.length);

    uint256 totalAssets = 0;
    uint256 strategiesLength = _strategies.length;

    for (uint256 i = 0; i < strategiesLength; i++) {
@>      currentAssets[i] = IStrategy(_strategies[i]).totalAssets();
        totalAssets += currentAssets[i];
    }
    totalUndeployed = 0;
    for (uint256 i = 0; i < strategiesLength; i++) {
@>      uint256 fractAmount = (amount * currentAssets[i]) / totalAssets;
@>      totalUndeployed += IStrategy(_strategies[i]).undeploy(fractAmount);
    }
}

function _rebalanceStrategies(uint256[] memory indexes, int256[] memory deltas) internal {
    ...
    // Iterate through each strategy to adjust allocations
    for (uint256 i = 0; i < totalStrategies; i++) {
        // if the delta is 0, we don't need to rebalance the strategy
        if (deltas[i] == 0) continue;

        // if the delta is positive, we need to deploy the strategy
        if (deltas[i] > 0) {
            uint256 balanceOf = IERC20(_strategies[indexes[i]].asset()).balanceOf(address(this));
            uint256 amount = uint256(deltas[i]) > balanceOf ? balanceOf : uint256(deltas[i]);
            IStrategy(_strategies[indexes[i]]).deploy(amount);
            // if the delta is negative, we need to undeploy the strategy
        } else if (deltas[i] < 0) {
@>          IStrategy(_strategies[indexes[i]]).undeploy(uint256(-deltas[i]));
        }
    }
    ...
}

function removeStrategy(uint256 index) external onlyRole(VAULT_MANAGER_ROLE) {
    ...
    // If the strategy has assets, undeploy them and allocate accordingly
@>  if (strategyAssets > 0) {
@>      IStrategy(_strategies[index]).undeploy(strategyAssets);
        _allocateAssets(strategyAssets);
    }
    ...
}

Recommended Mitigation Steps

We need a way to exclude third parties (Strategies) from withdrawals if they are unavailable. We need to be able to exclude a strategy without making a withdrawal request.

chefkenji (BakerFi) acknowledged


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

Likely the withdrawal logic iterates over all strategies and calls undeploy on each, without any mechanism to skip a paused or unavailable strategy.

Impact

Users cannot withdraw any funds, and rebalancing or removing the paused strategy is also impossible, potentially locking all deposited tokens permanently if the pause is permanent.

What the attacker needed

A third-party strategy is paused; user has funds in the vault

The fix

The vault should allow excluding a paused strategy from withdrawals, for example by adding a mechanism to skip or temporarily remove it without requiring a withdrawal request.

How it was found

  1. A third-party pool integrated as a strategy is paused.
  2. A user calls withdraw on the MultiStrategyVault.
  3. The vault attempts to undeploy assets from every strategy, including the paused one.
  4. The call to the paused strategy reverts, causing the entire withdrawal to fail.

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 vault spreads your money across several outside investment pools. If one pool is paused, the vault still tries to take money from it, and the whole withdrawal fails. So you cannot get any of your money back, even from the pools that are still working.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by klau5

View all

21 more disclosed reports, best first.

More from BakerFi Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.