The MysteryBox contract contains a critical access control vulnerability allowing unauthorized users to change the contract's ownership and withdraw all its funds. This vulnerability poses a significant threat to the integrity and security of the contract.
The changeOwner changeOwner MysteryBox contract does not have any access control mechanism, enabling any address to change the owner of the contract. Without the onlyOwner modifier, unauthorized users can gain control over the contract and perform sensitive functions such as withdrawing funds.
Copy this code in a test folder: MysteryBox/test/ChangeOwnerTest.t.sol
Output:
Unauthorized Ownership Changes: Any user can become the owner of the contract without permission.
Full Fund Withdrawal: The malicious owner can withdraw all funds from the contract.
Potential Further Exploitation: Any other owner-restricted functionalities are open to misuse.
Foundry
Implement access control using the onlyOwner onlyOwner Ownable contract to restrict sensitive functions.
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.