Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Invalid

Unrestricted Refund Functionality Leads to Free Raffle Participation

Vulnerability Details

The refund function allows players to claim a refund of their entrance fee at any time. This function does not check whether the raffle has already been drawn or whether the player calling the function has won or lost. As a result, players can participate in the raffle, wait for the outcome, and then claim a refund regardless of whether they won or lost. This flaw undermines the integrity of the raffle and can lead to financial losses for the contract owner.

function refund(uint256 playerIndex) public {
address playerAddress = players[playerIndex];
require(playerAddress == msg.sender, "PuppyRaffle: Only the player can refund");
require(playerAddress != address(0), "PuppyRaffle: Player already refunded, or is not active");
payable(msg.sender).sendValue(entranceFee);
players[playerIndex] = address(0);
emit RaffleRefunded(playerAddress);
}

Impact

  • Financial Losses: Players can game the system by participating without any financial risk. This could result in financial losses for the contract owner or other legitimate participants.

  • Loss of Trust: The integrity of the raffle is compromised, leading to a loss of trust from participants and potential reputational damage.

  • Reduced Participation: Knowledge of this exploit would deter honest players from participating, as the raffle is no longer fair or financially viable.

Recommendations

  • Restrict Refund Timing: Implement logic to restrict refunds to before the raffle draw. Once the raffle has commenced or a winner has been selected, refunds should no longer be permitted.

  • Track Participation Status: Maintain a record of each player's participation status, distinguishing between active participants, those who have won, and those who have been refunded.

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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

Give us feedback!