Closed c4-bot-1 closed 7 months ago
saxenism (sponsor) disputed
This is considered invalid
because if one can change verifier params they can do anything with the system so zero value isn’t a concern (and practically it should be never zero)
The Warden specifies that the verifier parameter adjustment permits zero values for some of the elements of the _newVerifierParams
structure which is conditional on an administrator's mistake and thus a finding better suited as part of a QA / Analysis report.
alex-ppg marked the issue as unsatisfactory: Out of scope
Lines of code
https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/contracts/ethereum/contracts/upgrades/BaseZkSyncUpgrade.sol#L147-L157
Vulnerability details
Impact
To properly upgrade
VerifierParams
, none of the parameters:recursionNodeLevelVkHash
,recursionLeafLevelVkHash
,recursionCircuitsSetVksHash
can be empty (bytes32(0)
). However, the current implementation of_setVerifierParams()
does not enforce this requirement. If at least one of these parameters is non-zero -_setVerifierParams()
will upgradeVerifierParams
.This basically means, that it's possible to upgrade
VerifierParams
even when some of the parameters arebytes32(0)
. This should not be possible. TheVerifierParams
should be upgraded only when all provided parameters are non-empty.This behavior is even confirmed in the previous version of the zkSync code:
File: previous contest
During the previous contest, function
_setVerifierParams()
was using||
operator, while the current implementation of_setVerifierParams()
is using&&
operator.Proof of Concept
File: BaseZkSyncUpgrade.sol
As demonstrated above, function uses AND operator (
&&
) instead of OR (||
). This basically means, that if at least one parameter is notbytes32(0)
- then above condition won't be fulfilled and function will continue its execution and setVerifierParams
.E.g., let's consider a scenario, where:
Even though above params are not correct (
recursionNodeLevelVkHash
andrecursionLeafLevelVkHash
arebytes32(0)
), function won'treturn
at lines 147-153, becauserecursionCircuitsSetVksHash
is notbytes32(0)
and it will updateVerifierParams
.This leads to the conclusion, that
_setVerifierParams()
will upgrade VerifierParams, even when some of them are empty.Tools Used
Manual code review
Recommended Mitigation Steps
Use OR instead of AND. It should not be possible to upgrade
VerifierParams
when any of the parameter isbytes32(0)
:The code should be changed to:
Assessed type
Invalid Validation