Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Anyone can initiate a "divorce" from a person who doesn't exist, creating ambiguity within the `Soulmate` Protocol.

Summary

Literally anybody, even those who haven't found their soulmate, can execute the getDivorced public function. Consequently, the execution results in a successful divorce between the individual who invoked the getDivorced function and a nonexistent (address(0)) person.

// ----------------
// -------- ||
// ---- \/
@> function getDivorced() public {
address soulmate2 = soulmateOf[msg.sender];
divorced[msg.sender] = true;
divorced[soulmateOf[msg.sender]] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}

Vulnerability Details

nonexistent divorce
  1. Place the following test code snippet into the test/unit/soulmateTest.t.sol file. Put it at the very bottom but before the last closing semicolon }.

function test_divorce() public {
address bob = makeAddr("BOB");
address soulmateOfBob = soulmateContract.soulmateOf(bob);
vm.startPrank(bob);
bool isDivorcedBefore = soulmateContract.isDivorced();
soulmateContract.getDivorced();
bool isDivorcedAfter = soulmateContract.isDivorced();
vm.stopPrank();
console2.log("Soulmate of Bob: ", soulmateOfBob);
console2.log("Divorce status before getting divorced: ", isDivorcedBefore);
console2.log("Divorce status after getting divorced: ", isDivorcedAfter);
assertEq(soulmateOfBob, address(0));
assertEq(isDivorcedBefore, false);
assertEq(isDivorcedAfter, true);
}
  1. Open Your Bash Terminal and execute the following command...

forge test --mt "test_divorce" -vv --via-ir
  1. Ouput should indicate that test Passed Successfully and not reverted anywhere. So, It's ambiguous that Anyone can get divorced with a nonexistent person so called address(0).

Impact

This behavior doesn't result in any tangible consequences other than creating ambiguity within the Soulmate Protocol.

Tools Used

Foundry Framework (Solidity, Rust)

Recommendations

Update the src/Soulmate.sol file with the following code modifications...

...
...
...
error Soulmate__alreadyHaveASoulmate(address soulmate);
error Soulmate__SoulboundTokenCannotBeTransfered();
+ error Soulmate__DontHaveAnySoulmate(address soulmate);
...
...
...
function getDivorced() public {
+ address sendersSoulmate = soulmateOf[msg.sender];
+ if (sendersSoulmate == address(0)) {
+ revert Soulmate__DontHaveAnySoulmate(sendersSoulmate);
+ }
address soulmate2 = soulmateOf[msg.sender];
divorced[msg.sender] = true;
divorced[soulmateOf[msg.sender]] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}
...
...
...

After modifying and updating the Soulmate.sol file, try to re-execute the test discussed in the Proof of Concept (PoC). It should get reverted with the error Soulmate__DontHaveAnySoulmate(0x0000000000000000000000000000000000000000), which may also have one argument of a zero address.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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