The setAdmin()
function in the RockPaperScissors
contract implements a single-step process for transferring admin privileges.
This design is error-prone since the admin role is immediately transferred to the specified address without confirmation from the new admin. If the function is called with an incorrect address (e.g., typo, miscopied address, or compromised wallet), administrative control of the contract could be permanently lost.
Current admin calls setAdmin()
with an incorrect address (e.g., a mistyped address or an address for which no one has the private key)
The function immediately transfers admin control to the new address: adminAddress = _newAdmin;
Since there's no way to verify the new admin can actually control the address before the transfer, administrative access to the contract is permanently lost
No rollback mechanism exists to revert the change
The loss of admin privileges would severely impact protocol management:
No ability to withdraw accumulated protocol fees (withdrawFees function)
No ability to update the join timeout setting (setJoinTimeout function)
No ability to transfer admin role to another address
Protocol fees would be permanently locked in the contract
Implement a two-step ownership transfer process:
Add a pendingAdmin
state variable to the contract:
Modify the admin transfer process to use two functions:
Code suggestions or observations that do not pose a direct security risk.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.