Christmas Dinner

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

Lack of ETH withdrawal implementation in `ChristmasDinner::withdraw`

Summary

The contract is designed to handle ETH payments alongside ERC20 tokens. However, based on the implementation, there is no specific function to facilitate the withdrawal of ETH contributions. This omission can lead to ambiguity and potential misuse of the withdraw function or other mechanisms to access ETH, posing a risk to both participants and the host.

Vulnerability Details

The ChristmasDinner::_refundETH function facilitates ETH refunds to participants by transferring back their balance, but no similar mechanism is provided for ETH withdrawals by the host after the deadline.
ETH contributions are stored in the contract without a dedicated withdrawal function and these funds remain inaccessible by the host, creating a functionality gap.

Impact

ETH contributions become locked in the contract if no withdrawal mechanism exists, rendering them inaccessible by the host for the intended by the protocol purposes.

Tools Used

Manual review

Recommendations

Add an ETH-Specific Withdrawal Function, while ensuring that withdrawals are only possible after the deadline

function withdrawETH() external onlyHost {
require(block.timestamp > deadline, "Cannot withdraw before the deadline");
uint256 balance = address(this).balance;
payable(getHost()).transfer(balance);
}

or remake the existing ChristmasDinner::withdraw function, again concidering the deadline and adding ETH-transfer functionality:

function withdraw() external onlyHost {
+ ---> require(block.timestamp > deadline, "Cannot withdraw before the deadline");
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)));
+ ---> uint256 balance = address(this).balance;
+ ---> payable(_host).transfer(balance);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge about 1 year 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.

Give us feedback!