Lack of access to ETH on L2 through L1->L2 transactions
ETH held on L2 by externally owned accounts cannot be used as msg.value in L1-to-L2 transactions, because such transactions only mint ETH from L1. A malicious operator that ignores L2 transactions could therefore trap users' L2 ETH, violating the guarantee that users can withdraw funds via L1 before a malicious upgrade.
Submitted by Audittens
Lines of code
https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L318 https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/contracts/ethereum/contracts/zksync/facets/Mailbox.sol#L305-L306 https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/system-contracts/bootloader/bootloader.yul#L2321 https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/system-contracts/bootloader/bootloader.yul#L2328-L2333
Description
ETH on L2 stored on EOAs is inaccessible through L1->L2 transactions, as for such transactions msg.value is generated only “from L1 ETH”, not from the active balance of the tx.origin on L2. This is because of the logic in the Malibox::_requestL2Transaction function, which enforces msg.value of the L1->L2 transaction to be only part of ETH to be minted inside of transaction processing on L2. Bootloader maintains this system invariant as well.
DefaultAccount incorrectly assumes that L1->L2 transactions initiated by EOA cover the needed functionality of the executeTransactionFromOutside function, so it is empty.
Users will be unable to access their ETH on L2 in the case of a malicious operator that ignores L2 transactions (so if it processes only L1->L2 transactions). Also, and importantly, this violates the security invariant that enforces the ability of the users to access L2 through L1->L2 transactions, and, therefore, withdraw funds from the rollup before the upgrade in case of a scheduled malicious upgrade.
Impact
No access to ETH on L2 that is controlled by EOAs in case of malicious operator.
Violation of the “guarantee of withdraw of funds before malicious upgrade execution” security invariant.
Recommended Mitigation Steps
Add a possibility to create L1->L2 transactions that can use ETH from the L2 balance as part of the msg.value. As an alternative, you can implement the DefaultAccount::executeTransactionFromOutside function so it will contain the expected behavior, as stated in the comment above its declaration.
miladpiri (zkSync) confirmed, but disagreed with severity and commented:
Warden states that if an EOA has some fund on L2, he can not withdraw it by requesting a tx from L1. The only way is to make a tx on L2. But, if the operator is malicious and only process L1-to-L2 txs, not L2 txs, then user’s fund will be trapped.
The scenario requires a malicious operator ignoring L2 txs. The main issue is that it is not possible to withdraw the fund of an account on L2 through L1 -> L2 transaction. Medium is fair.
@Alex the Entreprenerd @vladbochok - The main point of the described finding is about the violation of one of the main zkSync rollup invariants. Namely, the invariant mentioned in the finding is the “ability of the users to access L2 through
L1->L2transactions, and, therefore, withdraw funds from the rollup before the upgrade in case of a scheduled malicious upgrade”.This invariant should be maintained in the system design, as
L1->L2txs are currently the only one legal way to enforce the ability of the user to access his funds in case of the malicious operator. Therefore, it is a critical point that is the only difference between the current zkSync design and the sidechain with transitions proved by zkp.Otherwise, it wouldn’t make sense to publish state diffs using on-chain calldata: such data will be required to reconstruct the rollup state and force/process transactions in case of the malicious operator, but in case the operator can ignore L2 transactions and there is no access to ETH on L2 through
L1->L2txs there is no protection against the malicious operator. This confirms that the described vulnerability is no less serious than the “ability of the operator to not publish some of the rollup state diffs” or the “ability of the operator to ignoreL1->L2transactions (in the long-term system design with escape hatch)” (both of which are high-severity findings).Along with the facts that most of TVL of zkSync is native ETH (link1, link2), and custom wallets are not widely adopted on zkSync, most of the value locked in the zkSync fit the described situation.
vladbochok (zkSync) commented:
I can confirm that this is a valid submission. That being said by @Barichek, the problem is censorship resistance protection, so user can’t escape funds from the rollup using
L1->L2communication.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
The Warden has shown how due to a lack of implementation of
executeTransactionFromOutsidea malicious operator could prevent any withdrawal by denying L2 txs.Because of the specific scoping this is valid. Because of the reliance on a malicious operator, Medium Severity seems the most appropriate.
Note: For full discussion, see here.
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
Impact
If the operator is malicious and ignores L2 transactions, users cannot access ETH on L2 held by EOAs, breaking the guarantee of withdrawal before a malicious upgrade.
What the attacker needed
Malicious operator ignores L2 transactions; user holds ETH on L2 in an EOA
The fix
The report recommends allowing L1-to-L2 transactions to use ETH from the L2 balance as part of msg.value, or implementing the DefaultAccount::executeTransactionFromOutside function as described in its comment.
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.
On a rollup, users can normally send a transaction from the main chain (L1) to the rollup (L2) to recover funds if the rollup operator misbehaves. Here, that recovery path only works for ETH that comes from L1, not for ETH already sitting on L2. So if the operator refuses to process normal L2 transactions, users cannot move their L2 ETH out through L1.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.