MyCut

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

Lack of Validation in `closeContest` Function (Potential Double Closing of Contest)

Summary

The `closeContest` function in the `ContestManager` contract contains a few critical issues due to the absence of necessary validation checks:

  1. No Address Validation: The function does not verify whether the provided contest address is valid (i.e., non-zero and corresponds to a deployed contract). This could result in erroneous behavior if an invalid address is passed.

  2. No Check for Contest Closure: The function does not verify whether the contest has already been closed before attempting to close it again. This can lead to a situation where a contest is "double closed," which could cause unexpected errors or loss of state.

Impact

  1. Invalid Address Handling: If an invalid address is passed to the `closeContest` function, the `_closeContest` call could fail silently or behave unpredictably, leading to potential bugs in the system or loss of funds if the function is incorrectly assumed to have succeeded.

  2. Double Closing of Contests:** The absence of a check to determine if a contest has already been closed can result in the same contest being closed multiple times. This could potentially result in issues such as reallocation of rewards, errors in tracking the status of contests, or other undefined behaviors depending on the implementation of `_closeContest`.\

Tools Used

Manual Review

Recommendations

  1. Address Validation: Ensure that the provided `contest` address is non-zero and corresponds to a valid contract before proceeding with the function logic. This can be done by adding a simple check at the start of the function:

    require(contest != address(0), "Invalid contest address");require(contest != address(0), "Invalid contest address");
  2. Check Contest Closure Status: Before closing a contest, add a check to ensure that the contest has not already been closed. This can be implemented as:

    require(!Pot(contest).isClosed(), "Contest already closed");

This assumes the `Pot` contract has an `isClosed()` method that returns a boolean indicating whether the contest is already closed.

Updates

Lead Judging Commences

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

Support

FAQs

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