Update September 14th: We have published a security advisory and released Contracts v4.3.2 with a hotfix for this vulnerability. Still, it is now recommended you always initialize your implementation contracts as explained below.
Update September 16th: We have now published a post-mortem with a lot of detail at UUPSUpgradeable Vulnerability Post-mortem.
Due to a vulnerability in OpenZeppelin Contracts v4.1.0 through v4.3.1, all projects using the UUPS proxy pattern should initialize
their implementation contracts.
To help mitigate this situation, we have already executed transactions to initialize over 150 implementation contracts from multiple projects we identified across Mainnet, Polygon, xDAI, Binance, and Avalanche. These transactions were sent from address 0x37E8d216c3f6c79eC695FBD0cB9842e62fB84370
via a batching contract at 0x310fAC62C976d8F6FDFA34332a56EA1a05493b5b
on all networks.
As an example on how to execute the mitigation, given the following upgradeable ERC20 contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract MyToken is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable {
function initialize() initializer public {
__ERC20_init("MyToken", "MTK");
__Ownable_init();
__UUPSUpgradeable_init();
}
function _authorizeUpgrade(address newImplementation)
internal
onlyOwner
override
{}
}
A transaction must be sent to the implementation contract (not the proxy) to invoke the initialize
method. You can find out the address of the implementation contract given a proxy in Etherscan (if your contract source code is verified) on the “Read as Proxy” tab of the “Contract” section.
We will be releasing more information about the vulnerability along with a fix for the Contracts package next week, in order to give time to all projects to execute this mitigation.