TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

[H-1] endgame :: TwentyOne allows for reentrancy

Summary

function endGame(address player, bool playerWon) internal {
delete playersDeck[player].playersCards; // Clear the player's cards
delete dealersDeck[player].dealersCards; // Clear the dealer's cards
delete availableCards[player]; // Reset the deck
@> if (playerWon) {
payable(player).transfer(2 ether); // Transfer the prize to the player
emit FeeWithdrawn(player, 2 ether); // Emit the prize withdrawal event
}
}

the if statement requires playerWonto be true before transfer of ether. After the transfer the value was not set to false. Thereby allowing a malicious attacker to be able reenter the function and exhaust the contract funds

Vulnerability Details

Impact

The contract losses other players fund to the malicious attacker

Tools Used

Manual analysis

Recommendations

if (playerWon) {
payable(player).transfer(2 ether); // Transfer the prize to the player
+ playerWon = false
emit FeeWithdrawn(player, 2 ether); // Emit the prize withdrawal event
}
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!