Description: The withdraw()
function lacks deadline validation, allowing the host to withdraw funds before the deadline. The actual vulnerability is found here:
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:
Host can drain all user deposits before the event
Complete loss of user funds
Breaks the trust model of the contract
Proof of Concept:
function testPrematureWithdraw() public {
vm.prank(host);
christmasDinner.setDeadline(7);
vm.deal(alice, 1 ether);
vm.prank(alice);
(bool success,) = address(christmasDinner).call{value: 1 ether}("");
require(success);
vm.prank(host);
christmasDinner.withdraw();
assertEq(address(christmasDinner).balance, 0);
}
Recommended Mitigation: Add deadline check to withdraw()
function:
function withdraw() external onlyHost {
require(block.timestamp > deadline, "Cannot withdraw before 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)));
}