Challenger can override the 7 day finalization period
The L2OutputOracle contract allows the challenger to delete any L2 output, even those older than the 7-day finalization period, which can invalidate already confirmed withdrawals. An attacker with the challenger role could delete an output, causing users' withdrawals to fail.
unforgiven Follow with csanuragjain
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-01-optimism-judging/issues/75
Found by
unforgiven, csanuragjain
Summary
All withdrawals are finalized after a 7 days window (finalization period). After this duration transaction are confirmed and user can surely withdraw their balance. But due to lack of check, challenger can delete a l2Output which is older than 7 days meaning withdrawals will stop working for even confirmed transaction
Vulnerability Detail
- Proposer has proposed L2 output for a _l2BlockNumber which creates entries on l2Outputs using the proposeL2Output. Assume this creates a new l2Output at index X
l2Outputs.push(
Types.OutputProposal({
outputRoot: _outputRoot,
timestamp: uint128(block.timestamp),
l2BlockNumber: uint128(_l2BlockNumber)
})
);
-
proveWithdrawalTransaction has been called for user linked to this l2Output
-
Finalization period(7 day) is over after proposal and Users is ready to call
finalizeWithdrawalTransactionto withdraw their funds -
Since confirmation is done, User A is sure that he will be able to withdraw and thinks to do it after coming back from his holidays
-
Challenger tries to delete the index X (Step 1), ideally it should not be allowed as already confirmed. But since there is no such timeline check so the l2Output gets deleted
function deleteL2Outputs(uint256 _l2OutputIndex) external {
require(
msg.sender == CHALLENGER,
"L2OutputOracle: only the challenger address can delete outputs"
);
// Make sure we're not *increasing* the length of the array.
require(
_l2OutputIndex < l2Outputs.length,
"L2OutputOracle: cannot delete outputs after the latest output index"
);
uint256 prevNextL2OutputIndex = nextOutputIndex();
// Use assembly to delete the array elements because Solidity doesn't allow it.
assembly {
sstore(l2Outputs.slot, _l2OutputIndex)
}
emit OutputsDeleted(prevNextL2OutputIndex, _l2OutputIndex);
}
- User comes back and now tries to withdraw but the withdraw fails since the l2Output index X does not exist anymore. This is incorrect and nullifies the network guarantee.
Note: In case of a separate output root could be proven then user withdrawal will permanently stuck. Ideally if such anomaly could not be caught within finalization period then user should be allowed to withdraw
Impact
Withdrawal will fail for confirmed transaction
Code Snippet
Tool used
Manual Review
Recommendation
Add below check in
require(getL2Output(_l2OutputIndex).timestamp<=FINALIZATION_PERIOD_SECONDS, "Output already confirmed");
Discussion
rcstanciu
Comment from Optimism
Description: deleteL2Outputs delays finalization
Reason: This is know and expected behavior. If it did not delay finalization, new outputs would not be subject to the finalization window
csanuragjain
Escalate for 30 USDC
Finalization period is the time for raising any dispute and if finalization period is crossed then no matter what, transaction should be considered confirmed (Refer https://github.com/ethereum-optimism/optimism/blob/develop/specs/withdrawals.md).
The issue here is that Challenger is able to bypass the 7 days finalization period. Post 7 day finalization period, transaction should come in confirmed state but seems like Challenger can delete the l2OutputRoot even for confirmed state transaction. This is incorrect and will bring confirmed transaction into unconfirmed state again even when they completed the finalization period.
Challenger should be disallowed to delete any L2Output where getL2Output(_l2OutputIndex).timestamp>FINALIZATION_PERIOD_SECONDS
sherlock-admin
Escalate for 30 USDC
Finalization period is the time for raising any dispute and if finalization period is crossed then no matter what, transaction should be considered confirmed (Refer https://github.com/ethereum-optimism/optimism/blob/develop/specs/withdrawals.md).
The issue here is that Challenger is able to bypass the 7 days finalization period. Post 7 day finalization period, transaction should come in confirmed state but seems like Challenger can delete the l2OutputRoot even for confirmed state transaction. This is incorrect and will bring confirmed transaction into unconfirmed state again even when they completed the finalization period.
Challenger should be disallowed to delete any L2Output where
getL2Output(_l2OutputIndex).timestamp>FINALIZATION_PERIOD_SECONDS
You've created a valid escalation for 30 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation accepted.
Accepting escalation and labeling issue as medium as challenger is able to delete finalized withdrawals.
sherlock-admin
Escalation accepted.
Accepting escalation and labeling issue as medium as challenger is able to delete finalized withdrawals.
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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 deleteL2Outputs function lacks a check to prevent deletion of outputs that are older than the finalization period.
Impact
Withdrawals for confirmed transactions can fail if the challenger deletes the corresponding output, potentially permanently locking funds if a separate output root is proven.
What the attacker needed
Challenger role
How it was found
- A proposer submits an L2 output, creating an entry in the l2Outputs array.
- A user proves a withdrawal transaction linked to that output.
- The 7-day finalization period passes, and the user expects to finalize the withdrawal.
- The challenger calls deleteL2Outputs for that output index, which succeeds because there is no timestamp check.
- The user later tries to finalize the withdrawal but it fails because the output no longer exists.
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.
In this system, withdrawals are only final after a waiting period of 7 days. During that time, a special user called the challenger can delete outputs to dispute them. The bug is that the challenger can still delete outputs after the 7 days, which means a withdrawal that should be safe can be cancelled.
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.