# Attacker can fill merkle tree in `L2ToL1MessagePasser`, blocking any future withdrawals

Single fixed-capacity merkle tree (2^32-1 leaves) for all L2->L1 withdrawals can be filled by cheap spam, permanently bricking withdrawals.

- Payout: Audit contest
- Severity: medium
- Program: Morphl2
- Found by: mstpr-brainbot
- Disclosed: 2024-08-28
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/178
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-morphl2%3AM-9
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:dos

**Target:** L2ToL1MessagePasser / Tree.sol merkle tree on L2
**Root cause:** One global merkle tree with a hard cap of 2**32-1 leaves is used for all withdrawals; _appendMessageHash reverts with MerkleTreeFull once leafNodesCount reaches the cap, and there is no reset or alternate handling.
**Steps:**
1. Deploy a contract on L2 calling `l2CrossDomainMessenger.sendMessage(payable(0), 0, "", 0)` 200 times per tx (~9.9M gas).
2. Automate repeated calls (~21,000,000 txs) to append leaves until leafNodesCount hits 2**32-1.
3. Once full, every `_sendMessage` reverts in `Tree.sol::_appendMessageHash`, blocking all L2->L1 withdrawals.
**How found:** Code review of Tree.sol revealed a fixed _MAX_DEPOSIT_COUNT cap on a single shared tree; researcher measured gas per sendMessage to confirm the DoS is economically feasible.
**Exploitation:** Attacker spams cheap zero-value sendMessage calls from L2 to append leaves to the shared withdrawal merkle tree; at ~$51k gas cost the tree fills and all future withdrawals revert permanently.
**Insight:** For rollup/bridge designs, check whether withdrawal/message merkle trees are bounded and shared globally; a fixed-capacity append-only tree is a cheap griefing DoS vector—measure per-leaf gas cost to assess feasibility.

## Proof of concept (copied exactly from the original report)

**PoC test filling 200 withdrawals per tx**

```
function test_lowGasSendMessage() public {
    for (uint256 i = 0; i < 200; ++i) {
        l2CrossDomainMessenger.sendMessage(payable(0), 0, "", 0);
    }
}
```

