I found the following code for solidity smart contracts ownership purposes.
contract owned {
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
I would like to know if it is possible to reject ownership of a contract which is transferred by owner of that contract to your contract address(or your EOA)
The reason I'm asking this question is to prevent the following scenario
- Bob is owner of contract C1 and Alice is owner of contract C2
- Contract C1 can automatically withdraw ether(generally any token)from it's owner address and send it to Bob's EOA. In other words it is malicious contract at all which can do bad things
- Bob calls the function transferOwnership of contract C1 and transfer the Ownership to either contract C2 address or Alice's EOA .
- Contract C2 or Alice becomes the owner of contract C1
- Contract C1 start to withdraw the balance of it's newowner = Contract C2 or Alice, and send it to Bob's EOA