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.
Submitted by scaraven, also found by berndartmueller
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
- User starts a new migration proposal where
selectors.length != plugins.length - Enough users join proposal and the buyout bid starts
- Buyout bid is successful and migration starts with
settleVault() - A new vault is cloned with
create()->registry.deployFor()->vault.install(selectors, plugins) - a. If
selectors.length > plugins.lengththen we get an out of bounds error and transaction reverts b. Ifselectors.length < plugins.lengththen the excess values inpluginsis ignored which is tolerable - 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.
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
- User starts a new migration proposal where selectors.length != plugins.length
- Enough users join proposal and the buyout bid starts
- Buyout bid is successful and migration starts with settleVault()
- A new vault is cloned with create() -> registry.deployFor() -> vault.install(selectors, plugins)
- If selectors.length > plugins.length then we get an out of bounds error and transaction reverts
- 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.