Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Lack of Fund Transfer in EmergencyMigration::migrate Function Compromises Security of Emergency Migration

Summary

the EmergencyMigration::migrate doesn't transfer the funds from the MoneyShelf contract to the MoneyVault contract

Vulnerability Details

The goat of the EmergencyMigration::migrate is to allow the godfather to migrate funds from the MoneyShelf to a contract (MoneyVault) that only he can manage. However, the function currently does not transfer the funds, thus defeating the purpose of the emergency migration

Impact

Since the funds are not transferred to the MoneyVault, they remain in the MoneyShelf and are susceptible to being compromised.
Place the following into EmergencyMigration.t.sol.

function test_funds_are_not_transfered() public {
vm.prank(godFather);
usdc.transfer(address(this), 100e6);
usdc.approve(address(moneyShelf), 100e6);
laundrette.depositTheCrimeMoneyInATM(address(this), address(this), 100e6);
assertEq(usdc.balanceOf(address(this)), 0);
assertEq(usdc.balanceOf(address(moneyShelf)), 100e6);
console.log("moneyshelf balance: ", usdc.balanceOf(address(moneyShelf))); // MoneyShelf has 100 USDC
assertEq(address(kernel.getModuleForKeycode(Keycode.wrap("MONEY"))), address(moneyShelf));
EmergencyMigration migration = new EmergencyMigration();
MoneyVault moneyVault = migration.migrate(kernel, usdc, crimeMoney);
assertNotEq(address(moneyShelf), address(moneyVault));
assertEq(address(kernel.getModuleForKeycode(Keycode.wrap("MONEY"))), address(moneyVault));
console.log("moneyVault balance:", usdc.balanceOf(address(moneyVault))); // MoneyVault has 0 USDC
}

Tools Used

Manual Review

Recommendations

Add a transfer of funds from the MoneyShelf to the MoneyVault in the migrate function and keep track of balance of every account.

Updates

Lead Judging Commences

n0kto Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Emergency migration leave the USDC

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.