The changeOwner and withdrawFunds functions of the MysteryBox contract, which allows any address to assume ownership of the contract and withdraw all funds. The lack of access control in the changeOwner function permits any user to change the contract’s owner without restrictions, leading to a complete loss of control over the contract's balance and settings.
changeOwner Function: This function allows any user to change the contract owner by simply calling the function with an address.
withdrawFunds Function: Once the ownership is taken over by any malicious actor via the changeOwner function, they can call the withdrawFunds function to transfer the entire contract balance to themselves.
The vulnerability was confirmed using the following test case:
Logs:
Complete Ownership Loss: Any user can become the owner of the contract, seizing full control over it.
Full Fund Withdrawal: Once ownership is hijacked, the malicious actor can withdraw the entire balance of the contract.
Manipulation of Prices and Rewards: The attacker can manipulate box prices and rewards since they become the contract owner.
Manual Review
Testing Framework: Foundry
Add Access Control in changeOwner Function
OR Use role-based security mechanisms like OpenZeppelin's Ownable or AccessControl to manage ownership and access rights more effectively.
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.