TSender

Cyfrin
DeFiFoundry
15,000 USDC
View results
Submission Details
Severity: medium
Invalid

The `TSender_NoCheck::AIRDROP_ERC20` supposed huff replica of the `GasliteDrop` contract is missing a check

Summary

The TSender_NoCheck.huff which supposes to be the huff equivalent of the GasliteDrop::airdropERC20 function according to the documentation, lacks an important check present in the original GasliteDrop::airdropERC20 solidity implementation. This check ensures that the lengths of the amounts and recipients arrays match. The absence of this check could lead to financial loss for the caller.

Vulnerability Details

The documentation mentions the following :

TSender_NoCheck.huff: The Huff implementation without the extra checks, making the output similar to GasliteDrop. Much more gas efficient, but without any safety rails.

And

The TSender_NoCheck.huff does not have the extra checks, but is just a gas optimized version of the original GasliteDrop contract.

This means that TSender_NoCheck.huff is the exact replica of the functionalities of the GasliteDrop contract (the erc20 airdrop part). But with a specificity being a highly gas optimized contract. However, unlike it's original solidity implementation, it lacks the length check.

In the GasliteDrop implementation, the function airdropERC20 starts with the following check :

assembly {
// Check that the number of addresses matches the number of amounts
if iszero(eq(_amounts.length, _addresses.length)) { revert(0, 0) }

Impact

The huff implementation does not follow the documentation. Plus, it will lead to loss of funds for the caller if If the amounts array is longer than the recipients array as more tokens would be sent to the contract than the recipients. Any additionnal funds would be forever locked.
Since this goes against the documentation, this has medium severity.

Tools Used

Manual review

Recommendations

Consider adding the following check in the TSender_NoCheck.huff at the begining of the AIRDROP_ERC20 macro :

[NUMBER_OF_AMOUNTS_OFFSET_OFFSET] calldataload
calldataload
[NUMBER_OF_RECIPIENTS_OFFSET] calldataload
eq
lengths_match jumpi
// cast sig TSender__LengthsDontMatch()
0x50a302d6 0x00 mstore
0x04 [TWENTY_EIGHT] revert
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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