DatingDapp

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

userBalance problem

Summary

In "likedRegistry" contract, there is an internal function called "matchRewards" and it's called whenever both addresses liked each other. there is a logic error in this funciton.

Vulnerability Details

uint256 matchUserOne = userBalances[from];
uint256 matchUserTwo = userBalances[to];
userBalances[from] = 0;
userBalances[to] = 0;

So in this particular code, we can see that "matchUserOne" and "matchUserTwo" are getting and storing their values from "userBalances" mapping. The problem is, "userBalances" never gets update to users current balance, meaning that both "from" and "to" balances in "userBalances" mapping remains zero forever. Beacuase the only logic that updates "userBalance" mapping for users, is in this block despite it will set it to zero again.

Impact

Beacuase of this logic error, all ethers are stored in "likedRegistry" contract and the call function in "matchRewards" always sends zero ether to the "MultiSig" deployed contract.

Tools Used

Remix IDE, Hardhat

Recommendations

You should add this line in "likeUser" funciton in order to store users balance.

userBalances[msg.sender] = msg.value
Updates

Appeal created

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