Skip to content

No Validation Of create2 Return Value #18

@spyboy7711

Description

@spyboy7711

Impact

The BoringFactory.deploy() function is used to deploy lightweight proxy contracts . The function does not revert properly if there is a failed contract deployment or revert from the create2 opcode as it does not properly check the returned address for bytecode. The create2 opcode returns the expected address which will never be the zero address.

Proof of Concept

https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringFactory.sol#L32-L68

Recommended Mitigation Steps

The recommended mitigation is to check returned address by create2 that is cloneAddress variable for non zero adddress and non zero code size .

            // pass along failure message from failed contract deployment and revert.
           iszero(extcodesize(cloneAddress )) {
                returndatacopy(0, 0, returndatasize())
                revert(0, returndatasize())
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions