Description: The smart contract mysterybox contains a function named changeOwner that allows any user to modify the contract's ownership. This lack of proper access control allows unauthorized users to assume ownership of the contract, giving them full control over its operations. Once a malicious actor gains ownership, they can potentially execute privileged functions, including withdrawing all funds using withdrawFunds function or changing core logic, leading to significant financial and operational damage.
Impact:
Unauthorized Access: Any user can become the contract owner without restriction.
Fund Theft: The new unauthorized owner can withdraw all funds from the contract.
Contract Control: The malicious owner can execute privileged actions, modify the contract.
Proof of Concept:
paste this code snipped inside TestMysteryBox.t.sol and run this command in the terminal forge test --mt testOwnerChange -vvvv to see the full output of this test
Recommended Mitigation:
Implement strict access control on the changeOwner function by adding a require statement to ensure that only the current owner can call this function.
Consider using OpenZeppelin’s Ownable contract, which provides a secure ownership mechanism.
Tools Used: Manual
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.