Submitted by erebus, also found by bin2chen and anon
In bootloader, function processL1Tx, it is possible for a malicious operator to steal all the gas provided by ANY user who requests an L1L2 transaction simply by returning an overinflated refundGas for the transaction execution.
The refundGas the user will receive is the sum of:
Note: please see scenario in wardens original submission.
With reservedGas being the excess of gas between what the user provided and what the operator is willing to use, and refundGas (not the final one) is the remaining gas left after preparing and executing the requested transaction.
As both quantities are added via the opcode add:
bootloader, line 921
The operator can return an over-inflated value so that it gets picked by the max() function and is added to reservedGas; overflowing the result as there are no checks for overflows in assembly:
bootloader, lines 921-927
As anyone will be able to be an operator once zkSync Era becomes decentralized, this issue becomes critical as it would be possible for ANY operator to farm the gas provided by ANY user.
Just use safeAdd:
bootloader, line 921
miladpiri (zkSync) confirmed via duplicate issue #187
Alex the Entreprenerd (judge) commented:
