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

A user can accidentally be divorced even before finding a soulmate initially.

Summary

In the Soulmate protocol, only a user who already has a soulmate could divorce. However, it has been discovered that a user can be in a divorced state without ever having had a soulmate.

Vulnerability Details

The lack of verification in Soulmate::getDivorced regarding whether a user currently has a soulmate could result in a situation where a user can be divorced if the function is called, regardless of whether the user has a valid soulmate or not.

The following PoC can be added to SoulmateTest.t.sol to verify this.

function test_CanDivorceAlone() public {
vm.startPrank(soulmate1);
soulmateContract.getDivorced();
assertTrue(soulmateContract.isDivorced() == true);
vm.stopPrank();
}

Impact

The impact of this vulnerability is LOW. According to the protocol description, 'Soulmate::getDivorced' offers no way to undo this action. Once a user is in the divorced state, it is permanent, and the user can no longer receive airdrops. Hence, it is important to ensure that a user cannot accidentally enter a divorced state by mistake.

Tools Used

Foundry

Recommendations

When a user calls Soulmate::getDivorced, it is essential to check that the user has a valid soulmate. A custom error, error Soulmate__doesNotHaveASoulmate(), could be defined and used for this purpose.

function getDivorced() public {
address soulmate2 = soulmateOf[msg.sender];
+ if (soulmate2 == address(0))
+ revert Soulmate__doesNotHaveASoulmate();
divorced[msg.sender] = true;
divorced[soulmateOf[msg.sender]] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}
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.