The LikeRegistry::likeUser
function fails to update a user's balance when Ether is sent, resulting in inaccurate tracking of funds. Additionally, the userBalances
mapping is designed to track a single balance per address, whereas it should map balances for each like interaction between two parties.
Problem with Updating userBalances:
– When a match occurs and the contract is expected to forward all Ether collected by both partners to a new multisig wallet, the match function verifies the Ether amounts by checking the userBalances of each user.
– Because likeUser never increments the corresponding balance entry, the userBalances remain at zero even though Ether was sent. As a result, the match function cannot accurately account for the funds held on behalf of the users.
Incorrect Mapping Structure:
– The current implementation uses a single-level mapping:
mapping(address => uint256) public userBalances;
This design maps one balance to an address but doesn’t distinguish between multiple relationships (i.e. which user liked which other user).
– To correctly track the funds associated with each “like” or match, the mapping should be nested:
mapping(address => mapping(address => uint256)) public userBalances;
With this change, the balance from user A to user B (and vice versa) can be tracked independently.
Missing Update Logic:
– The likeUser function should update the mapping by adding the sent Ether amount to the balance corresponding to the sender and the target user. Without this update, any Ether sent is not recorded properly, leading to potential issues in future fund claims or in executing matching logic.
Funds Misaccounted:
– Since the Ether sent through likeUser is not added to any internal ledger, it becomes impossible for the contract to later determine how much Ether each user contributed and the fund are irrecoverable.
Broken Match Functionality:
– The match function relies on userBalances to verify the total funds that should be forwarded to a new multisig wallet. Without proper balance updates, a match result in an incorrect transfer of funds.
Foundry
Change the Mapping Structure:
– Replace the single-level mapping with a nested mapping to track funds per like between two parties:
Update the Balance in likeUser:
– Modify the likeUser function to record the sent Ether amount into the proper balance entry. For instance:
Likelihood: High, always. Impact: High, loss of funds
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.