Closed code423n4 closed 2 years ago
This is intentional.
If Alice approves type(uint256).max to the migrator contract, she is allowing that contract to migrate her tokens.
Worst case the tokens get migrated and sent to her address. The situation where a user would not want to migrate is not feasible in our opinion. This is akin to LEND => AAVE.
Agree with sponsor. This is a feature. Alice could always revoke the approval or send oldToken to a different account.
Lines of code
https://github.com/maple-labs/mpl-migration/blob/a99549d96ed12cd4589a02bccf70747dbaebeb5b/contracts/Migrator.sol#L24-L28
Vulnerability details
https://github.com/maple-labs/mpl-migration/blob/a99549d96ed12cd4589a02bccf70747dbaebeb5b/contracts/Migrator.sol#L24-L28
The
migrate()
allows anyone to use other's allowance to migrateoldToken
tonewToken
.newToken
is not necessarily valued higher or equal tooldToken
, therefore, migratingoldToken
tonewToken
against users' will can result in users' fund loss.PoC
Given:
type(uint256).max
of oldToken to the contract;migrate()
and migrated 1,000 oldToken to newToken;oldToken
is now greater thannewToken
, Alice decided not to migrate the rest old tokens;migrate()
and migrated Alice's 9,000oldToken
tonewToken
.Recommendation
Change to: