The LikeRegistry
contract has a design flaw where the likes
mapping is not reset after a mutual match. This prevents users from matching again in the future, as the likes
mapping remains true
indefinitely. This issue limits the functionality of the contract and prevents users from re-engaging with each other after an initial match.
When a user decides to like other user, he calls LikeRegistry::likeUser
which then calls LikeRegistry::matchRewards
if there are matches. The likes
mapping is used to track whether a user has liked another user. Once a mutual like occurs, the users are matched, and their addresses are added to the matches
mapping. However, the likes
mapping is not reset after a match, meaning that users cannot like each other again in the future. This is because the likeUser
function includes a check to ensure that a user cannot like another user more than once (require(!likes[msg.sender][liked], "Already liked");
). But after MultiSigWallet
has been created for both users and their funds sent to it, their likes mappings should be reset so they can be able to re-engage in the future.
The provided test case test_UnableToMatchMutualsAgain
demonstrates the issue. After USER1 and USER2 mutually like each other and MultiSigWallet created for them, USER1 is unable to like USER2 again in the future because the likes
mapping is not reset.
Here is the code the prove the scenario. Create a new test file LikeRegistryTest.t.sol
and add to the test/
directory.
Then run the command below;
The impact of this issue is as follows:
Users are unable to like each other again after an initial mutual match, limiting the functionality of the contract.
This design flaw could lead to a poor user experience, as users expect to be able to interact with each other multiple times.
Manual review
Foundry (Forge) for testing and vulnerability demonstration.
To address this issue, the likes
mapping should be reset after a mutual match. This can be achieved by updating the matchRewards
function to reset the likes
mapping for both users involved in the match. Here is the recommended fix:
By resetting the likes
mapping, users will be able to like each other again in the future, enabling repeated interactions and improving the overall user experience.
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.
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.