Description:
The LikeRegistry
contract contains a critical vulnerability in its balance tracking mechanism. The contract uses a single userBalances
mapping to track all ETH sent by a user across all their likes, rather than tracking balances per-like. When a match occurs, the contract uses the sender's entire pooled balance rather than just the amount associated with the specific match.
This means when a user sends ETH to like multiple users, an early match can drain ETH that was intended for other potential matches, essentially "stealing" funds that were meant for later matches.
Impact:
HIGH - The vulnerability directly leads to loss of user funds and breaks the core matching mechanism of the protocol. It allows:
Early matches to claim more ETH than they should be entitled to
Later matches to receive less ETH than users intended
Potential denial of service as users' intended matches cannot be properly funded
Breaking of user expectations and trust in the protocol
Proof of Code:
Proof of Concept:
Here's a step-by-step walkthrough of how the vulnerability can be exploited:
Alice sends multiple likes:
Bob triggers an early match:
The match calculation in matchRewards
uses ALL of Alice's balance:
When Carol later matches with Alice:
The match with Carol can't access the 3 ETH Alice originally intended, as it was drained in the match with Bob.
Recommended Mitigation:
Replace the single userBalances
mapping with a per-like balance tracking system:
This ensures that:
Each like's ETH is tracked separately
Matches only use the ETH associated with that specific pair of likes
Early matches cannot drain ETH intended for other potential matches
Additionally:
Add explicit balance tracking per like/match pair
Clear balances after successful matches
Add events for balance updates and tracking
Consider adding a mechanism to allow users to update or withdraw unmatched like amounts
This change maintains the integrity of the matching system and ensures user funds are used as intended.
Likelihood: Medium, if anyone has 2 matches or more before reliking. Impact: Medium, the user won't contribute to the wallet.
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.