DatingDapp

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

Critical Logic Change in matchRewards Function Parameters

Summary

During the review of the likeUser function in the smart contract, it was observed that the function call on line 46matchRewards(liked, msg.sender); has undergone an unauthorized change from its original flow. This alteration may impact the intended reward distribution logic and potentially introduce security risks.

Vulnerability Details

Incorrect Role Assignment in matchRewards

  • Originally, matchRewards was likely designed to process rewards in a specific order:

    • from (the user initiating the match)

    • to (the user receiving the like)

  • However, with the current order matchRewards(liked, msg.sender);, the liked user (liked) is now being treated as the sender (from), while the actual sender (msg.sender) is being treated as the recipient (to).

function likeUser(address liked) external payable {
require(msg.value >= 1 ether, "Must send at least 1 ETH");
require(!likes[msg.sender][liked], "Already liked");
require(msg.sender != liked, "Cannot like yourself");
require(profileNFT.profileToToken(msg.sender) != 0, "Must have a profile NFT");
require(profileNFT.profileToToken(liked) != 0, "Liked user must have a profile NFT");
likes[msg.sender][liked] = true;
emit Liked(msg.sender, liked);
// Check if mutual like
if (likes[liked][msg.sender]) {
matches[msg.sender].push(liked);
matches[liked].push(msg.sender);
emit Matched(msg.sender, liked);
matchRewards(liked, msg.sender); // Parameter order changed
}
}

Impact:

Parameter altered as per the original flow of the like likeuser user function.

Tools Used

Manual Method

Recommendations

Make the parameter order as according to the flow

function likeUser(address liked) external payable {
require(msg.value >= 1 ether, "Must send at least 1 ETH");
require(!likes[msg.sender][liked], "Already liked");
require(msg.sender != liked, "Cannot like yourself");
require(profileNFT.profileToToken(msg.sender) != 0, "Must have a profile NFT");
require(profileNFT.profileToToken(liked) != 0, "Liked user must have a profile NFT");
likes[msg.sender][liked] = true;
emit Liked(msg.sender, liked);
// Check if mutual like
if (likes[liked][msg.sender]) {
matches[msg.sender].push(liked);
matches[liked].push(msg.sender);
emit Matched(msg.sender, liked);
-- matchRewards(liked, msg.sender);
++ matchRewards(msg.sender, liked);
}
}
Updates

Appeal created

n0kto Lead Judge 5 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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.