Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

Unchecked Multiplication in `Airdrop::claim()` Function (Risk of Overflow)

Medium

[M-1] Unchecked Multiplication in Airdrop::claim() Function (Risk of Overflow)

Description:

The Airdrop::claim() function in the Airdrop contract lacks explicit protection against potential overflow vulnerabilities when calculating the numberOfDaysInCouple and subsequently determining the token amount to distribute. This vulnerability arises due to the unchecked multiplication of numberOfDaysInCouple with 10 ** loveToken.decimals().

Impact:

The impact of this vulnerability is significant as it can lead to incorrect token amounts being distributed or even contract malfunction. If numberOfDaysInCouple becomes sufficiently large, the resulting token amount calculation could overflow, resulting in unexpected behavior or loss of funds.

Proof of Concept:

The Airdrop::claim() function, specifically the numberOfDaysInCouple. However, in the provided test case testInvariantStatelessFuzz_ClaimWillOverflow, the attempt to trigger an overflow.

PoC
// Test claiming function with different scenarios
function testInvariantStatelessFuzz_ClaimWillOverflow(uint256 day) public {
_mintOneTokenForBothSoulmates();
vm.prank(soulmate1);
vm.expectRevert();
airdropContract.claim();
vm.warp(block.timestamp + (day * 1 days) + 1 seconds);
vm.prank(soulmate1);
airdropContract.claim();
assertTrue(loveToken.balanceOf(soulmate1) == (day * 1 ether));
vm.prank(soulmate2);
airdropContract.claim();
assertTrue(loveToken.balanceOf(soulmate2) == (day * 1 ether));
}

Recommended Mitigation:

To mitigate this vulnerability, it's recommended to implement checks to prevent potential overflow scenarios. One approach is to use SafeMath or similar libraries to perform arithmetic operations safely. Additionally, consider validating input parameters and implementing sanity checks to ensure the integrity of calculations.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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