Skip to content
Business logic Audit finding Intermediate

Malicious challenger can brick `finalizeTimestamp` of unfinalized batches

The challengeState function extends the finalization timestamp of all unfinalized batches by the proof window without any cap. A malicious challenger can repeatedly challenge and immediately prove batches, causing the finalization of other batches to be delayed by many days.

DeltaXV Follow with PASCAL, n4nika and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/145

The protocol has acknowledged this issue.

Found by

DeltaXV, PASCAL, n4nika, ulas

Summary

A malicious challenger can brick the delay for the finalization of batches. This is possible due to the uncapped extension of the finalization period for all unfinalized batches within the challengeState function.

Vulnerability Detail

The challengeState function extends the finalizeTimestamp by doing an addition with the proofWindow variable (2 days) for each index (all unfinalized batches) except the challenged one, with not a single check or safeguard:

Solidity
        for (uint256 i = lastFinalizedBatchIndex + 1; i <= lastCommittedBatchIndex; i++) {
            if (i != batchIndex) {
                batchDataStore[i].finalizeTimestamp += proofWindow;
            }
        }

The permissionless proveState function allows anyone including challengers to provide a ZK-proof and immediate resolution of a challenge, setting inChallenge to false:

Solidity
        // Mark challenge as finished
        challenges[_batchIndex].finished = true;
        inChallenge = false;

Attack details:

  • An attack window of 15 minutes (could be longer)
    • 15 minutes = ~ 75 Ethereum blocks (12 seconds per block)
    • Challenge-prove cycle (due to inChallenge flag) => 2 blocks per cycle => 37 batches
    • Each cycle extends the finalization period for all other batches by proofWindow = 2 days (37 cycles * 2 days per cycle) means that each batch would inccur an additional extension of ~74 days!
  • Attackers capital: 37 ETH => while risking only 1 ETH!
    • Or maybe not, because the malicious challenger could get his deposit back whenever admin pauses the contract see Rollup::L444
    • claimReward function doesn't have a whenNotPaused modifier meaning that the owner has no ability to freeze attackers funds see Rollup::L543

This combination allows an attacker to:

  1. Pre-generate ZK proofs for multiple batches (32 unfinalized batch)
  2. Call challengeState function - Initiate a challenge on a batch
  3. Call proveState function - Immediately prove the batch in the next block
  • Repeat steps 2-3 for multiple batches (32 times)

Result: Each cycle extends the finalization period for all other batches by proofWindow (2 days), finalizeTimestamp accumulate a significant delay due to repetitive extension.

Impact

  • Massive delay for unfinalized batches (uncapped delay) - Huge impact on L2 - Short-term: loss of time and money

Code Snippet

https://github.com/sherlock-audit/2024-08-morphl2/blob/98e0ec4c5bbd0b28f3d3a9e9159d1184bc45b38d/morph/contracts/contracts/l1/rollup/Rollup.sol#L383

Tool used

Manual Review

Recommendation

Fix the current design by implementing some of these mitigation (mainly safguards):

  • Implement a cooldown period between challenges for the same challenger address
  • Cap the maximum extension of the finalization period
  • Check which unfinalized batches requires a extension within the loop
  • Break this attack incentive ? - Implement withdrawal lock period for withrawal request to monitor any suspicious activity - Add a whenNotPaused modifier on the claimReward function, incase of exploit could freeze funds
  • Ultimately restrict the "prover" actor (mitigation from sponsor discussed in private thread).

The original report as published on Sherlock, by DeltaXV. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

Root cause

The challengeState function adds the proof window to the finalizeTimestamp of every unfinalized batch without any cap or cooldown, allowing repeated extensions.

Impact

Unfinalized batches could be delayed by an uncapped amount, causing loss of time and money for the L2.

What the attacker needed

Ability to submit challenges and proofs; sufficient capital for deposits

The fix

The protocol should implement safeguards such as a cooldown between challenges, a cap on the maximum extension, or a check to only extend batches that require it.

How it was found

  1. Pre-generate ZK proofs for multiple batches.
  2. Call challengeState to initiate a challenge on a batch.
  3. Call proveState to immediately prove the batch in the next block.
  4. Repeat steps 2-3 for multiple batches.

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.

When a batch is challenged, the system adds extra time to the finalization of all other pending batches. An attacker can challenge and then quickly prove the same batch over and over, each time adding more delay. This can push back finalization by weeks or months.

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.

More by DeltaXV

View all

4 more disclosed reports, best first.

More from MorphL2

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.