Skip to content

fix: apply CEI pattern in DisputeGameFactory create() and createWithInitData()#366

Open
dev-khimesh wants to merge 1 commit into
base:mainfrom
dev-khimesh:fix/dispute-game-factory-cei-pattern
Open

fix: apply CEI pattern in DisputeGameFactory create() and createWithInitData()#366
dev-khimesh wants to merge 1 commit into
base:mainfrom
dev-khimesh:fix/dispute-game-factory-cei-pattern

Conversation

@dev-khimesh

Copy link
Copy Markdown

Description

This PR fixes a Checks-Effects-Interactions (CEI) violation in DisputeGameFactory.sol identified by Lumi Security Audit (Issue #356).

Vulnerability

Both create() and createWithInitData() perform an external call (proxy_.initialize() / proxy_.initializeWithInitData()) before updating the factory's internal state via _finalizeGameCreation(). This violates the CEI pattern and exposes the contract to:

  • Reentrancy attack surface: A malicious initialize function could re-enter the factory before the game is registered
  • Integration failures: If a dispute game implementation expects the factory to recognize it during initialization, the call will fail because _disputeGames mapping hasn't been updated yet

Fix

Swapped the order so _finalizeGameCreation (state effect) runs before proxy_.initialize() (external interaction). The EVM auto-rolls back state if the subsequent call reverts, preserving safety.

Severity: Medium

Closes #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