Closed c4-bot-2 closed 7 months ago
saxenism (sponsor) disputed
Not an issue. The only reason why mintEther can fail, while keeping enough gas to execute nearCallPanic() itself is if 63/64 of the gas of the parent frame was passed and it wasnt enough. We must use nearCallPanic to protect ourselves from malicious users supplying too few gas.
The Warden denotes that gas will be forcibly burnt if an ether mint fails at the L2 level which may be considered unfair. Per the Sponsor's assessment and the code's implementation, the scenario under which an ether mint will fail can only be considered as "malicious" in the sense that the caller did not supply sufficient gas.
In such a case, burning any remaining gas is an acceptable error handling mechanism as the gas itself should be minuscule and the ether mint's failure indicates abnormal circumstances (i.e. significantly small gas allocated).
alex-ppg marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/system-contracts/bootloader/bootloader.yul#L1792-L1847 https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/system-contracts/bootloader/bootloader.yul#L797-L822
Vulnerability details
Proof of Concept
Take a look at https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/system-contracts/bootloader/bootloader.yul#L797-L822
This function is used to mint ether to the recipient, as seen this function directly uses the
useNearCallPanic
to know if to revert with reason or panic call and burn all the gas attached to the parent frameNow consider https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/system-contracts/bootloader/bootloader.yul#L1792-L1847
This function is responsible for the execution of the L1->L2 transaction, case with this is that it hardcodes the
useNearCallPanic
totrue
while queryingmintEther()
, which then causes all the gas sent by the user for this transaction to be burnt, since it callsnearCallPanic()
whose implementation can be seen here https://github.com/code-423n4/2024-03-zksync/blob/4f0ba34f34a864c354c7e8c47643ed8f4a250e13/code/system-contracts/bootloader/bootloader.yul#L1857-L1862However using this search command [https://github.com/search?q=repo%3Acode-423n4%2F2024-03-zksync%20mintEther(&type=code](https://github.com/search?q=repo%3Acode-423n4%2F2024-03-zksync%20mintEther(&type=code) we can see that all other two instances of querying
mintEther()
in the bootloader passes theuseNearCallPanic
bool asfalse
saving the user their gasImpact
Medium since this is loss of monetary value (albeit in gas), but currently, all of the gas attached to the transaction while calling
ZKSYNC_NEAR_CALL_executeL1Tx()
could get unfairly burnt if there is a need of minting ether.Recommended Mitigation Steps
Since the other 2 instances have their
useNearCallPanic
as false leading them to revert with reason, the same fate should meet the instance attached in report in order to not save the whole gas attached to the transactionAssessed type
Context