The Address::isContract function is designed to check if a given address belongs to a smart contract. However, this function can be bypassed when called within the constructor of a contract, as the code size of a contract is zero during its construction phase. This loophole can potentially be exploited to deceive the isContract check.
The isContract function in the Address library relies on the extcodesize assembly instruction to determine if an address has associated contract code. The function returns true if the code size at the given address is greater than zero.
Here is the relevant code from the Address library:
The vulnerability arises because, during the execution of a contract's constructor, the extcodesize of the contract's address is zero. Consequently, calling isContract within the constructor will incorrectly return false, even though the address belongs to a contract.
In this case, the require statement will pass during construction, even though address(this) is indeed a contract.
This vulnerability can lead to several potential issues:
Manual code review
Solidity documentation and assembly analysis
Static analysis tools for additional insights
While there is no perfect solution to completely eliminate this issue due to the nature of contract construction in Ethereum, the following mitigations can reduce the risk:
The following issues and its duplicates are invalid as admin errors/input validation/malicious intents are1 generally considered invalid based on [codehawks guidelines](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#findings-that-may-be-invalid). If they deploy/set inputs of the contracts appropriately, there will be no issue. Additionally admins are trusted as noted in READ.ME they can break certain assumption of the code based on their actions, and
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.