Vulnerability Details
The smart contract contains a vulnerability where the host is unable to withdraw Ether locked in the contract after the deadline has passed. Despite invoking the withdraw function, the Ether balance of the contract remains unchanged, preventing the host from accessing the funds collected for the event.
Impact
The Ether collected for the event remains locked in the contract, rendering it inaccessible to the host, which defeats the purpose of fund collection.
Tools Used
Foundry , VS Code
POC
function test_etherlockedInContract() public {
address dummyUser = makeAddr('786');
vm.deal(dummyUser, 10e18);
vm.startPrank(dummyUser);
(bool sendEther,) = address(cd).call{value: 10e18}("");
require(sendEther,"Failed to send ether");
vm.stopPrank();
uint256 etherBalanceBefore = address(cd).balance;
vm.startPrank(deployer);
vm.warp(DEADLINE + 1);
cd.withdraw();
vm.stopPrank();
uint256 etherBalanceAfter = address(cd).balance;
assertEq(etherBalanceBefore, etherBalanceAfter);
}
parwej@90CXC:/mnt/d/my Docs/2024-12-christmas-dinner$ forge test --mt test_etherlockedInContract
[⠒] Compiling...
[⠆] Compiling 1 files with Solc 0.8.28
[⠔] Solc 0.8.28 finished in 594.08ms
Compiler run successful!
Ran 1 test for test/ChristmasDinnerTest.t.sol:ChristmasDinnerTest
[PASS] test_etherlockedInContract() (gas: 81986)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 862.57µs (130.25µs CPU time)
Ran 1 test suite in 50.14ms (862.57µs CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
## Recommendations
function withdraw() external onlyHost {
address _host = getHost();
+ (bool success,) host.call{value: address(this).balance}("");
+ require(sucess,"failed to send ether");
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)));
}