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.
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.
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.
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)
Implement Reentrancy Guard
Use OpenZeppelin’s ReentrancyGuard
to prevent reentrancy attacks in likeUser()
and matchRewards()
.
Restrict ETH Deposits
Add conditions in receive()
to allow only owner or approved contracts to deposit ETH.
Optimize Storage for Gas Efficiency
Use a single mapping with a struct instead of multiple mappings to track likes and matches.
Enhance Fee Withdrawal Security
Implement a time lock or require multi-signature approval for withdrawals by the owner.
Fix User Balance Management
Ensure that ETH sent for likes is properly credited to userBalances
and used when needed.
Make Fee Percentage Adjustable
Allow the owner to update FIXEDFEE
within a reasonable range through an onlyOwner
function.
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.
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.
Not the best design, but if you send money accidentally, that's a user mistake. Informational.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.