The selectWinner function uses a push payment model that sends ETH directly to the winner. If the winner is a contract that rejects ETH, the transfer fails and reverts, permanently trapping all funds and bricking the raffle protocol with no recovery mechanism.
The contract attempts to send the prize pool directly to the winner using winner.call{value: prizePool}(""). If this call fails (e.g., the winner is a contract without a receive() function or explicitly rejects ETH), the require(success) statement reverts the entire transaction.
While the state changes (delete players, raffleStartTime = block.timestamp) are rolled back on revert, the contract enters a permanently stuck state: the raffle duration has passed, the players array still contains the rejecting contract, and every subsequent attempt to call selectWinner will also fail if it selects the same winner. The funds (both the 80% prize and the 20% fee) are permanently locked with no recovery mechanism.
File: src/PuppyRaffle.sol (lines 140-145)
Severity: High
Likelihood: Medium
Impact: High
❌ Funds permanently trapped if winner rejects ETH
❌ Protocol permanently bricked (DoS)
❌ No recovery mechanism
❌ Affects all users and their funds
Scenario: A player enters the raffle using a smart contract that rejects all incoming ETH. When this contract is randomly selected as the winner, the prize transfer fails and all funds become permanently locked.
Test Output:
What This Proves:
✅ Push payment model fails if winner rejects ETH
✅ Funds are permanently trapped with no recovery
✅ Protocol suffers permanent DoS
Use a pull payment model instead of push:
Why This Fixes It:
✅ Raffle state updates regardless of winner's ability to receive ETH
✅ Winner can withdraw prize at their convenience
✅ If withdrawal fails, funds remain in mapping and can be retried
✅ Prevents permanent DoS and fund trapping
SWC-114: Transaction Order Dependence
Checks-Effects-Interactions pattern
OpenZeppelin Withdrawals pattern
## Description If a player submits a smart contract as a player, and if it doesn't implement the `receive()` or `fallback()` function, the call use to send the funds to the winner will fail to execute, compromising the functionality of the protocol. ## Vulnerability Details The vulnerability comes from the way that are programmed smart contracts, if the smart contract doesn't implement a `receive() payable` or `fallback() payable` functions, it is not possible to send ether to the program. ## Impact High - Medium: The protocol won't be able to select a winner but players will be able to withdraw funds with the `refund()` function ## Recommendations Restrict access to the raffle to only EOAs (Externally Owned Accounts), by checking if the passed address in enterRaffle is a smart contract, if it is we revert the transaction. We can easily implement this check into the function because of the Adress library from OppenZeppelin. I'll add this replace `enterRaffle()` with these lines of code: ```solidity function enterRaffle(address[] memory newPlayers) public payable { require(msg.value == entranceFee * newPlayers.length, "PuppyRaffle: Must send enough to enter raffle"); for (uint256 i = 0; i < newPlayers.length; i++) { require(Address.isContract(newPlayers[i]) == false, "The players need to be EOAs"); players.push(newPlayers[i]); } // Check for duplicates for (uint256 i = 0; i < players.length - 1; i++) { for (uint256 j = i + 1; j < players.length; j++) { require(players[i] != players[j], "PuppyRaffle: Duplicate player"); } } emit RaffleEnter(newPlayers); } ```
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.