migrateFractions may be called more than once by the same user which may lead to loss of tokens for other users
The migrateFractions function in the Migration contract did not record that a user had already migrated, so the same user could call it repeatedly and receive new vault tokens more than once. This drained the contract's token balance, leaving later users unable to claim the tokens they were owed.
Submitted by dipp, also found by 0x52, ak1, auditor0517, hansfriese, jonatascm, kenzo, Lambda, panprog, PwnedNoMore, Ruhum, smiling_heretic, Treasure-Seeker, and xiaoming90
The migrateFractions function in the Migration.sol contract is used to send new vault tokens to the user calculated based on the amount of ETH and fractions the user contributed to the migration proposal. After it is called once the user should have all the new vault tokens owed to them.
Since the function does not check if the user had already called it, a user may call it more than once, allowing them to gain more new vault tokens than they are owed. If a user repeatedly uses this function to gain new tokens then other users may not be able to get their new tokens.
Proof of Concept
Test code added to Migrations.t.sol:
The test code below shows the first user (Alice) migrating their tokens to the new vault twice before the second user (Bob) calls migrateFractions which then fails.
function testMigrateFractionsAgain() public {
// Setup
testSettle();
(, , , , address newVault, , , , ) = migrationModule.migrationInfo(
vault,
1
);
(address newToken, uint256 id) = registry.vaultToToken(newVault);
// First user migrates fractions twice
assertEq(IERC1155(newToken).balanceOf(address(migrationModule), id), TOTAL_SUPPLY * 2); // Confirm Migration has all new tokens
assertEq(getFractionBalance(alice.addr), 4000); // Alice joined with 1 ether and 1000 fractions
alice.migrationModule.migrateFractions(vault, 1);
assertEq(IERC1155(newToken).balanceOf(alice.addr, id), 6000); // Alice's shares == 6000
assertEq(IERC1155(newToken).balanceOf(address(migrationModule), id), TOTAL_SUPPLY * 2 - 6000); // Confirm Migration loses new tokens
alice.migrationModule.migrateFractions(vault, 1);
assertEq(IERC1155(newToken).balanceOf(alice.addr, id), 12000); // Confirm Alice gains 6000 new tokens again
assertEq(IERC1155(newToken).balanceOf(address(migrationModule), id), 8000); // Confirm Migration loses new tokens
// Second user attempts to migrate fractions
assertEq(getFractionBalance(bob.addr), 0); // Bob joined with 1 ether and 5000 fractions (all of his fractions)
vm.expectRevert(stdError.arithmeticError);
bob.migrationModule.migrateFractions(vault, 1); // Bob is unable to call migrateFractions and gain new tokens because the migration module does not contain enough tokens
assertEq(IERC1155(newToken).balanceOf(bob.addr, id), 0); // Confirm Bob does not gain any new tokens (supposed to gain 14,000 tokens)
}
Recommended Mitigation Steps
A possible fix might be to set the userProposalEth and userProposalFractions to 0 after the user’s tokens have been migrated.
mehtaculous (Fractional) confirmed
HardlyDifficult (judge) increased severity to High and commented:
migrateFractionscan be called multiple times, stealing funds from other users. This is a High risk issue.Selecting this submission as the primary for including a clear POC.
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 function never reset or marked the caller's recorded contribution amounts after a successful migration, so the same entitlement could be claimed repeatedly.
Impact
A single user could take more new tokens than owed, and other users could be unable to claim theirs at all.
What the attacker needed
A completed migration proposal; attacker holds fractions in the old vault
The fix
The user's recorded ETH and fraction contributions should be zeroed after a successful migration so the claim cannot be repeated.
How it was found
- Set up the migration so the new vault and token exist and the migration module holds the new tokens.
- Have the first user call migrateFractions once and receive their new tokens.
- Have the same user call migrateFractions again and receive the same amount of new tokens a second time.
- Have a second user call migrateFractions, which reverts because the module no longer holds enough tokens.
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.
When a project moves to a new token, each person is meant to swap their old holdings for new ones exactly once. Here the swap function had no memory of who had already swapped, so one person could keep pressing the button and take more than their share. The pool of new tokens ran dry, and honest users who came later got nothing.
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.