Skip to content
Business logic Audit finding Intermediate

Migration can permanently fail if user specifies different lengths for selectors and plugins

The migration proposal function did not check that the selectors and plugins arrays had equal lengths. If a proposal was created with more selectors than plugins, the subsequent vault installation would revert with an out-of-bounds error, preventing a new vault from being created and permanently locking assets in the old vault.

scaraven Follow

Originally disclosed on Code4rena

Submitted by scaraven, also found by berndartmueller

https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/Vault.sol#L73-L82

https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/modules/Migration.sol#L72-L99

https://github.com/code-423n4/2022-07-fractional/blob/8f2697ae727c60c93ea47276f8fa128369abfe51/src/VaultRegistry.sol#L174

Impact

In propose() in Migration.sol, there is no check that the lengths of the selectors and plugins arrays are the same. This means that if a migration is successful, the install() function in Vault.sol could revert beacuse we access an array out of bounds. This prevents a new vault being created thereby permanently locking assets inside the vault.

Proof of Concept

  1. User starts a new migration proposal where selectors.length != plugins.length
  2. Enough users join proposal and the buyout bid starts
  3. Buyout bid is successful and migration starts with settleVault()
  4. A new vault is cloned with create() -> registry.deployFor() -> vault.install(selectors, plugins)
  5. a. If selectors.length > plugins.length then we get an out of bounds error and transaction reverts b. If selectors.length < plugins.length then the excess values in plugins is ignored which is tolerable
  6. In scenario a., the migration fails and a new migration cannot start so assets in the vault are permanently locked

This may seem quite circumstantial as this problem only occurs if a user specifies selectors and plugins wrongly however it is very easy for an attacker to perform this maliciously with no cost on their behalf, it is highly unlikely that users will be able to spot a malicious migration.

Tools Used

VS Code

Recommended Mitigation Steps

Consider adding a check in propose() to make sure that the lengths match i.e.

function propose(
        address _vault,
        address[] calldata _modules,
        address[] calldata _plugins,
        bytes4[] calldata _selectors,
        uint256 _newFractionSupply,
        uint256 _targetPrice
    ) external {
        // @Audit Make sure that selectors and plugins match
        require(_selectors.length == _plugins.length, "Plugin lengths do not match");
        // Reverts if address is not a registered vault
        (, uint256 id) = IVaultRegistry(registry).vaultToToken(_vault);
        if (id == 0) revert NotVault(_vault);
        // Reverts if buyout state is not inactive
        (, , State current, , , ) = IBuyout(buyout).buyoutInfo(_vault);
        State required = State.INACTIVE;
        if (current != required) revert IBuyout.InvalidState(required, current);

        // Initializes migration proposal info
        Proposal storage proposal = migrationInfo[_vault][++nextId];
        proposal.startTime = block.timestamp;
        proposal.targetPrice = _targetPrice;
        proposal.modules = _modules;
        proposal.plugins = _plugins;
        proposal.selectors = _selectors;
        proposal.oldFractionSupply = IVaultRegistry(registry).totalSupply(
            _vault
        );
        proposal.newFractionSupply = _newFractionSupply;
    }

Additionally, I would suggest adding such a check in the install() function as this may prevent similiar problems if new modules are added.

stevennevins (Fractional) confirmed

HardlyDifficult (judge) commented:

A misconfiguration of a migration can result in permanently locked up funds. Agree with High risk here.


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

Impact

A migration could fail permanently, locking assets in the vault; the report notes this requires a user to specify the arrays wrongly, but an attacker could do so maliciously at no cost.

What the attacker needed

A migration proposal with mismatched array lengths; enough users join the proposal; a successful buyout bid

The fix

A check should be added in propose() to ensure the selectors and plugins arrays have equal length, and optionally a similar check in install().

How it was found

  1. User starts a new migration proposal where selectors.length != plugins.length
  2. Enough users join proposal and the buyout bid starts
  3. Buyout bid is successful and migration starts with settleVault()
  4. A new vault is cloned with create() -> registry.deployFor() -> vault.install(selectors, plugins)
  5. If selectors.length > plugins.length then we get an out of bounds error and transaction reverts
  6. In scenario a., the migration fails and a new migration cannot start so assets in the vault are permanently locked

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 lets users vote to move their assets to a new vault. The code that sets up the move did not check that two lists it received were the same length. If one list was longer, the move would crash and the assets could get stuck forever.

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 scaraven

View all

6 more disclosed reports, best first.

More from Fractional v2 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.