Skip to content

Incorrect Position of 'from' Parameter Check in '_allowances' Mapping

Description

The 'from' parameter is checked at an incorrect position in the '_allowances' mapping, potentially leading to unauthorized access or manipulation of allowances.

Examples

Insecure Code

solidity
function burnFrom(address from, ...) {
    _burn(from, ...);
    require(_allowances[msg.sender][from] >= amount, ...);
}

Secure Code

solidity
function burnFrom(address from, ...) {
    require(_allowances[msg.sender][from] >= amount, ...);
    _burn(from, ...);
}

Remediation

Move the check for the 'from' parameter to the correct position in the '_allowances' mapping to ensure proper authorization and access control.

Rule Details

FieldValue
IDCODE-0503
CategoryAccessControl
SeverityHIGH
CWECWE-688
ConfidenceMEDIUM
ImpactHIGH
LikelihoodHIGH
ExploitabilityMODERATE
Tagssmart contract, access control
OWASPN/A

References