TwentyOne

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

No function to withdraw dealers' winnings

Summary

It is not possible to withdraw ETH (that comes form dealer's winnings) from the contract

Vulnerability Details

When the dealer wins, the ETH provided by players remains in the contract. There is no function to withdraw this winnings from the contract

Impact

This inability to withdraw ETH from the contract may result in loose ETH being stuck in the contract forever.

Tools Used

Manual review

Recommendations

Add an admin role and function that only an admin can call to take eth out of the contract. See the example below:

contract TwentyOne {
address payable admin;
constructor() {
admin = payable(msg.sender);
}
function withdraw(uint256 _amount) external {
require(msg.sender == admin, "Only Admin");
require(address(this).balance >= _amount);
(bool success,) = admin.call{value: _amount}("");
require(success, "Transfer failed");
}
// ----------------- REST OF THE CONTRACT ---------------------
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Owner has no method to withdraw

Support

FAQs

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