MondrianWallet2::_authorizeUpgrade make it possible for anyone to call MondrianWallet2::upgradeToAndCall and permanently change its functionality.Description: MondrianWallet2 inherits UUPSUpgradeable from openZeppelin. This contract comes with a function upgradeToAndCall that upgrades a contract. It also comes with a requirement to include a _authorizeUpgrade function that manages access control. As noted in the UUPSUpgradable contract:
The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
However, the implementation of _authorizeUpgrade lacks any such access restrictions:
Impact: Because anyone can call MondrianWallet2::upgradeToAndCall, anyone can upgrade the contract to anything they want. First, this goes against the stated intention of the contract. From README.md:
only the owner of the wallet can introduce functionality later
Second, it allows for a malicious user to disable the contract.
Third, the the upgradeability can also be disabled (by having _authorizeUpgrade always revert), making it impossible to revert changes.
Proof of Concept:
A malicious user deploys an alternative MondrianWallet2 implementation.
The malicious user calls upgradeToAndCall and sets the new address to their implementation.
The call does not revert.
From now on MondrianWallet2 follows the functionality as set by the alternative MondrianWallet2 implementation.
In the example below, all functions end up reverting - including the upgradeToAndCall. But any kind of change can be implemented, by any user, at any time.
Place the following code underneath the existing tests in ModrianWallet2Test.t.sol.
Then place the following among the existing tests:
Recommended Mitigation: Add access restriction to MondrianWallet2::_authorizeUpgrade, for example the onlyOwner modifier that is part of the imported OwnableUpgradable.sol contract:
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.