When adding a new zkChain to the Bridge Hub, it is possible for the sender to force its inclusion even when the maximum allowed amount of chains has been reached, this by using a boolean flag to indicate it. However, even when the flag has been set to bypass the maximum value check, the process will revert if this value has been reached due to failure to check the flag a few steps later, turning the flag useless and making impossible to add more zkChains to the Bridge Hub.
When adding a new zkChain in the Bridge Hub, the _registerNewZKChain
internal function is called to update the zkChainMap
mapping. This function receives the chain information and the _checkMaxNumberOfZKChains
boolean to determine if the MAX_NUMBER_OF_ZK_CHAINS
value will be checked. This boolean is used to bypass the maximum allowed amount of registered chains if desired.
According to the NATSPEC:
Providing _checkMaxNumberOfZKChains = false
may be preferable in cases where we want to guarantee that a chain can be added. These include:
1. Migration of a chain from the mapping in the old CTM
2. Migration of a chain to a new settlement layer
Nevertheless, for the second case, if the MAX_NUMBER_OF_ZK_CHAINS
value has been reached the process will fail even if the _checkMaxNumberOfZKChains
value is set to false as it is not checked in the MessageRoot::_addNewChain
function.
During chain migration, the Bridgehub::bridgeMint
function is called. If the contract of the zkChain is not yet deployed, it will be created and registered in the system, with _checkMaxNumberOfZKChains
set as false. Then the MessageRoot::_addNewChain
function is called and the MAX_NUMBER_OF_ZK_CHAINS
value is checked again, without taking into account the _checkMaxNumberOfZKChains
value. Even if the variable is set to false, the process will revert when the maximum value has been reached.
Impact: High
It is not possible to add more chains even when it is intended to be allowed.
Likelihood: Low
Manual Review
It is recommended allow to bypass the maximum value checking in the MessageRoot::_addNewChain
function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.