MyCut

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

Double Funding Risk in `fundContest` Function (Missing Validation Check)

Summary
Due to lack of Proper checks in the `fundContest`, a pot can be funded multiple times, if the fundContest is unintentionally called with the same `index`

Vulnerability Details

The `fundContest` function in the `ContestManager` contract is vulnerable due to the absence of validation checks to determine if the pot has already been funded. The function does not verify whether the pot has been funded before, which could lead to unintended double funding if its called twice with the same `index`.

Impact

  • if the function is called multiple times with the same `index` without the proper checks to see if it was funded already, it could result in the pot being funded multiple times, leading to an excess transfer of tokens.

  • This could deplete the contest owner's funds and disrupt the contest's reward distribution.Tools Used

Proof of Concept
Add this test to Test to TestCut.t.sol

function testCannotFundPotTwice() public mintAndApproveTokens {
vm.startPrank(user);
// Step 1: Create and Fund Pot
contest = ContestManager(conMan).createContest(players, rewards, IERC20(ERC20Mock(weth)), totalRewards);
ContestManager(conMan).fundContest(0);
// Step 2: Attempt to Fund the Pot Again
vm.expectRevert("Pot has already been funded");
ContestManager(conMan).fundContest(0); // Attempt to fund the same pot again
vm.stopPrank();

The test failed and didnt revert as expected.


Tools Used

  • Manual Review

  • Foundry Test

Recommendations

Add a check to ensure the pot has not funded beforerequire(!pot.isFunded(), "Pot has already been funded");require(!pot.isFunded(), "Pot has already been funded");

require(!pot.isFunded(), "Pot has already been funded");
Updates

Lead Judging Commences

equious Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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