Summary
In the MondrianWallet2
it not necessary inherit and use the Initializable
contract.
Vulnerability Details
MondrianWallet2
will be have a unecessary inheritance of Initializable
because the UUPSUpgradeable
inheritance already have Initializable
inheritance.
In the lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol
:
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
Impact
MondrianWallet2
will be have unecessary inheritance because.
Tools Used
Solidity and Foundry
Proof Of Concept
Add the following code in the test/ModrianWallet2Test.t.sol
:
function testZkDontNeedInitializableInheritance() public {
MondrianWallet2 newImplementation = new MondrianWallet2();
vm.prank(ANVIL_DEFAULT_ACCOUNT);
UUPSUpgradeable(address(mondrianWallet)).upgradeToAndCall(address(newImplementation), bytes(""));
}
Run: forge test --zksync --system-mode=true --match-test testZkDontNeedInitializableInheritance -vvv
Recommendations
In the MondrianWallet2
you should remove the import and inheritance of Initializable
:
// OZ Imports
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
- import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
/**
* @title MondrianWallet2
* @notice Its upgradable! So there shouldn't be any issues because we can just upgrade!... right?
*/
- contract MondrianWallet2 is IAccount, Initializable, OwnableUpgradeable, UUPSUpgradeable {
+ contract MondrianWallet2 is IAccount, OwnableUpgradeable, UUPSUpgradeable {