Omniscia rain protocol Audit

Factory Manual Review Findings

Factory Manual Review Findings

FAC-01M: Inexistent Validation of Existing Child

TypeSeverityLocation
Logical FaultFactory.sol:L50, L52

Description:

The createChild function does not validate whether a child has already been deployed at a particular address, a trait that can be achieved in case deterministic deployment addresses are utilized such as create2 instructions.

Example:

contracts/factory/Factory.sol
34/// Implements `IFactory`.
35///
36/// Calls the `_createChild` hook that inheriting contracts must override.
37/// Registers child contract address such that `isChild` is `true`.
38/// Emits `NewChild` event.
39///
40/// @param data_ Encoded data to pass down to child contract constructor.
41/// @return New child contract address.
42function createChild(bytes calldata data_)
43 external
44 virtual
45 override
46 nonReentrant
47 returns (address)
48{
49 // Create child contract using hook.
50 address child_ = _createChild(data_);
51 // Register child contract address to `contracts` mapping.
52 contracts[child_] = true;
53 // Emit `NewChild` event with child contract address.
54 emit IFactory.NewChild(msg.sender, child_);
55 return child_;
56}

Recommendation:

We advise a require check to be imposed ensuring that the contracts[child_] entry is false catching any malfunction in the _createChild function.

Alleviation:

A require check was introduced ensuring that the child_ has not been previously created to avoid potential malfunctions in the _createChild function.