Skip to content

fix(security): Security audit, fix security findings in grevm parallel EVM#99

Merged
AshinGau merged 9 commits intoGalxe:mainfrom
AshinGau:security
Mar 9, 2026
Merged

fix(security): Security audit, fix security findings in grevm parallel EVM#99
AshinGau merged 9 commits intoGalxe:mainfrom
AshinGau:security

Conversation

@AshinGau
Copy link
Copy Markdown
Collaborator

@AshinGau AshinGau commented Mar 4, 2026

follow #97

Richard1048576 and others added 9 commits February 26, 2026 10:35
Internal security audit of grevm parallel EVM engine identified:
- 3 CRITICAL: undefined behavior via invalid_reference_casting (7 instances),
  data race on ContinuousDetectSet, unsound concurrent ParallelState mutation
- 3 HIGH: TOCTOU race in async_finality, deadlock risk in TxDependency,
  next_validation_idx double-increment race
- 5 MEDIUM: panic in production paths, env var parsing, hardcoded ERC20 hints,
  println debug output, fork_join unsound mutation
- 5 LOW + 3 INFO: bounds checks, TODOs, memory ordering, redundancy

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…M-019)

CRITICAL fixes:
- GREVM-001: Replace all 7 instances of `&T → &mut T` UB with proper
  interior mutability (UnsafeCell, AtomicBool, DisjointVec wrapper)
- GREVM-002: Replace Vec<bool> with Vec<AtomicBool> in ContinuousDetectSet
- GREVM-003: Wrap ParallelState in UnsafeCell with documented safety
  invariants for commit thread vs worker thread access

HIGH fixes:
- GREVM-004: Fix TOCTOU race in async_finality by holding lock across
  check-and-set
- GREVM-005: Fix potential deadlock in TxDependency::add() by enforcing
  ascending lock order on dependent_state
- GREVM-006: Fix double-increment race in next_validation_idx() with
  compare_exchange loop

MEDIUM fixes:
- GREVM-007: Replace panic!/assert!/unwrap() in production paths with
  error returns (async_commit nonce check, balance increment, scheduler
  commit/validation/execution panics)
- GREVM-008: Use unwrap_or(default) for env var parsing
- GREVM-009: Fix get_contract_type() to return UNKNOWN for non-ERC20
  function selectors (was hardcoded to ERC20)
- GREVM-010: Replace println!() with tracing::warn!/debug!
- GREVM-011: Introduce DisjointVec<T> wrapper with UnsafeCell for
  fork-join parallel mutation with documented safety

LOW/INFO fixes:
- GREVM-014: Upgrade memory ordering to Acquire/Release
- GREVM-015: Remove redundant block_size field
- GREVM-INFO-001: Remove dead func_id initialization
- GREVM-INFO-003: Replace .clone() on Copy types

All tests pass (20/20). 3 findings deferred (GREVM-012, 013, 016).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
HIGH findings:
- GREVM-R2-001: UnsafeCell safety invariant not enforced by the type
system — state_mut() accessible from any thread context
- GREVM-R2-002: Commit continues after nonce validation failure —
invalid state applied before abort

MEDIUM findings:
- GREVM-R2-003: fork_join_util produces empty partitions without guard
when num_elements < parallel_cnt
- GREVM-R2-004: clear_destructed_entry full table scan is O(n) on
MVMemory size, potential DoS via SELFDESTRUCT
- GREVM-R2-005: tx_dependency.print() clones and locks all state
unconditionally under tracing::debug!

LOW findings:
- GREVM-R2-006: DisjointVec::set has no bounds check
- GREVM-R2-007: IdentityHasher::write() panics with unreachable!()
- GREVM-R2-008: Unnecessary clone in parallel_apply_transitions via
transitions.get().cloned()

INFO findings:
- GREVM-R2-INFO-001: release profile sets panic="abort"
- GREVM-R2-INFO-002: forked dependencies on private branch

Filtered out findings matching Round 1 reviewer rejection patterns
(algorithmic invariant panics, Block-STM design-level TOCTOU,
business-logic-guaranteed lock ordering, consensus-layer bounds).
Copy link
Copy Markdown
Collaborator

@Richard1048576 Richard1048576 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AshinGau AshinGau merged commit 45cbc41 into Galxe:main Mar 9, 2026
2 checks passed
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.

3 participants