Summary
endGame function uses transfer
, to transfer the prize to the player.
Vulnerability Details
function endGame(address player, bool playerWon) internal {
delete playersDeck[player].playersCards;
delete dealersDeck[player].dealersCards;
delete availableCards[player];
if (playerWon) {
payable(player).transfer(2 ether);
emit FeeWithdrawn(player, 2 ether);
}
}
Impact
Transfer uses fixed 2300 gas which is too low, it may cause transfer to fail.
Tools Used
Manual Review
Recommendations
Use call
instead, is more flexible it allows to specify how much gas to forward to the recipient.
function endGame(address player, bool playerWon) internal {
delete playersDeck[player].playersCards;
delete dealersDeck[player].dealersCards;
delete availableCards[player];
if (playerWon) {
(bool success, ) = payable(player).call{value: prize}("");
require(success, "Transfer failed");
emit FeeWithdrawn(player, 2 ether);
}
}