TwentyOne

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

The user's bet isn't controlled properly

Summary

In the game we can only bet 1 eth to receive 2 eth, but in the code we can deposit 1 eth or higher (so up to infinity). Even if it's intentionnal, it doesn't matter how much we bet, we're still gonna only receive 2 eth

Vulnerability Details

on the startGame fonction, we only controle that the ether sent by the player are equal or higher then one, but the code then, if he win, only send him 2 eth.

There is 4 choice.

1 make the eth sent variable (which would be contrary to what we want to do)

2 send back the ETH that are in surplus

3 only stat the game if the player send 1 eth

4 let the player deposit has much as he want (like we actually do) and let him loose the surplus

Impact

Tools Used

Recommendations

// actual start game fonction
function startGame() public payable returns (uint256) {
address player = msg.sender;
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);
}

either modify the require part or modify the end game fonction to give a variable number (if we decide to send more)

Updates

Lead Judging Commences

inallhonesty Lead Judge
7 months ago
inallhonesty Lead Judge 7 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.