DatingDapp

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

Lack of Recovery Function for Excessive ETH Sent

Summary

The LikeRegistry contract allows ETH to be sent via its receive function but lacks a mechanism to recover or withdraw excessive ETH. Additionally, when computing fees (e.g., totalRewards * FIXEDFEE / 100), if totalRewards is not an exact number which could cause rounding down issues, small dust amounts may accumulate over time, becoming permanently locked within the contract.

Vulnerability Details

The LikeRegistry contract has a receive function, allowing anyone to send ETH to the contract, but there is no function to withdraw these funds. Additionally, The contract performs calculations where ETH amounts are divided and fees are rounded down, leaving small dust amounts behind. Although negligible, over time, these dust amounts accumulate and become permanently locked in the contract, leading to inefficiencies in fund management.

Impact

  • ETH sent mistakenly or in excess cannot be recovered.

  • Dust amounts resulting from rounding issues accumulate indefinitely, potentially reaching significant levels over time.

  • The contract owner can withdraw only the explicitly tracked fees, but excess ETH from incorrect transactions remains locked.

Tools Used

Manual review

Recommendations

Implement a recover function allowing the owner to withdraw untracked ETH that is not part of user balances or fees. If owner is not to be fully trusted add additional internal accounting, so that the owner cannot rug pull the users.

uint256 public totalDepositedAmount; // prevent rug pull, update on each likeUser() call
function recoverETH() external onlyOwner {
uint256 contractBalance = address(this).balance;
uint256 withdrawableBalance = contractBalance - totalDepositedAmount - totalFees;
require(withdrawableBalance > 0, "No excess ETH to recover");
(bool success,) = payable(owner()).call{value: withdrawableBalance}("");
require(success, "Withdraw failed");
}
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.