Soulmate::getDivorced
does not check if you have a soulmate, therefore allowing for a pair to be one registered as Divorced and the other as Not divorced.
In Soulmate
contract there is a function getDivorced
that sets to false
the value paired with your address in divorced
.
However, as you can see, there is no if clause to check if msg.sender
is actually linked to a soulmate!
It allows to divorce before getting a soulmate. Moreover, after being linked with a soulmate, in the divorced
mapping, msg.sender
appears as divorced (value is true
), whereas the soulmate appears as not divorced (value is false
) creating a state not expected to be possible by the contract.
I assessed the severity of this finding as Medium due to the lack of consequences it has in the current version of the contract (Does not generate any advantage to the pair or creates malfunction).
Foundry
Proof of Concept:
1- soulmate3
calls Soulmate::mintSoulmateToken
when nobody is looking for a soul
2- soulmate3
calls Soulmate::getDivorced
before any other user calls Soulmate::mintSoulmateToken
, getting its value in divorced
changed to true
3- A soulmate4
calls Soulmate::mintSoulmateToken
, and gets paired with soulmate3
. Neither soulmate3
nor soulmate4
called Soulmate::getDivorced
after being paired, so the value of soulmate4
in divorced
is false
Add the following code to the SoulmateTest.t.sol
file.
Recommended Mitigation:
Adding a check to revert if msg.sender
does not have a soulmate yet, and a custom error to give verbosity to the situation:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.