The claim
function in the Airdrop contract has a vulnerability that allows users to claim LoveTokens without verifying Soulmate NFT ownership. Additionally, the current implementation lacks proper checks for the claim period, enabling potential malicious users to exploit the contract and claim LoveTokens without the necessary ownership requirements.
The claim
function does not include a check to ensure that the caller owns a Soulmate NFT. Without this check, any address can call the function and claim LoveTokens, violating the intended behavior described in the function comment.
The existing claim period check is insufficient. The current implementation relies on the calculation of the number of days since the last claim, but it does not ensure that enough time has passed since the user's Soulmate NFT creation. As a result, malicious users can exploit this loophole to claim LoveTokens even if they do not meet the necessary ownership criteria.
Malicious actors could exploit these issues to claim LoveTokens without the required Soulmate NFT ownership, leading to financial losses and undermining the fairness of the distribution mechanism.
Copy the below test and run it via cmd forge test --match-test testClaimByHacker -vvvv
Result:
Implement Soulmate NFT Ownership Check:
Include a check in the claim
function to ensure that the caller owns a Soulmate NFT before proceeding with the LoveToken claim process.
Enhance Claim Period Verification:
Improve the claim period verification by considering the time since the user's Soulmate NFT creation rather than only the time since the last claim. This ensures that users can claim LoveTokens only once per day, in line with the intended functionality.
For example the new code should look like this so that it has the required checks:
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.