Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Polaris_tow - Use safeTransfer/safeTransferFrom consistently instead of transfer/transferFrom #62

Closed
sherlock-admin opened this issue May 5, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented May 5, 2023

Polaris_tow

medium

Use safeTransfer/safeTransferFrom consistently instead of transfer/transferFrom

Summary

Use safeTransfer/safeTransferFrom consistently instead of transfer/transferFrom

Vulnerability Detail

Some tokens do not revert on failure, but instead return false (e.g. ZRX).
https://github.com/d-xo/weird-erc20/#no-revert-on-failure
tranfser/transferfrom is directly used to send tokens in many places in the contract and the return value is not checked.
If the token send fails, it will cause a lot of serious problems.
For example,

    function claimERC20Prize(
      address _to,
      IERC20Upgradeable _token,
      uint256 _amount,
      bytes32[] calldata _proof
  ) external whenNotPaused nonReentrant {
      if (_to != msg.sender) {
          revert InvalidAccount();
      }

      if (
          !MerkleProofUpgradeable.verify(
              _proof,
              erc20MerkleRoot,
              keccak256(abi.encodePacked(_token, _to, _amount))
          )
      ) {
          revert InvalidERC20MerkleProof();
      }

      uint256 value = _amount - totalERC20Claimed[_token][_to];

      if (value > 0) {
          totalERC20Claimed[_token][_to] += value;
          _token.transfer(_to, value);
      }

      emit ClaimERC20(_token, _to, value);
  }

Impact

If the token send fails, it will cause a lot of serious problems, the return value is not checked.

Code Snippet

https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumEscrow.sol#L105-L111
https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumPrizeDistributor.sol#L106-L134

Tool used

Manual Review

Recommendation

Consider using safeTransfer/safeTransferFrom consistently.

Duplicate of #86

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 10, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant