The claimAirdrop
function lacks validation to determine whether the user is reunited or not. If a user who is not reunited attempts to claim the reward, the idToCreationTimestamp
mapping value remains the default, resulting in a calculation error. This miscalculation could lead to a significant value for numberOfDaysInCouple
, potentially exceeding the balance of the vault contract and causing the withdrawal of all funds.
If a user is not reunited, either because they minted a soulmate NFT but did not find a match or did not mint an NFT at all, attempting to claim the reward in the Airdrop leads to an issue. The idToCreationTimestamp
mapping value is not updated, remaining at the default zero value. The calculation of numberOfDaysInCouple
becomes the pure result of block.timestamp / daysInSecond
, representing the days since the initial block creation. Consequently, the tokenAmountToDistribute
becomes excessively large, potentially causing the user to drain all funds in the Airdrop vault contract.
A test scenario exemplifies this potential issue:
In this case, soulmate1, who did not mint any tokens, still receives 10,000 love tokens as a reward, deviating from the intended specification.
Manual Review
To address this vulnerability, it is recommended to add validation checks to determine whether the user is reunited or not. Additionally, consider validating whether idToCreationTimestamp
is at its default value before proceeding with the reward claim.
High severity, This issue is separated from the flawed `isDivorced()` check presented in issue #168 as even if that is fixed, if ownership is not checked, isDivorced would still default to false and allow bypass to claim airdrops by posing as tokenId 0 in turn resulting in this [important check for token claim is bypassed.](https://github.com/Cyfrin/2024-02-soulmate/blob/b3f9227942ffd5c443ce6bccaa980fea0304c38f/src/Airdrop.sol#L61-L66). #220 is the most comprehensive issue as it correctly recognizes both issues existing within the same function.
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.