DatingDapp

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

Security and Functional Audit of LikeRegistry.sol in DatingDapp

Summary

The LikeRegistry.sol contract facilitates decentralized matchmaking by allowing users to like profiles through payments and establishing mutual matches. It integrates a fee system, maintains a record of user interactions, and deploys a multisig wallet for matched users. However, security risks and functional inefficiencies need to be addressed to ensure fairness, prevent fund loss, and optimize the contract’s efficiency.

Vulnerability Details

Reentrancy Risk :

  • The function likeUser() makes external calls while modifying state variables. An attacker could exploit this by re-entering the function before state changes finalize.

    **Lack of Fallback Function Security **:

  • The receive() function allows arbitrary ETH deposits without restrictions, leading to potential misuse where attackers could flood the contract with ETH, making it harder to track legitimate payments.

    Gas Inefficiency in Mapping Updates:

  • The matches mapping stores multiple arrays per address, increasing storage costs and making retrieval operations expensive.


    No Fee Withdrawal Control:

  • The contract lacks time locks or multi-approval mechanisms for fee withdrawals, enabling the owner to withdraw at will.

    User Balance Management Issues:

  • User balances are stored but never used in likeUser(). This could lead to ETH being locked in the contract unintentionally.


    Fixed Fee Percentage is Hardcoded:

  • A FIXEDFEE of 10% is hardcoded, reducing flexibility for future changes and adjustments without redeploying the contract.

Impact

  • Potential Fund Loss: A reentrancy attack could allow an attacker to drain ETH before state updates finalize.

  • High Gas Fees: Inefficient data storage increases transaction costs, making the system less user-friendly.

  • Lack of Administrative Control: The absence of access control mechanisms for fee withdrawals increases risks of mismanagement or unauthorized access.

  • User Trust Issues: The inability to update the fee dynamically could make the platform uncompetitive in the long run.

Tools Used

  • Slither (Static analysis for vulnerabilities)

  • Hardhat (Contract testing and debugging)

  • Foundry (Fuzz testing and security validation)

  • Remix IDE (Code review and simulation)

  • OpenZeppelin Contracts (For best security practices)

Recommendations

  1. Implement Reentrancy Guard

    • Use OpenZeppelin’s ReentrancyGuard to prevent reentrancy attacks in likeUser() and matchRewards().

  2. Restrict ETH Deposits

    • Add conditions in receive() to allow only owner or approved contracts to deposit ETH.

  3. Optimize Storage for Gas Efficiency

    • Use a single mapping with a struct instead of multiple mappings to track likes and matches.

  4. Enhance Fee Withdrawal Security

    • Implement a time lock or require multi-signature approval for withdrawals by the owner.

  5. Fix User Balance Management

    • Ensure that ETH sent for likes is properly credited to userBalances and used when needed.

  6. Make Fee Percentage Adjustable

    • Allow the owner to update FIXEDFEE within a reasonable range through an onlyOwner function.

Updates

Appeal created

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

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

invalid_reentrancy_with_no_impact

matchRewards: Contract is created just before and is the one called. No impact. executeTransaction: CEI is followed. Emitting an event in disorder is informational in that context. withdraw: CEI is followed.

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.