DatingDapp

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

[H-1] matchRewards Fail to Process Fees Due to Unupdated User Balances

Summary

The `LikeRegistry::matchRewards` function fails to process fees correctly because user balances are never updated in the `LikeRegistry::likeUser` function. When users send ETH via `likeUser()`, the value is not recorded in the `LikeRegistry::userBalances` mapping. as a result, when `matchRewards` is calling during a match, it processes zero balances instead of the actual ETH sent by users

Vulnerability Details

```solidity

function testIncorrectFeeCalculation() public {

vm.deal(user1, 2 ether);

vm.deal(user2, 2 ether);

uint256 initialOwnerBalance = owner.balance;

vm.prank(user1);

likeRegistry.likeUser{value: 1 ether}(user2);

vm.prank(user2);

likeRegistry.likeUser{value: 1 ether}(user1);

vm.prank(owner);

vm.expectRevert();

likeRegistry.withdrawFees();

uint256 totalFees = owner.balance - initialOwnerBalance;

assertEq(totalFees, 0); // This checks if no fees were withdrawn (0)

}

```

Impact

High

Tools Used

foundry

Recommendations

Update `LikeRegistry::likeUser` to track sent ETH

```diff

function likeUser(address liked) external payable {

// ... existing checks ...

+ userBalances[msg.sender] += msg.value;

likes[msg.sender][liked] = true;

// .... existing code ...

}

```

Updates

Appeal created

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