Address.isContract() is not a reliable way of checking if the input is an EOA
The contract uses Address.isContract() to ensure an address is an externally owned account (EOA), but this check can be bypassed if the address is a smart contract still under construction or not yet deployed. An attacker could therefore register a smart contract as the EOA representative, contrary to the intended design.
Submitted by yixxas, also found by CloudX and ladboy233
The underlying assumption of eoaRepresentative being an EOA can be untrue. This can cause many unintended effects as the contract comments strongly suggests that this must be an EOA account.
Proof of Concept
When BLS public key is registered in registerBLSPublicKeys(), it has the check of
require(!Address.isContract(_eoaRepresentative), "Only EOA representative permitted")
However, this check can be passed even though input is a smart contract if
- Function is called in the constructor.
Address.isContract()checks for the code length, but during construction code length is 0. - Smart contract that has not been deployed yet can be used. The CREATE2 opcode can be used to deterministically calculate the address of a smart contract before it is created. This means that the user can bypass this check by calling this function before deploying the contract.
Recommended Mitigation Steps
It is generally not recommended to enforce an address to be only EOA and AFAIK, this is impossible to enforce due to the aforementioned cases. I recommend the protocol team to take a closer look at this and build the protocol with the assumption that _eoaRepresentative == EOA.
vince0656 (Stakehouse) disputed and commented:
Using tx.origin is generally frowned upon.
The sponsor confirming that they know it’s an issue does not invalidate it as an issue.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the check relies on code length, which is zero during contract construction and before deployment, so it cannot reliably distinguish EOAs from contracts.
Impact
A smart contract could be registered as the EOA representative, potentially causing unintended effects as the protocol assumes it is an EOA.
What the attacker needed
Ability to call registerBLSPublicKeys(); Contract under construction or not yet deployed
The fix
The protocol should be designed with the assumption that _eoaRepresentative may not be an EOA, as enforcing EOA-only is impossible.
How it was found
- Call registerBLSPublicKeys() from within a contract's constructor, where code length is zero.
- Alternatively, use CREATE2 to compute a contract address before deployment and call the function with that address.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract is a program on the blockchain. An EOA (externally owned account) is a normal user account controlled by a private key. The code tries to make sure only EOAs can be used, but the check fails for contracts that are being created or not yet deployed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.