Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: low
Invalid

No check for non-contract addresses in `MembershipERC1155::callExternalContract`

Description: The external call in MembershipERC1155::callExternalContract did not check if the address passed in is a contract address or not.

Impact: Funds could mistakenly be sent to an externally owned address.

Recommended Mitigation: Add the following function to the MembershipERC1155 and MembershipFactory contract:

function isContract(address addr) internal view returns (bool) {
uint256 codeSize;
assembly {
codeSize := extcodesize(addr)
}
return codeSize > 0;
}

Now update the function as follows:

function callExternalContract(address contractAddress, bytes memory data) external payable onlyRole(OWP_FACTORY_ROLE) returns (bytes memory ) {
+ require(isContract(contractAddress), "Address is not a contract");
(bool success, bytes memory returndata) = contractAddress.call{value: msg.value}(data);
require(success, "External call failed");
return returndata;
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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