Skip to content

fix(disputegamefactory): apply CEI pattern in create() and createWithInitData()#371

Open
dev-khimesh wants to merge 1 commit into
base:mainfrom
dev-khimesh:fix/disputegamefactory-cei-pattern-356
Open

fix(disputegamefactory): apply CEI pattern in create() and createWithInitData()#371
dev-khimesh wants to merge 1 commit into
base:mainfrom
dev-khimesh:fix/disputegamefactory-cei-pattern-356

Conversation

@dev-khimesh

Copy link
Copy Markdown

Description

Fixes a state-desynchronization vulnerability in DisputeGameFactory.sol caused by a violation of the Checks-Effects-Interactions (CEI) pattern.

Vulnerability

In both create() and createWithInitData(), the factory deploys a clone proxy, performs an external initialization call (proxy_.initialize() / proxy_.initializeWithInitData()), and only THEN updates its internal state (_disputeGames mapping and _disputeGameList array).

This creates two risks:

  1. Integration Failure: If a dispute game initialization sequence queries the factory to verify its own legitimacy, the verification fails because the game is not yet registered.
  2. Stale State: Downstream components querying the factory during initialization see stale data.

Fix

Moves _finalizeGameCreation() before the external proxy_.initialize() call in both functions, following the CEI (Checks-Effects-Interactions) pattern. If initialization fails, the EVM atomically reverts the state registration along with the entire transaction.

CEI Order (Corrected)

  1. Checks: Bond validation, duplicate UUID check (already in _createGameImpl)
  2. Effects: _finalizeGameCreation() — register game in factory state
  3. Interactions: proxy_.initialize() — external call to the new game proxy

Closes #356

…WithInitData()

Moves _finalizeGameCreation() before the external proxy.initialize()/initializeWithInitData() call in both create() and createWithInitData() functions to follow the Checks-Effects-Interactions (CEI) pattern. This prevents state-desynchronization where a dispute game could be initialized but not yet registered in the factory registry, which could cause integration failures and stale state reads for downstream components. Closes base#356.
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lumi Security Audit: Security Feedback for DisputeGameFactory.sol

2 participants