Christmas Dinner

First Flight #31
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

The Received Ether will be stuck forever caused by lack of withdraw mechanism

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)));
@> // no mechanism to withdraw ether
}

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");
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

withdraw function lacks functionality to send ether

Support

FAQs

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