TwentyOne

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

Incorrect Ether Validation Leads to Unexpected Ether Lockup in Contract

Summary

The startGame function in the contract contains a vulnerability in the validation of the Ether amount provided by users. Specifically, the require statement only checks if the Ether sent is greater than or equal to 1 Ether (msg.value >= 1 ether). This condition allows users to send more than 1 Ether, but any excess Ether becomes locked in the contract with no mechanism for withdrawal or refund.

Impact

Users sending more than 1 Ether will lose the excess amount, as the contract does not handle refunds or excess Ether explicitly.

Tools Used

Manual

Recommendations

function startGame() public payable returns (uint256) {
address player = msg.sender;
- require(msg.value >= 1 ether, "not enough ether sent");
+ require(msg.value == 1 ether, "not enough ether sent");
initializeDeck(player);
uint256 card1 = drawCard(player);
uint256 card2 = drawCard(player);
addCardForPlayer(player, card1);
addCardForPlayer(player, card2);
return playersHand(player);
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

[INVALID] User mistake, too much ETH sent

Support

FAQs

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