MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Unchecked transfer Operation in `Pot::closePot`

Summary

The Pot::closePot uses an unchecked transfer operation when transferring the manager’s cut. This could lead to situations where the transfer fails without being detected, causing issues with the funds distribution.

Vulnerability Details

Within the Pot::closePot, the following code is used to transfer the manager’s cut from the remaining rewards:

function closePot() external onlyOwner {
if (block.timestamp - i_deployedAt < 90 days) {
revert Pot__StillOpenForClaim();
}
if (remainingRewards > 0) {
uint256 managerCut = remainingRewards / managerCutPercent;
@> i_token.transfer(msg.sender, managerCut);
uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
for (uint256 i = 0; i < claimants.length; i++) {
_transferReward(claimants[i], claimantCut);
}
}
}

This operation does not verify whether the transfer was successful. If it fails, the contract will continue executing, incorrectly assuming the manager has received their cut.

Impact

Manager’s Funds: The manager may not receive their entitled portion of the rewards.

Incorrect Distribution: The remaining rewards, meant to be distributed among claimants, could be miscalculated if the manager’s cut is not successfully transferred.

Tools Used

Manual Review

Slither

Recommendations

Replace the unchecked transfer with a safe transfer using OpenZeppelin’s SafeERC20 library to ensure the operation’s success:

function closePot() external onlyOwner {
if (block.timestamp - i_deployedAt < 90 days) {
revert Pot__StillOpenForClaim();
}
if (remainingRewards > 0) {
uint256 managerCut = remainingRewards / managerCutPercent;
- i_token.transfer(msg.sender, managerCut);
+ i_token.safeTransfer(msg.sender, managerCut);
uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
for (uint256 i = 0; i < claimants.length; i++) {
_transferReward(claimants[i], claimantCut);
}
}
}
Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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