TSender

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

`areListsValid` interface is not defined as `pure` in the huff implementation which costs gas fees

Summary

The areListsValid function in the huff implementation is not declared as pure, resulting in unnecessary gas costs for validation checks that could be performed off-chain or in a pure context. This beats the purpose of this function.

Vulnerability Details

The areListsValid function is designed to perform several validation checks on recipients and amounts arrays. According to the documentation it's purpose is to perform theses checks without cost :

Additionally, we did not want to spend gas checking a few things, so we added a function called areListsValid that takes in a address[] recipients and uint256[] amounts to check for:

  • Duplicate addresses

  • Zero address sends

  • There is at least 1 recipient

  • All amounts are > 0

  • recipients.length == amounts.length

In the contract TSender.huff the interface airdropERC20 is declared in the same way as the function airdropERC20 which is an external function :

/* Interface */
#define function airdropERC20(address,address[],uint256[],uint256) nonpayable returns()
#define function areListsValid(address[],uint256[]) nonpayable returns (bool)

While it's counterpart defined in TSender.sol is a pure function.

The huff documentation says that you can declare an interface as pure or view depending on your need :

Functions can be of type view, pure, payable or nonpayable

Impact

The huff implementation is declared as external, which causes it to consume gas. The function's purpose is purely to check the validity of the input arrays without modifying the state. Even though the impact is low, the functionality of this function does not work as the documentation stipulates. So it does break the invariant of not paying any gas fees when calling this function. Which makes it a medium.

Tools Used

Manual review

Recommendations

Consider the following change :

- #define function areListsValid(address[],uint256[]) nonpayable returns (bool)
+ #define function areListsValid(address[],uint256[]) pure returns (bool)
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
maroutis Submitter
about 1 year ago
patrickalphac Auditor
about 1 year ago
maroutis Submitter
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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