Skip to content

Delegatecall to Arbitrary Address

Description

An attacker may perform delegatecall() to an arbitrary address, potentially leading to unauthorized access or execution of malicious code.

Examples

Insecure Code

solidity
contract VulnerableContract { function delegate(address contractAddress) public { contractAddress.delegatecall(); } }

Secure Code

solidity
contract SecureContract { function delegate(address contractAddress) public { require(contractAddress == authorizedAddress, 'Unauthorized address'); contractAddress.delegatecall(); } }

Remediation

Validate and sanitize the input address before performing the delegatecall(). Ensure that the address is authorized and trusted.

Rule Details

FieldValue
IDCODE-0652
CategorySmart Contract
SeverityHIGH
CWECWE-20
ConfidenceLOW
ImpactHIGH
LikelihoodHIGH
ExploitabilityMODERATE
Tagsdelegatecall, arbitrary address, input validation
OWASPN/A

References