Description:
In the ChristmasDinner::withdraw function, there is no such mechanism to withdraw ether by host
function withdraw() external onlyHost {
address _host = getHost();
i_WETH.safeTransfer(_host, i_WETH.balanceOf(address(this)));
i_WBTC.safeTransfer(_host, i_WBTC.balanceOf(address(this)));
i_USDC.safeTransfer(_host, i_USDC.balanceOf(address(this)));
@>
}
Impact:
The Host will not be able to withdraw ether and funds will stuck forever.
Proof of Concept:
function test_modifiedWithdraw() public {
vm.deal(user1, 1e18);
vm.prank(user1);
(bool sent1, ) = address(cd).call{value: 1e18}("");
address host2 = cd.getHost();
vm.prank(host2);
cd.withdraw();
vm.expectRevert();
assertEq(host2.balance, 1e18);
}
Recommended Mitigation:
function withdraw() external onlyHost {
address _host = getHost();
...
+ (bool sent,) = _host.call{value: address(this).balance}("");
+ require(sent, "transfer failed");
}