# Batches committed during an on going challenge can avoid being challenged

Batches committed during an ongoing challenge get a full finalization window, letting a malicious sequencer finalize an invalid batch unchallenged right after the defender wins.

- Payout: Audit contest
- Severity: medium
- Program: Morphl2
- Found by: PapaPitufo
- Disclosed: 2024-08-28
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/143
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-morphl2%3AM-4
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:race-window technique:source-review vuln:accounting-error vuln:business-logic

**Target:** L2 rollup Rollup.sol commitBatch/challengeState/finalizeBatch
**Root cause:** commitBatch sets finalizeTimestamp = block.timestamp + finalizationPeriodSeconds without compensating for time spent inside an ongoing challenge, while challengeState only extends already-committed batches.
**Steps:**
1. Batch N is finalized; challenger calls `challengeState(N)` paying challengeDeposit, setting inChallenge=true and extending existing batches by proofWindow (2 days).
2. Sequencer commits batch N+1 during the challenge; its finalizeTimestamp = now + finalizationPeriodSeconds (1 day).
3. After ~1.5 days defender wins via `proveState()`, batch N becomes finalizable.
4. Backrun `proveState()` with batched `finalizeBatch(N)` and `finalizeBatch(N+1)` calls; N+1 finalizes before any challenger can call `challengeState(N+1)`.
5. Invalid batch N+1 is finalized with no challenge opportunity.
**How found:** Code review of challengeState's compensation loop versus commitBatch's timestamp assignment; noticed new batches committed during a challenge are not extended, and compared finalizationPeriodSeconds (1 day) to proofWindow (2 days) to confirm the window closes before the challenge ends.
**Exploitation:** Malicious sequencer commits an invalid batch while a challenge is active, waits for the defender to win the current challenge, then backruns proveState with batched finalizeBatch calls to finalize the invalid batch before the challenge window can be used.
**Escalation:** Chaining finalizeBatch calls in one transaction removes the challenger's reaction window entirely; repeated use can finalize arbitrary invalid batches, potentially bricking the L2.
**Insight:** When a protocol pauses or locks a resource during a challenge/dispute, check whether new entries created during that lock inherit the same time compensation; mismatched windows between pre-existing and newly-created state let attackers finalize during the lock.

