DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

ETH CAN BE PERMANENTLY STUCK IN THE CONTRACT ON DIRECT TRANSFER

H-2 ETH CAN BE PERMANENTLY STUCK IN THE CONTRACT

Description:
The LikeRegistry contract can receive ETH through direct transfers but lacks a mechanism to retrieve ETH sent outside of the likeUser() function. Additionally, the withdrawFees() function only withdraws the tracked totalFees, leaving any other ETH permanently stuck in the contract.

Impact:
This has several severe impacts:

  1. ETH sent directly to the contract (not via likeUser) becomes permanently stuck

  2. Neither users nor admin can recover the stuck ETH

  3. Loss of user funds if they accidentally send ETH to the contract

  4. Violates the principle that contracts should have complete control over their funds

Proof of Concept

Test demonstrating ETH getting stuck in the contract:

function test_eth_stuck_in_contract() public {
// Arrange
_mintSoulNFT(USER1, "User 1", 20, "https://example.com/image.png");
_mintSoulNFT(USER2, "User 2", 20, "https://example.com/image.png");
// Act
_mutualLike(USER1, USER2);
//random user3 enters the contract and does not use the like function
vm.deal(USER3, 1 ether);
vm.prank(USER3);
(bool success,) = address(likeRegistry).call{value: 1 ether}("");
require(success, "Transfer failed");
//admin withdraws fees
vm.prank(likeRegistry.owner());
likeRegistry.withdrawFees();
// Assert
assertEq(address(likeRegistry).balance, 1 ether); //eth is stuck in the contract
}

Code Miigation

receive() external payable {
+ revert("Contract does not accept ETH");
}
Updates

Appeal created

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_receive_function

Not the best design, but if you send money accidentally, that's a user mistake. Informational.

Support

FAQs

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