DatingDapp

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

userBalances in likeRegistry is not set in the code, causing the core Reward protocol to not work

userBalances in likeRegistry is not set in the code, causing the core Reward protocol to not work

Description: The userBalance mapping is not set in the code, meaning that if an user like someone his/her fund are not keep in the protocol.

Impact:

  1. No Reward mechanism possible, as the totalReward will be set to zero each time.

  2. The totalFee will be zero everytime a match is met.

  3. The multiSignWallet will not work as the value in it, will be zero.

Proof of Concept: You need to create a test file testLikeRegistry.t.sol

contract LikeRegistryTest is Test {
SoulboundProfileNFT soulboundNFT;
LikeRegistry likeRegistry;
address user = address(0x123);
address user2 = address(0x456);
address owner = address(this); // Test contract acts as the owner
function setUp() public {
soulboundNFT = new SoulboundProfileNFT();
likeRegistry = new LikeRegistry(address(soulboundNFT));
}
}

and add the following test

function testmatchReward() public {
uint256 initialBalance = 5e18; // user and user2 have 5 ether.
vm.deal(user, initialBalance);
vm.deal(user2, initialBalance);
vm.deal(owner, 1e18);
assertEq(user.balance, initialBalance, "user balance is not 5 ether");
assertEq(user2.balance, initialBalance, "user2 balance is not 5 ether");
assertEq(owner.balance, 1e18, "user2 balance is not 1 ether");
vm.prank(user);
soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage");
vm.prank(user2);
soulboundNFT.mintProfile("Bob", 27, "ipfs://profileImage");
// Alice and bob like each other, it will trigger matchReward.
vm.prank(user);
likeRegistry.likeUser{value: 1e18}(user2);
vm.prank(user2);
likeRegistry.likeUser{value: 1e18}(user);
// totalFee is empty meaning TotalReward is empty, meaning Reward is empty.
vm.startPrank(owner);
likeRegistry.withdrawFees;
if(owner.balance == 1e18) {
revert("Error : zero fee");
}
}

Recommended Mitigation: You need to set userBalance somewhere(likely in LikeRegistry::LikeUser), for the protocol to work properly.

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.