Skip to content

transferFrom() can steal allowance of other accounts

Description

The transferFrom() function can be used to steal the allowance of other accounts due to incorrect approval logic. This can lead to unauthorized transfers of funds.

Examples

Insecure Code

solidity
function transferFrom(address sender, address recipient, uint256 amount) {
        _approve(sender, recipient, allowance(sender, recipient).sub(amount, "ERC20: transfer amount exceeds allowance"), 0);
    }

Secure Code

solidity
function transferFrom(address sender, address recipient, uint256 amount) {
        _approve(sender, recipient, allowance(sender, recipient).sub(amount, "ERC20: transfer amount exceeds allowance"), allowance(sender, recipient));
    }

Remediation

Update the approval logic to correctly handle the allowance of the sender and recipient.

Rule Details

FieldValue
IDCODE-0435
CategoryCrypto
SeverityCRITICAL
CWECWE-688
ConfidenceHIGH
ImpactHIGH
LikelihoodHIGH
ExploitabilityEASY
Tagssmart contract, ethereum
OWASPN/A

References