The getDivorced function is supposed to be used by users who have already been paired up with another user, to initiate a divorce between the two. However, a flaw in Soulmate.sol allows users to invoke the getDivorced function regardless of their current pairing status. This includes users who have never been paired (minted a soulmate token) and users who have initiated the minting process but have not yet been paired with another user. The issue allows for a divorce state to be set for users outside the intended logic of requiring a pair to be formed first.
The Soulmate::getDivorced function does not check whether a user is currently in a paired state before allowing the divorce action to proceed. This results in the possibility for a user to:
Become divorced without ever having a soulmate.
Become divorced while in a waiting state for a soulmate.
Impact the logical flow of the contract by allowing users in unintended states to become divorced.
The contract uses a boolean mapping to track divorced states, and the absence of checks allows any user to set their divorced state to true.
Place the following piece of code to SoulmateTest.t.sol:
This vulnerability disrupts the intended logic and flow of the Soulmate contract by allowing users to reach a divorced state without ever entering a proper pairing. This could lead to inconsistencies within the contract state, affecting the overall integrity of the system.
For example, consider the following scenario:
UserA calls Soulmate::mintSoulmateToken, and waits to be paired up with somebody else.
Before having been paired up with another user, UserA accidentally calls Soulmate::getDivorced which sets its divorced state to true.
UserB calls Soulmate::mintSoulmateToken and, consequently, is paired up with UserA. Now we have a couple made up by UserA who has a divorced state true, andUserB who has a divorced state false.
Even thoughUserA has not divorced UserB, UserA will not be able to collect its share of love tokens by calling Airdrop::claim due to its divorced flag being true.
Manual review.
Implement checks within getDivorced to ensure that a user is in a valid state to request a divorce:
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.