sherlock-audit / 2024-05-tokensoft-distributor-contracts-update-judging

3 stars 2 forks source link

bareli - zero amount transfer can fail. #47

Closed sherlock-admin3 closed 5 months ago

sherlock-admin3 commented 5 months ago

bareli

medium

zero amount transfer can fail.

Summary

Some ERC20 tokens revert on zero value transfers:

https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers

Vulnerability Detail

function sweepToken(IERC20 token) external onlyOwner { uint256 amount = token.balanceOf(address(this)); token.safeTransfer(recipient, amount); emit SweepToken(address(token), amount); }

function sweepToken(IERC20 token, uint256 amount) external onlyOwner {
    token.safeTransfer(recipient, amount);
    emit SweepToken(address(token), amount);
}

Impact

ERC20 token can revert.sweep will be revert.

Code Snippet

https://github.com/sherlock-audit/2024-05-tokensoft-distributor-contracts-update/blob/main/contracts/packages/hardhat/contracts/utilities/Sweepable.sol#L24

Tool used

Manual Review

Recommendation

check the amount is greater than 0.