Burning of the user gas in the sendCompressedBytecode function
The bootloader's sendCompressedBytecode function uses nearCallPanic when the Compressor::publishCompressedBytecode call fails, which can be triggered by invalid data from the operator. This allows the operator to burn all gas of an L2 transaction if at least one bytecode is to be published.
Submitted by Audittens
Lines of code
https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/system-contracts/bootloader/bootloader.yul#L1244-L1245 https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/system-contracts/bootloader/bootloader.yul#L1255-L1259 https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/system-contracts/bootloader/bootloader.yul#L1365
Description
In the bootloader::sendCompressedBytecode function the nearCallPanic() is used for the case of unsuccessfull call of the Compressor::publishCompressedBytecode function. In practice, such situation could happen because of invalid data provided by the operator, as any of the internal checks of this function could be ignored by the operator to make the call to revert: decoding of the _rawCompressedData (link), the checks on dictionary length (link1, link2), the check on the encodedData length (link), etc.
Such possibility of forcing the overall bootloader::ZKSYNC_NEAR_CALL_markFactoryDepsL2 to near call revert, makes the operator able to burn all the gas of the L2 transaction if there is at least one bytecode to be published at the start of transaction processing.
Impact
The ability of the operator to burn all the gas of the L2 transaction in the call of the bootloader::ZKSYNC_NEAR_CALL_markFactoryDepsL2 function, if at least one bytecode is to be published.
Recommended Mitigation Steps
Use revertWithReason instead of nearCallPanic for the cases of unsuccessful calls of the Compressor::publishCompressedBytecode function. The cases of out of gas error on such calls operator can process as standard bytecode publications through the bootloader::markFactoryDepsForTx functionality.
miladpiri (zkSync) confirmed and commented:
This has medium severity because it gives the operator the ability to forcefully fail the transaction.
Alex the Entreprenerd (judge) commented:
The finding is similar to #71; however, in this case it shows how the Operator can break trust expectations by purposefully making tx fails via OOG.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the use of nearCallPanic instead of revertWithReason for unsuccessful calls to Compressor::publishCompressedBytecode causes all gas to be consumed on failure.
Impact
The operator could burn all the gas of an L2 transaction if at least one bytecode is to be published, breaking trust expectations.
What the attacker needed
Operator is malicious or faulty; at least one bytecode to publish
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a blockchain, the operator is the party that processes transactions. This report shows that the operator could deliberately cause a transaction to fail in a way that consumes all its gas (the fee paid for computation), even though the user did nothing wrong. The problem is that a failure in a helper function is handled by a panic that uses up all remaining gas instead of a normal revert.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.