A critical inconsistency exists in Matter Labs' Merkle Tree implementation where competing validation logics for single-node trees create a race condition in the security model. While calculateRootPaths
correctly validates single-node scenarios, both calculateRoot
and calculateRootMemory
implement a conflicting validation pattern that breaks the fundamental security assumptions of cross-chain message verification.
This vulnerability manifests in L1->L2 message processing where single-node Merkle trees (which are valid and common in certain bridge scenarios) would be rejected by calculateRoot
but accepted by calculateRootPaths
. The inconsistency creates an attack vector where a malicious actor could force message processing down specific codepaths by manipulating the tree structure, potentially leading to cross-chain message verification failures or bypasses.
Most critically, single-node Merkle trees are commonly used in bridge implementations for individual message verification, batch processing of single messages, and recovery scenarios. The presence of dual validation paths breaks the security invariant that a valid Merkle proof should be consistently verifiable across the entire system.
The vulnerability stems from competing validations in two locations:
calculateRootPaths
accepts valid single-node cases:
While _validatePathLengthForSingleProof
used by calculateRoot
rejects ALL single-node cases:
Here's a proof-of-concept that demonstrates how this affects bridge message verification:
To exploit this in a bridge context:
Attacker constructs a cross-chain message that must be verified via Merkle proof
Forces message batching into a single-node tree
Message verification fails or succeeds based on which validation path is taken
This breaks the fundamental assumption that valid messages should always verify consistently
The real-world impact is particularly severe for L1->L2 bridges where inconsistent message verification could lead to:
Stuck cross-chain messages
Potential double spending if redundant verification paths exist
Denial of service for legitimate single-message proofs
Increased gas costs from forced message batching to avoid the inconsistency
The fix requires unifying the validation logic to maintain consistent security invariants across all verification paths. Implement a new unified validation function:
Then modify both proof verification paths to use this unified validation:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.