DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: high
Valid

User Balances Are Not Updated in likeUser()

Summary

The likeUser() function requires users to send 1 ETH, but does not update userBalances[msg.sender]. This results in incorrect reward distribution in matchRewards(), leading to zero or miscalculated rewards for matched users.

Vulnerability Details

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; // ✅ Stores the like, but does not track ETH sent
emit Liked(msg.sender, liked);
if (likes[liked][msg.sender]) {
matches[msg.sender].push(liked);
matches[liked].push(msg.sender);
emit Matched(msg.sender, liked);
matchRewards(liked, msg.sender);
}
}

Problem:

  • The function accepts ETH but does not store the amount sent by msg.sender.

  • When matchRewards() is called, userBalances[msg.sender] remains 0, leading to zero rewards.

  • Matched users may receive less than expected rewards, or rewards may go unclaimed.

Impact

  • Incorrect reward distribution: Users may receive no rewards despite contributing ETH.

  • Potential user dissatisfaction: Users may lose trust in the dApp.

  • Financial loss risk: Funds may get stuck in the contract instead of being distributed.

Tools Used

Manual Review

Recommendations

Store ETH sent by users when they like someone.

userBalances[msg.sender] += msg.value; // ✅ Fix: Store ETH amount sent by user
Updates

Appeal created

n0kto Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

finding_likeUser_no_userBalances_updated

Likelihood: High, always. Impact: High, loss of funds

Support

FAQs

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