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.
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:
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:
// 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
inChallengeflag) => 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
claimRewardfunction doesn't have awhenNotPausedmodifier meaning that the owner has no ability to freeze attackers funds see Rollup::L543
This combination allows an attacker to:
- Pre-generate ZK proofs for multiple batches (32 unfinalized batch)
- Call
challengeStatefunction - Initiate a challenge on a batch - Call
proveStatefunction - 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
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
whenNotPausedmodifier on theclaimRewardfunction, incase of exploit could freeze funds - Ultimately restrict the "prover" actor (mitigation from sponsor discussed in private thread).
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
- Pre-generate ZK proofs for multiple batches.
- Call challengeState to initiate a challenge on a batch.
- Call proveState to immediately prove the batch in the next block.
- 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.