Skip to content
Business logic Audit finding Intermediate

Even when the Vault contract is paused, the rebalance function is not paused

The rebalance function in the Vault and MultiStrategyVault contracts lacks a pause check, so it can still be called when the contract is paused. This allows performance fees to be collected from interest even though users cannot withdraw.

klau5 Follow

Originally disclosed on Code4rena

Submitted by klau5

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

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

Finding description and impact

When the contract is paused, rebalance is not paused. While users cannot withdraw, performance fees can still be collected from interest.

Proof of Concept

The rebalance should not be callable when paused (according to the documentation), but it can still be called even when paused. This means that while users cannot withdraw their investments from the Vault when paused, it’s still possible to collect performance fees on interest through the rebalance function. Also, MultiStrategyVault has the same issue.

    function rebalance(
        IVault.RebalanceCommand[] calldata commands
@>  ) external override nonReentrant onlyRole(VAULT_MANAGER_ROLE) returns (bool success) {
        success = true;
        uint256 numCommands = commands.length;
        for (uint256 i = 0; i < numCommands; ) {
            if (commands[i].action == HARVEST_VAULT) {
                _harvestAndMintFees();
            }
            unchecked {
                i++;
            }
        }
    }

Recommended Mitigation Steps

Add the whenNotPaused modifier to the rebalance function.

chefkenji (BakerFi) confirmed

BakerFi mitigated:

PR-3

Status: Mitigation confirmed. Full details in reports from 0xlemon and shaflow2.


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

The rebalance function is missing the whenNotPaused modifier, so it remains callable during a pause.

Impact

While the contract is paused and users cannot withdraw, performance fees can still be collected from interest through rebalance.

What the attacker needed

Contract is paused; caller has VAULT_MANAGER_ROLE

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 can have a pause switch to stop certain actions in an emergency. Here, the pause switch stops users from taking their money out, but it does not stop a special function called rebalance. That function can still take a cut of the interest earned, even while everything is supposed to be frozen.

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

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.