First Flight #21: KittyFi

First Flight #21
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Arbitrary `_user` passed to transferFrom (or safeTransferFrom), which can lead to loss of funds

Summary

In KittyVault::executeDepawsit the Arbitrary Passing an arbitrary _user address to transferFrom (or safeTransferFrom) can lead to loss of funds, because anyone can transfer tokens from the _user address if an approval is made.

Vulnerability Details

function executeWhiskdrawal(address _user, uint256 _cattyNipToWithdraw) external onlyPool {
uint256 _ameownt = _cattyNipToWithdraw.mulDiv(getTotalMeowllateral(), totalCattyNip);
userToCattyNip[_user] -= _cattyNipToWithdraw;
totalCattyNip -= _cattyNipToWithdraw;
totalMeowllateralInVault -= _ameownt;
@> IERC20(i_token).safeTransfer(_user, _ameownt);
}
function executeWhiskdrawal(address _user, uint256 _cattyNipToWithdraw) external onlyPool {
uint256 _ameownt = _cattyNipToWithdraw.mulDiv(getTotalMeowllateral(), totalCattyNip);
userToCattyNip[_user] -= _cattyNipToWithdraw;
totalCattyNip -= _cattyNipToWithdraw;
totalMeowllateralInVault -= _ameownt;
- IERC20(i_token).safeTransfer(_user, _ameownt);
+ IERC20(i_token).safeTransfer(msg.sender, _ameownt);
}

Impact

can lead to loss of funds

Tools Used

manual review

Recommendations

Use `msg.sender` as `_user` in transferFrom (or safeTransferFrom)
function executeWhiskdrawal(address _user, uint256 _cattyNipToWithdraw) external onlyPool {
uint256 _ameownt = _cattyNipToWithdraw.mulDiv(getTotalMeowllateral(), totalCattyNip);
userToCattyNip[_user] -= _cattyNipToWithdraw;
totalCattyNip -= _cattyNipToWithdraw;
totalMeowllateralInVault -= _ameownt;
- IERC20(i_token).safeTransfer(_user, _ameownt);
+ IERC20(i_token).safeTransfer(msg.sender, _ameownt);
}
Updates

Lead Judging Commences

shikhar229169 Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!