DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

The `LikeRegistry` contract is vulnerable to inadvertent ownership transfer

[H-3] Summary

The LikeRegistry contract implements OpenZeppelin's Ownable contract and also holds ETH funds. The inadvertent ownership transfer could therefore result in the funds being locked in the contract.

Vulnerability Details

The Ownable contract exposes a transferOwnership function, which allows the current owner to transfer ownership to another address in a single function call. If the new owner is a contract, which doesn't implement the required logic, or is an invalid address, then the funds in the contract would be permanently locked.

Impact

High impact - the funds would be locked in the contract. Medium likelihood - the owner would have to make a mistake in the address they are transferring ownership to.

Tools Used

Manual review

Recommendations

Implement a 2-step ownership transfer mechanism, for example:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract OwnableTwoStep is Ownable {
address private _pendingOwner;
event OwnershipTransferInitiated(address indexed newOwner);
event OwnershipTransferConfirmed(address indexed newOwner);
modifier onlyPendingOwner() {
require(msg.sender == _pendingOwner, "Not the pending owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "New owner is the zero address");
_pendingOwner = newOwner;
emit OwnershipTransferInitiated(newOwner);
}
function confirmOwnership() public onlyPendingOwner {
emit OwnershipTransferConfirmed(_pendingOwner);
_transferOwnership(_pendingOwner);
_pendingOwner = address(0);
}
function cancelOwnershipTransfer() public onlyOwner {
_pendingOwner = address(0);
}
}
Updates

Appeal created

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Admin is trusted

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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