DatingDapp

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

It is possible for one person to date multiple partners.

Description

In LikeRegistry::likeUser() a user can be liked by another person even after a profile is matched to different person. Which creates a possibility to date multiple people.

Example :

  • Adam and Eve has matched the profile

  • Alice likes Adam's profile

  • Now Adam is able to like Alice's profile despite having matched with Eve.

  • which will create a possibility to date multiple person.

Impact

It allows one person to date multiple partner, which does not ensures genuine connection.

Proof of Concept

Create testLikeRegistry.t.sol file and add this code

Run with forge test --mt testMultipleMatchedProfile -vv

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/SoulboundProfileNFT.sol";
import "../src/LikeRegistry.sol";
contract TestLikeRegistry is Test {
SoulboundProfileNFT soulboundNFT;
address Alice = address(0x123);
address Bob = address(0x456);
address Eve = address(0x789);
address owner = makeAddr("owner"); // Test contract acts as the owner
LikeRegistry likeRegistry;
function setUp() public {
vm.prank(owner);
soulboundNFT = new SoulboundProfileNFT();
vm.prank(owner);
likeRegistry = new LikeRegistry(address(soulboundNFT));
}
modifier createProfile() {
vm.prank(Alice); // Simulates user calling the function
soulboundNFT.mintProfile("Alice", 25, "ipfs://profileImage");
vm.prank(Bob); // Simulates user calling the function
soulboundNFT.mintProfile("Bob", 25, "ipfs://profileImage");
vm.prank(Eve); // Simulates user calling the function
soulboundNFT.mintProfile("Eve", 25, "ipfs://profileImage");
vm.deal(Alice, 10 ether);
vm.deal(Bob, 10 ether);
vm.deal(Eve, 10 ether);
_;
}
function testMultipleMatchedProfile() public createProfile {
// Alice likes Bob
vm.prank(Alice);
(bool success,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Bob));
// Bob likes Alice
vm.prank(Bob);
(bool success2,) =
address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Alice));
// Eve likes Bob
vm.prank(Eve);
(bool success3,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Bob));
// Bob likes Eve
vm.prank(Bob);
(bool success4,) = address(likeRegistry).call{value: 1 ether}(abi.encodeWithSignature("likeUser(address)", Eve));
// Getting matchs for bob
vm.prank(Bob);
address[] memory userLikes = likeRegistry.getMatches();
// asserting that Bob has two matches
assert(userLikes.length == 2);
// looping over matches profiles for Bob
for (uint256 i; i < userLikes.length; i++) {
console.log(userLikes[i]);
}
}
/
* Ran 1 test for test/testLikeRegistry.t.sol:TestLikeRegistry
* [PASS] testMultipleMatchedProfile() (gas: 5084272)
* Logs:
* 0x0000000000000000000000000000000000000123
* 0x0000000000000000000000000000000000000789
*
* Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.13ms (868.20µs CPU time)
*/
}

Recommended Mitigation

Here we are checking if liked address is already match with someone.

In LikeRegistry.sol

function likeUser(address liked) external payable {
// Checking wether the liked address is matched or not
+ address[] memory userMatches = getMatchesForUser(liked);
+ require(userMatches.length == 0, "Already matched");
...
}
+ function getMatchesForUser(address liked) public view returns (address[] memory) {
+ return matches[liked];
+ }
Updates

Appeal created

n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice
0x1422 Submitter
7 months ago
n0kto Lead Judge
7 months ago
n0kto Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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