Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low
Valid

Unsafe ownership transfer of the ProxyFactory contract

Summary

The ProxyFactory contract uses a single-step ownership transfer mechanism that is risky. Due to possible human error, the owner-privileged functions using the onlyOwner modifier can be locked permanently.

Vulnerability Details

The ProxyFactory contract inherits from OpenZeppelin's Ownable contract. The Ownable implements the transferOwnership() that can transfer the ownership of the ProxyFactory contract from a current owner to another.

The transferOwnership() provides a single-step ownership transfer mechanism that is risky. If a (current) owner mistakenly inputs the newOwner param (e.g., an address that is not owned by the new owner is inputted), the new owner will lose ownership of the contract immediately, and this action is unrecoverable.

// FILE: lib/openzeppelin-contracts/contracts/access/Ownable.sol
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}

Impact

The following owner-privileged functions using the onlyOwner modifier will be locked permanently.

To clarify the vulnerability, although only an owner can execute the transferOwnership() and the owner is trusted, the incident can occur by mistake (i.e., this vulnerability is not about any centralization or trust risks; it is about the risks of input mistakes only).

The likelihood is considered LOW (since the owner is expected to do due diligence). The impact is considered HIGH. Therefore, the severity is considered MEDIUM.

Tools Used

Manual Review

Recommendations

Use the OpenZeppelin's Ownable2Step contract instead. The Ownable2Step contract provides a two-step ownership transfer mechanism guaranteeing that the ownership of the ProxyFactory contract will be transferred to a new owner, who can access their account for real.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.