Submitted by RadiantLabs
On L2, MsgFinalizeTokenDeposit must be relayed in strict sequence, matching finalizedL1Sequence, err := ms.GetNextL1Sequence(ctx)
x/opchild/keeper/msg_server.go::FinalizeTokenDeposit(..)
As long as a specific L1 sequence is not successfully processed, subsequent L1->L2 deposits have to wait and cannot be processed. If it were possible to purposefully create a MsgFinalizeTokenDeposit message that cannot be executed on L2, it will DoS all subsequent deposits to L2!
Due to strict validation on the L1 in InitiateTokenDeposit(..) it seems almost impossible to create such a message.
However, the data field in MsgFinalizeTokenDeposit is not restricted in size. This allows creating a message that is so large that it cannot be processed on L2. Specifically, the RPC message size limit (rpc-max-body-bytes and max_body_bytes) and the mempool/consensus max tx size limit (maxTxBytes) might be exceeded, preventing the message from being processed.
The RPC limits messages by default to 1MB, while maxTxBytes is set to 2MB (on L1 and the minimove L2).
Note that the RPC limit is not 100% effective. An active validator is not limited by it and can include a message in a proposed block that is larger than the RPC limit, but smaller than the mempool limit.
Given that data is unrestricted, and MsgInitiateTokenDeposit on L1 contains less properties than MsgFinalizeTokenDeposit on L2, it is possible to create a MsgInitiateTokenDeposit message that is smaller than the enforced 2MB, but when relayed to L2, the MsgFinalizeTokenDeposit message is too large (e.g., due to the additional BaseDenom field and others) and thus rejected.
MsgFinalizeTokenDeposit
VS MsgInitiateTokenDeposit
Additionally, the executor batches messages into a single Cosmos tx without any check that the incremental payload exceeds the maximum length that can be accepted by the API, which might lead to this scenario occurring organically if enough messages of normal size accumulate.
Ultimately, L1->L2 deposits can be DoSed by purposefully providing a large data field which results in the L2 MsgFinalizeTokenDeposit message being too large to be processed.
The following PoC demonstrates how a large data field in MsgInitiateTokenDeposit can lead to a DoS of L1->L2 deposits.
Add the following changes. For simplicity, the L1 RPC limit is increased. Note that this does not affect the mempool limit. The RPC limit can be sidestepped by a block proposer anyway.
opinit-bots/e2e/helper.go#L253
opinit-bots/e2e/helper.go#L260
Paste the test case into opinit-bots/e2e/multiple_txs_test.go and run withgo test -v . -timeout 30m -run TestMultipleDepositsAndWithdrawalsExceedingLimit.
After a while, the logs will show that the Cosmos transaction containing the MsgFinalizeTokenDeposit message is rejected due to the message size limit.
This is a proof that L1->L2 deposits can be DoSed by purposefully providing a large data field that results in the L2 MsgFinalizeTokenDeposit message being too large to be processed on L2.
The size of data can be meticulously crafted to be just below the L1 RPC and mempool limit, but exceeding the limits on L2.
One way to do so is to alter the NewInitiateTokenDeposit command to accept data size instead of content:
With this change, it is possible to bisect incrementally larger sizes to find the right limit of a signed transaction (below 749667 is found):
Consider restricting the size of the data field in MsgInitiateTokenDeposit to a reasonable limit, such as 100KB. Additionally, the executor should be modified to handle large messages in a more graceful manner, such as splitting them into multiple transactions if the simulation fails due to the message size limit.
beer-1 (Initia) confirmed, but disagreed with severity and commented:
LSDan (judge) commented:
berndartmueller (warden) commented:
LSDan (judge) commented:
