# A batch can be unintentionally be challenged during L1 reorg leading to loss of funds

challengeState references batches only by index, so an L1 reorg can swap the committed batch and make a challenger slash the wrong (correct) batch, losing their stake.

- Payout: Audit contest
- Severity: medium
- Program: Morphl2
- Found by: HaxSecurity
- Disclosed: 2024-08-28
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/146
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-morphl2%3AM-6
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm technique:source-review vuln:business-logic vuln:race-condition

**Target:** L1 Rollup contract challengeState
**Root cause:** challengeState identifies the batch solely by batchIndex without binding to the batch hash, so a reorg that reorders batch commits changes which batch sits at that index.
**Steps:**
1. Sequencer submits incorrect batch at batchIndex=x, then a correct batch at x (reverts as occupied).
2. Challenger calls `challengeState(x)` with the challenge deposit.
3. L1 reorg reorders: correct batch lands at x first, incorrect batch reverts.
4. Challenger's challengeState now targets the correct batch and loses the stake when proven.
**How found:** Reading challengeState and noticing it only takes batchIndex, then reasoning about reorg reordering of two competing batch commits at the same index; compared to a prior Optimism reorg finding.
**Exploitation:** Not attacker-driven; requires an L1 reorg to reorder batch commit transactions so the challenger's index-based challenge points at a valid batch, causing loss of the challenge deposit.
**Insight:** When a challenge/dispute function references state by index rather than hash, reorgs can silently retarget it; require the caller to pass the batch header and verify committedBatches[index]==hash.

