20,000 USDC
View results
Submission Details
Severity: medium

Return values of `transfer()/transferFrom()` not checked

Summary

Vulnerability Details

Not all IERC20 implementations revert() when there's a failure in transfer()/transferFrom(). The function signature has a boolean return value and they indicate errors that way instead. By not checking the return value, operations that should have marked as failed, may potentially go through without actually making a payment.

There are 20 instances of this issue:

Exploit scenario

contract Token {
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
}
contract MyBank{
mapping(address => uint) balances;
Token token;
function deposit(uint amount) public{
token.transferFrom(msg.sender, address(this), amount);
balances[msg.sender] += amount;
}
}

Several tokens do not revert in case of failure and return false. If one of these tokens is used in MyBank, deposit will not revert if the transfer fails, and an attacker can call deposit for free..

Impact

Tools Used

Recommendations

Use SafeERC20, or ensure that the transfer/transferFrom return value is checked.

Support

FAQs

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