Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Valid

Lack of Validation Leading to Potential Fund Loss in Vault

Summary

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.

Vulnerability Details

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.

Impact

A test scenario exemplifies this potential issue:

function test_AllFundsDrained() public {
vm.warp(10_000 days + 1 seconds);
vm.prank(soulmate1);
airdropContract.claim();
assertEq(loveToken.balanceOf(soulmate1), 10_000 ether);
}

In this case, soulmate1, who did not mint any tokens, still receives 10,000 love tokens as a reward, deviating from the intended specification.

Tools Used

Manual Review

Recommendations

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.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-claim-airdrop-without-owning-NFT

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.