The changeOwner function in the MysteryBox contract lacks proper access control, enabling any user to transfer ownership of the contract to an arbitrary address. This vulnerability allows malicious actors to assume control over owner-restricted functionalities, posing a significant security risk.
The changeOwner function in src/MysteryBox.sol does not enforce any restrictions on who can call it. As a result, any user can invoke this function to change the contract's owner to their own address or another address of their choosing. This flaw effectively bypasses the intended access controls, granting unauthorized users the ability to perform privileged actions within the contract.
The following test case demonstrates how an unauthorized user can exploit the changeOwner function to transfer ownership of the contract.
High Impact
An attacker can withdraw all funds from the contract by leveraging ownership privileges.
Users may lose confidence in the protocol's security, leading to reputational damage.
Malicious changes to ownership can disrupt the intended functionality and administration of the contract.
Manual Code Review
Remix IDE
Implement Access Control:
Restrict the changeOwner function to be callable only by the current owner. This can be achieved by adding a require statement to verify the caller's identity.
Implement Proper Access Control Modifiers
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.