The contract TSender
has a function called airdropERC20()
which is responsible for airdropping ERC20 tokens. The issue arises from the sequence in which the total amount of tokens is verified against the sum of individual airdrop amounts. This discrepancy can lead to failed or partial token transfers, causing inefficiencies in the airdrop process.
The airdropERC20()
function performs the check if iszero(eq(addedAmount, totalAmount))
after initiating the token transfers to the recipients. This sequence allows the totalAmount
specified to be different from the actualTotal
calculated from the amounts array, potentially leading to inconsistencies and incorrect behavior in the airdrop process. For example, if the user specifies totalAmount
as 10 tokens but the sum of the amounts array (actualTotal) is 20 tokens, the contract will attempt to transfer the specified amounts. This results in the contract running out of tokens mid-way through the process, causing partial transfers and transaction failure, thereby wasting gas and causing inefficiencies.
If the totalAmount
provided is less than the sum of the amounts
array, the function may proceed with the incorrect assumption, resulting in:
Failed Transfers: If the contract runs out of tokens mid-way through the airdrop.
Partial Airdrops: Where some recipients receive their tokens while others do not, leading to an incomplete and inefficient distribution.
Wasted Gas Costs: And potential loss of funds for users initiating the airdrop due to the transaction reverting late in the process.
These issues can significantly disrupt the intended airdrop operations and cause operational inefficiencies and dissatisfaction among users.
Manual Review
Pre-transfer Validation: Calculate the actualTotal
from the amounts
array and verify it against totalAmount
before initiating any token transfers. This pre-transfer validation ensures that the total amount specified matches the sum of the individual amounts to be airdropped.
Code Adjustment: Move the check if iszero(eq(addedAmount, totalAmount))
to immediately after calculating actualTotal
and before any token transfers.
Revised implementation:
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.