Closed code423n4 closed 1 year ago
Looks off without showing a POC of the variables not being set properly.
Immutable variables will be set at deploy time and will alter the bytecode of the contract deployed
This is incorrect, the way it's going to work is as follows:
In lack of this being acknowledged, and then disputed, I will close as invalid (Incorrect)
GalloDaSballo marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/bridge/L1ERC20Bridge.sol#L57-L60 https://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/bridge/L1EthBridge.sol#L48-L51
Vulnerability details
Vulnerability Details
The
L1ERC20Bridge
andL1EthBridge
are implementation contracts that would be delegatecalled by their corresponding proxy contracts. In other words, all state variables and assets would be stored in the proxy contracts. In contrast, the implementation contracts would keep the logic for processing the state variables stored in the proxy contracts.We found that the
L1ERC20Bridge
andL1EthBridge
contracts initialize their state variables, includingzkSyncMailbox
andallowList
, in theconstructor
(L57 - 60 in code snippet 1 and L48 - 51 in code snippet 2).Specifically, initializing state variables in the implementation contracts'
constructor
would not be effective on the proxy contracts. Consequently, the resulting uninitialized state variables (i.e.,zkSyncMailbox
andallowList
) can render the proxy contracts unusable.Impact
We found that the
L1ERC20Bridge
andL1EthBridge
contracts initialize their state variables, includingzkSyncMailbox
andallowList
, in theconstructor
(L57 - 60 in code snippet 1 and L48 - 51 in code snippet 2).Specifically, initializing state variables in the implementation contracts'
constructor
would not be effective on the proxy contracts. Consequently, the resulting uninitialized state variables (i.e.,zkSyncMailbox
andallowList
) can render the proxy contracts unusable.For this reason, we considered this issue high severity.
Proof of Concept
https://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/bridge/L1ERC20Bridge.sol#L57-L60
https://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/bridge/L1EthBridge.sol#L48-L51
Tools Used
VSCode (Manual Review)
Recommended Mitigation Steps
We recommend initializing the state variables
zkSyncMailbox
andallowList
in theinitialize
function, like L75 - 76 in code snippet 3 and L58 - 59 in code snippet 4.The
initialize
function would be delegatecalled by the proxy contracts during the system initialization process. Therefore, the state variableszkSyncMailbox
andallowList
would be initialized and effective on the proxy contracts.