Skip to content
Business logic Audit finding Advanced

OPFaultVerifier ingests games that resolve incorrectly

The OPFaultVerifier contract did not check whether a dispute game was blacklisted before using it to verify state proofs. An attacker could potentially use a blacklisted game, which the Guardian blacklists only when it resolves incorrectly, to have incorrect data accepted by the verifier.

Bauchibred Follow

Originally disclosed on Code4rena

Submitted by Bauchibred

Take a look at the OPFaultVerifier implementation:

https://github.com/code-423n4/2024-12-unruggable/blob/8c8cdc170741d4c93287302acd8bca8ff3d625a2/contracts/op/OPFaultVerifier.sol#L67-L91

interface IOptimismPortal {
    function disputeGameFactory() external view returns (IDisputeGameFactory);
    function respectedGameType() external view returns (GameType);
    // we don't care if the root was blacklisted, this only applies to withdrawals
    //function disputeGameBlacklist(IDisputeGame game) external view returns (bool);
}
..snip
function getStorageValues(
    bytes memory context,
    GatewayRequest memory req,
    bytes memory proof
) external view returns (bytes[] memory, uint8 exitCode) {
    uint256 gameIndex1 = abi.decode(context, (uint256));
    GatewayProof memory p = abi.decode(proof, (GatewayProof));
    (, , IDisputeGame gameProxy, uint256 blockNumber) = _gameFinder.gameAtIndex(
        _portal,
        _minAgeSec,
        _gameTypeBitMask,
        p.gameIndex
    );
    require(blockNumber != 0, "OPFault: invalid game");
    // @audit No blacklist check here
    // ...
    return GatewayVM.evalRequest(req, ProofSequence(0, p.outputRootProof.stateRoot, p.proofs, p.order, _hooks));
}

From the documentation, the Optimism Fault proof verifier assumes that blacklisted games only matters for withdrawals, where as this is one of the reason why the blacklisted logic is implemented (i.e., blockage of withdrawals), this is not the only reason.

To put this in retrospect, The optimism portal allows the GUARDIAN to permanently blacklist a game, when the game resolves incorrectly, that’s to show this is no case to be trusted to be used in our verification logic.

This can be seen from the Optimism Portal itself.

See the implementation of the portal from the previous code4rena audit:

First, the blacklist is implemented as a simple mapping in the OptimismPortal2 contract:

OptimismPortal2.sol#L127-L130

/// @notice A mapping of dispute game addresses to whether or not they are blacklisted.
mapping(IDisputeGame => bool) public disputeGameBlacklist;

Only the guardian can blacklist dispute games and this is done only in the case where the game is resolving incorrectly:

OptimismPortal2.sol#L439-L445

/// @notice Blacklists a dispute game. Should only be used in the event that a dispute game resolves incorrectly.
/// @param _disputeGame Dispute game to blacklist.
function blacklistDisputeGame(IDisputeGame _disputeGame) external {
    if (msg.sender != guardian()) revert Unauthorized();
    disputeGameBlacklist[_disputeGame] = true;
    emit DisputeGameBlacklisted(_disputeGame);
}

Which then brings us to the fact that if a game is blacklisted, then it is a wrong premise to be used for verification and we should check for this in the Verifier.

Impact

High. While the primary and most visible impact of blacklisting a game is blocking withdrawals, the blacklisting mechanism actually invalidates a dispute game entirely since they are resolving incorrectly which then means we shouldn’t use this in our OP Verifiers, otherwise we would be accepting an incorrectly resolving game.

Recommended Mitigation Steps

Ensure the game being verified is not blacklisted.

thomasclowes (Unruggable) acknowledged and commented:

The Optimism documentation is lacking, and this rollup tech is nascent in nature. From our discussions with the OP team the blacklisting is purely utilised for withdrawals. This is corroborated within the smart contracts.

The overhead of checking against the blacklist is significant, and it is unclear how to verify against it in this context noting that the system wasn’t built with this use case in mind.

We acknowledge this, but need to converse with the OP team directly as they iterate on their tech moving forward to be able to utilize this in any meaningful way. It was an intentional ommission.

Picodes (judge) commented:

Downgrading to Low for “unclear documentation” following this remark.

Bauchibred (warden) commented:

@Picodes, thanks for judging, but I can’t seem to understand the POV of the sponsors and take it at face value.

I don’t see how we should be allowing a blacklisted game in Unruggable’s OPVerifier, considering blacklisting a game on Optimism is a completely irreversible process. This is only done once the game is concluded to have been resolved incorrectly by the Guardian.

Does this block withdrawals? 100%, but the game is never permanently blacklisted if it didn’t resolve incorrectly and once done, it can not be un-done. In my opinion, it seems counterintuitive for sponsors to rely on the fact that it’s purely for withdrawals and have it here in the OPVerifier.

Picodes (judge) commented:

@bauchibred - indeed digging into this this isn’t about Unruggable’s documentation, but about Optimism. However, I’m seeing the conditions required for this to happen. I believe Medium severity is more appropriate (“Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.“)

thomasclowes (Unruggable) commented:

The argument here is that the blacklist is not implemented as a method of verifying data integrity when reading data from OP stack chains. It is purely implemented in the context of asset withdrawals as outlined by Optimism. That is to say, Optimism would not blacklist a game to invalidate data read integrity..

Picodes (judge) commented:

@thomasclowes - I get the argument; but to me, the argument is not if they “would not” blacklist this game, but if they “can” do it or not, isn’t it? As they can, your reasoning stands but this is a valid Medium following C4 rules, that you’re free to acknowledge.

thomasclowes (Unruggable) commented:

They ‘can’ blacklist the game, but it is a mechanism that is not used in the context of data verification (this use case).

Picodes (judge) commented:

@thomasclowes - is it explicitly outlined somewhere or is this from your conversation with the team?

thomasclowes (Unruggable) commented:

Conversations with the Optimism team, on their developers Discord. They stated that our use case for verifying state integrity is not what the blacklist is designed for and linked to the following documentation.

“Blacklisting a dispute game means that no withdrawals proven against it will be allowed to finalize (per the “Dispute Game Blacklist” invariant), and they must re-prove against a new dispute game that resolves correctly.”

Unruggable mitigated:

Mitigation here.

Status: Mitigation confirmed. Resolved by adding finalized mode validation to check that the selected game is finalized.


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

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 OPFaultVerifier's getStorageValues function did not check the disputeGameBlacklist mapping before using a dispute game to verify proofs.

Impact

A blacklisted game, which resolves incorrectly, could be used in verification, potentially leading to acceptance of incorrect state data; the judge rated this as Medium severity because the attack requires the Guardian to blacklist a game and the impact is not direct loss of assets.

What the attacker needed

A dispute game is blacklisted by the Guardian; the blacklisted game is used in a proof

The fix

The verifier was mitigated by adding finalized mode validation to check that the selected game is finalized.

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.

A dispute game is a mechanism in Optimism that resolves disagreements about the state of the blockchain. The Guardian can blacklist a game if it resolved incorrectly, meaning it should not be trusted. The verifier in this report did not check for that blacklist, so it might accept data from a game that is known to be wrong.

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 Bauchibred

View all

22 more disclosed reports, best first.

More from Unruggable Invitational

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.