DatingDapp

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

LikeRegistry: Locked ETH in Contract Due to Incomplete Withdrawal Mechanism

Summary

The contract allows receiving ETH via the receive() function but lacks a mechanism to withdraw any surplus ETH that is not tracked by totalFees. The existing withdrawFees function only allows withdrawing totalFees, leaving any excess ETH permanently stuck in the contract.

Vulnerability Details

The contract includes a receive() function and it has a payable function, allowing it to accept ETH. However, the only withdrawal function, withdrawFees, is limited to withdrawing the value stored in totalFees. This means any ETH sent to the contract outside of the expected fee structure will remain inaccessible.

To address this, the withdrawSurplus function has been introduced:

function withdrawSurplus() external onlyOwner {
address owner = owner();
uint256 balance = address(this).balance;
uint256 surplus = balance - totalFees;
require(surplus > 0, "No surplus to withdraw");
(bool success,) = payable(owner).call{ value: surplus }("");
require(success, "Transfer failed");
}

This function ensures that any extra ETH that is not accounted for in totalFees can be recovered by the contract owner.

Impact

Severity: High

  • ETH sent to the contract outside of the fee mechanism would be permanently locked, leading to potential fund loss.

  • The protocol’s treasury management becomes inflexible, as only totalFees can be withdrawn.

  • Users who mistakenly send ETH to the contract will have no way to recover it.

Recommended Fix

The withdrawSurplus function correctly addresses the issue by allowing the owner to withdraw excess ETH. Ensure that this function is included and properly tested before deployment to avoid permanently locked funds.

Tools Used

  • Manual Code Review

  • Foundry Testing

Updates

Appeal created

n0kto Lead Judge 6 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.