MyCut

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

Lack of checking for funded contest in `ContestManager::fundContest`, Onwer can fund a contest multiple times.

Description:

The fundContest function do not check for funded contest and it allows owner to fund contest multiple time.

Impact:

The owner send more money than intend.

Proof of Concept:

Paste this test into TestMyCut.t.sol, test will pass. The owner can fund the Pot contract multiple times.

function test_canFundPotMultipleTime() public mintAndApproveTokens {
vm.startPrank(user);
contest = ContestManager(conMan).createContest(
players,
rewards,
IERC20(ERC20Mock(weth)),
4
);
ContestManager(conMan).fundContest(0);
assertEq(ERC20Mock(weth).balanceOf(contest), 4);
// Funding contest again
ContestManager(conMan).fundContest(0);
}

Tools Used:

Manual review

Foundry

Recommendations:

Add a mapping to keep track of funded contest.

+ mapping(address => bool) public contestIsFunded;
function fundContest(uint256 index) public onlyOwner {
Pot pot = Pot(contests[index]);
IERC20 token = pot.getToken();
uint256 totalRewards = contestToTotalRewards[address(pot)];
if (token.balanceOf(msg.sender) < totalRewards) {
revert ContestManager__InsufficientFunds();
}
+ contestIsFunded = true;
token.transferFrom(msg.sender, address(pot), totalRewards);
}
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.