Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Latest commit

 

History

History
37 lines (31 loc) · 2.29 KB

015.md

File metadata and controls

37 lines (31 loc) · 2.29 KB

Nois3

low

Denial of Service vulnerability in the 'proveWithdrawalTransaction' function of the Optimism L1ERC721Bridge contract

Summary

The proveWithdrawalTransaction function in the L1ERC721Bridge contract is vulnerable to a DoS attack. An attacker can repeatedly call this function with the same withdrawal transaction and different output roots, causing the contract to spend excessive amounts of gas and potentially leading to a blockage of the contract.

Vulnerability Detail

The proveWithdrawalTransaction function allows users to prove a withdrawal transaction by providing an output root proof and a withdrawal proof. However, the function does not have any mechanism to prevent an attacker from repeatedly calling the function with the same withdrawal transaction and different output roots. This can cause the contract to spend excessive amounts of gas on redundant computation and potentially lead to a blockage of the contract.

Impact

Code Snippet

The vulnerable code can be found in the proveWithdrawalTransaction function in the L1ERC721Bridge contract:

function proveWithdrawalTransaction(
        Types.WithdrawalTransaction memory _tx,
        uint256 _l2OutputIndex,
        Types.OutputRootProof calldata _outputRootProof,
        bytes[] calldata _withdrawalProof
    ) external {
        // ...
        // Verify that the output root can be generated with the elements in the proof.
        require(
            outputRoot == Hashing.hashOutputRootProof(_outputRootProof),
            "OptimismPortal: invalid output root proof"
        );
        // ...
}

https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/packages/contracts-bedrock/contracts/L1/OptimismPortal.sol#L160

Tool used

Manual Review

Recommendation

To prevent this vulnerability, the proveWithdrawalTransaction function should have a mechanism to prevent an attacker from repeatedly calling the function with the same withdrawal transaction and different output roots. This could be achieved by adding a mapping of withdrawal transactions to output roots and checking if the provided output root matches the one previously stored before performing further computations. Additionally, the function should check if the provided output root is valid before performing any computation.