Open code423n4 opened 1 year ago
All the immutables of the contracts are reset during after the call to the consutrctor (it is expected that the compiler will set the needed immutables). I don’t think it is a security issue. The immutables should be rewriten.
Severity is QA.
miladpiri marked the issue as disagree with severity
I have requested more info to the Warden, I would downgrade to QA in lack of additional proof.
GalloDaSballo changed the severity to QA (Quality Assurance)
L
GalloDaSballo marked the issue as grade-a
Lines of code
https://github.com/code-423n4/2023-03-zksync/blob/21d9a364a4a75adfa6f1e038232d8c0f39858a64/contracts/ContractDeployer.sol#L212-L227
Vulnerability details
Impact
when contracts get deployed, code set their immutable values in the ImmutableSimulator contract and the default value for any immutable index is 0. function
forceDeployOnAddress()
is to be used only during an upgrade to set bytecodes on specific addresses but the code doesn't reset the immutable values for the upgrading contract. This will create state for the contract after deployment which can result in unexpected behavior.Proof of Concept
This is
forceDeployOnAddress()
code:As you can see it calls
_constructContract()
which is:which sets the deployed contract's immutables based on the return value of the constructor. Function
forceDeployOnAddress()
can be used to redeploy a new code to an address, and that address may have immutables set for it in previous deploys. As you can see in both_constructContract()
andforceDeployOnAddress()
there is no logic to reset the previously set immutables, This can cause problems in this two scenario:forceDeployOnAddress()
get called withcallConstructor
as false, then the constructor of the new code won't get called and no new immutables would have been set for that address, but the immutables would have values from previous deploys. because the new code would be different than the previous code, so there is no guarantee that the value of the immutables are the same for them.Tools Used
VIM
Recommended Mitigation Steps
code should have some value so deployer define that if he wants the immutables to be reset before deployment or not.