The Airdrop::claim
function is intended to distribute LoveToken
to participants who are in a couple. But due to an incorrect implementation on the Soulmate::isDivorced
function, people who are no longer in a couple (divorced) can still claim LoveToken
.
The Airdrop::claim
function allows the people who are soulmates to claim 1 LoveToken
for every day in that they have been together. The README
of the protocol said for the Soulmate::getDivorced
function:
getDivorced: Where you and your soulmate are separated and no longer soulmates. This will cancel the possibily for 2 lovers to collect LoveToken from the airdrop.
Therefore, people who aren't anymore soulmates should not have the possibility to claim LoveToken
from Airdrop
.
The Airdrop::claim
function includes a check intended to prevent divorced participants from claiming LoveTokens
:
if (soulmateContract.isDivorced()) revert Airdrop__CoupleIsDivorced();
The Soulmate::isDivorced
function has the following implementation:
The isDivorced()
function doesn't accept any input arguments. It checks if the caller of the function (msg.sender
) is divorced. But when the Airdrop::claim
function calls the Soulmate::isDivorced()
function, the caller is the Airdrop
contract, not the caller of the claim
function (soulmate1
or soulmate2
). The address of Airdrop
contract is not in the divorced
mapping. Therefore, the return value from the call to the Soulmate::isDivorced
will be always false
.
The Airdrop::claim
function allows any divorced couple to claim 1 LoveToken
per a day.
The following test function test_ClaimDivorcedCouple()
shows that case. In this test scenario we have a soulmate1
and soulmate2
. They are firstly a couple, but then they decided to get divorced. Although that, the claim
function continues to allow them to claim LoveToken
.
You can add this function in the file AirdropTest.t.sol
and execute it with the Foundry
command: forge test --match-test "test_ClaimDivorcedCouple"
The test doesn't revert as expected:
The divorced couple (soulmate1 and soulmate2) successfully claim 5 LoveToken
from the Airdrop
which is not the intended logic.
VS Code, Foundry
In order to mitigate this issue you can add an input argument address
to the Soulmate::isDivorced
function:
Then you should modify the Airdrop::claim
function to calls the Soulmate::isDivorced
function in a proper way:
After these changes the test function test_ClaimDivorcedCouple
reverted as expected and the divorced couple can not claim a LoveToken
. The changes in the interface of the Soulmate
contract also should be made. Also, you should decide if the isDivorced
function should be called by anyone.
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.