TwentyOne

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

Missing Overpayment Refund in startGame() Leads to Lost Player Funds

Summary

The TwentyOne contract accepts overpayments in startGame() without refunding excess ETH above the required 1 ETH bet, leading to permanent loss of player funds.

Vulnerability Details

  • No Overpayment Handling:

    • Function only checks for minimum payment

    • Excess ETH remains trapped in contract

function startGame() public payable returns (uint256) {
require(msg.value >= 1 ether, "not enough ether sent");
// No refund of msg.value > 1 ether

Impact

  • Players lose excess funds above 1 ETH

  • No mechanism to recover overpaid amounts

  • Poor user experience and potential loss of trust

Tools Used

  • Manual Code Review

Recommendations

  • Implement exact payment or refund excess:

function startGame() public payable returns (uint256) {
require(msg.value >= 1 ether, "not enough ether sent");
uint256 excess = msg.value - 1 ether;
if (excess > 0) {
(bool success,) = msg.sender.call{value: excess}("");
require(success, "Refund failed");
}
// ... rest of the function
}
Updates

Lead Judging Commences

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

[INVALID] User mistake, too much ETH sent

Appeal created

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