In Solidity, low-level calls (address.call
) do not check for the existence of contract code at the target address, unlike high-level calls that verify contract existence using the extcodesize
opcode. This behavior allows calls to non-existent contracts to appear successful, returning true
even when no code exists at the target address.
As highlighted in the Solidity docs:
Due to the fact that the EVM considers a call to a non-existing contract to always succeed, Solidity uses the
extcodesize
opcode to check that the contract that is about to be called actually exists (it contains code) and causes an exception if it does not. This check is skipped if the return data will be decoded after the call and thus the ABI decoder will catch the case of a non-existing contract.
Note that this check is not performed in case of low-level calls which operate on addresses rather than contract instances.
For that matter, when the callExternalContract()
in both MembershipFactory.sol and MembershipERC1155.sol function attempts to call a contract at contractAddress
using contractAddress.call(data)
, the EVM does not verify whether the address contains contract code. As a result, a call to a non-existent contract will return success = true
despite no actual contract execution occurring.
In the above as it exists in MembershipFactory.sol:
The low-level call does not verify if contractAddress
points to a valid contract.
If contractAddress
lacks code, i.e is a non-existent contract, then this call will still return success = true
, causing the assumption that the call was successful.
This particularly impacts scenarios where critical logic relies on the call's success flag to determine further actions.
Leads to the assumption that the low level call was successful.
Manual Code Review
Verify that the contract being called exists, either immediately before being called with an extcodesize
check, or by verifying during contract deployment and using a constant
/immutable
value if the contract can be fully trusted.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.