TSender

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

Insufficient Check for recipients in `areListsValid` can cause funds locked if recipient is `address(this)`

Summary

recipients check is not checking if one of the recipients is address(this) leading to loss of funds (getting locked) in case of setting it by mistake.

Vulnerability Details

Tsender.sol/huff::areListsValid() function checks that the recipients and amounts are not zero value. and there is no duplicate recipient. But this check is not sufficient for recipients, as in case the recipient is set to address(this) by mistake this will lead to the loss of funds when airDropping tokens.

TSender.sol#L129-L131

function areListsValid(address[] calldata recipients, uint256[] calldata amounts) external pure returns (bool) {
...
for (uint256 i; i < recipients.length; i++) {
@> if (recipients[i] == address(0)) {
return false;
}
...
}

As stated by the Sponser, areListsValid will be fired to check that the list of addresses and recipients are valid to prevent any issue happens. and this check (recipients[i] == address(this) is not implemented. which will make the function return true if one of the recipients is address(this).

The problem is that these funds are unrecoverable, as there is a check after distributing that forces the amount sent by the caller to the AirDrop contract be the same as the amount distributed. so the funds will be locked inside the contract and unrecoverable.

TSender.sol#L101-L104

if iszero(eq(addedAmount, totalAmount)) {
mstore(0x00, 0x63b62563) // cast sig TSender__TotalDoesntAddUp()
revert(0x1c, 0x04)
}

This is different from normal Admin Mistake errors. as the idea of areListsValid() function is to let the caller that everything is correct before distributing tokens. and since it will return true in that case, he will fire the function without problems, which will lead to this issue.

Impact

Loss of funds and getting Locked in the AirDrop contract forever

Tools Used

Manual Review

Recommendations

Check that the recipient is not set to address(this)

Tsender::areListsValid()

function areListsValid(address[] calldata recipients, uint256[] calldata amounts) external pure returns (bool) {
...
for (uint256 i; i < recipients.length; i++) {
- if (recipients[i] == address(0)) {
+ if (recipients[i] == address(0) || recipients[i] == address(this)) {
return false;
}
...
}

This check should also be added in the huff version.

Updates

Lead Judging Commences

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

Support

FAQs

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