Closed c4-bot-9 closed 7 months ago
Invalid issue since gasPrice is 0, so operator will receive 0. Since value is also zero the refund will be 0 too.
saxenism (sponsor) disputed
The Warden describes that a chain ID upgrade transaction may lose gas to the zero address, however, as the Sponsor denotes no gas expenditure will occur resulting in no gas refunds being processed. Even in a scenario whereby gas refunds would be processed, the maximum impact of this exhibit would be QA due to the minuscule amount of gas refunded to an incorrect address.
alex-ppg marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/contracts/ethereum/contracts/state-transition/StateTransitionManager.sol#L194
Vulnerability details
Impact
Setting the
refundRecipient
of a L1 -> L2 transaction to0
will send the leftover gas of such a transaction to theaddress(0)
. As the hyperchain ecosystem evolves, more and more hyperchains will be created, so the amount lost over time can be considerable.Proof of Concept
When the
bridgeHub
creates a new hyperchain, it will eventually callStateTransitionManager, function createNewChain
If we follow the execution path, we see that it builds from scratch the L2 transaction to be submitted in
and it sets all the values inside the
reserved
array field to0
. This is a bad decission as it is very difficult to estimate the exact amount of gas that a tx will need, so there will be some dust that must be returned to the caller. From the previous contest, thereserved[1]
field denotes therefundAddress
, so if it is0
, the bootloader will naively send the refund gas to theaddress(0)
, which means those funds will be permanently lost. The code snippet responsible of that is inbootloader, lines 1029 to 1035
Recommended Mitigation Steps
Pass as a function argument to the
createNewChain
function therefundAddress
for the L1 -> L2 transaction, so that the leftover gas is not lost forever:Assessed type
Other