https://github.com/Cyfrin/2024-09-mystery-box/blob/main/src/MysteryBox.sol#L111
Anyone can call the MysteryBox::changeOwner function and change the contract’s owner. After that, the new owner (attacker) gains access to all onlyOwner functions and can steal funds by calling MysteryBox::withdrawFunds.
An attacker can exploit this by calling MysteryBox::changeOwner, setting themselves as the owner, and then calling MysteryBox::withdrawFunds to steal funds.
Add a check in the MysteryBox::changeOwner function to verify that the msg.sender is the current owner:
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.