Skip to content

Auditing Merkle Proofs in Solidity - How Airdrops and Bridges Accept Forged Claims

An airdrop or a bridge that pays from a Merkle root stores 32 bytes on chain and leaves the list itself off chain. A claimant sends a leaf and a short proof, the contract recomputes the root, and a match means the leaf was in the committed list. The hashing in that check is a few lines of a well-tested library; the bugs found in audits and incidents sit around it: in what the leaf commits to, in which proofs the library accepts, in what the contract records after a successful check, and in who sets the root.

This article goes through nine such bugs, grouped by where they sit. Each one is reproduced by a Foundry test against OpenZeppelin’s MerkleProof library, with the fix next to the vulnerable code. Where a public finding, advisory or incident exists, it is cited: the Across V2 audit, KarmaAirdrop, AmpleEarn, an OpenZeppelin advisory, Nomad and the BNB Chain bridge. The other cases come from the library’s own warnings and from the encoding rules. The 18 tests are in the verification directory of this site’s repository: test/Leaf.t.sol holds cases 1 to 5 and test/ProofAndRoot.t.sol cases 6 to 9, all passing on solc 0.8.28 with Foundry 1.5.0.

This article has been made with the help of Claude Code and several custom skills

What you need to know first

The article assumes Solidity and the basics of hash functions. It relies on the following mechanisms without deriving them:

  • Merkle tree and inclusion proof. Leaves are hashed in pairs, level by level, up to a single root. A proof for one leaf is the list of sibling hashes on its path; the verifier hashes the leaf with each sibling in turn and compares the result with the stored root.
  • Sorted-pair hashing. OpenZeppelin’s MerkleProof hashes the smaller of two nodes first, so H(a, b) == H(b, a). A proof then needs no left/right flags, and it shows that a leaf is in the tree, not where.
  • abi.encode and abi.encodePacked. abi.encode pads every static value to 32 bytes and writes an offset and a length for each dynamic value; abi.encodePacked concatenates values with no padding for short types and no lengths. The ABI encoding article covers both.
  • Multiproof. One proof for several leaves at once: the verifier merges the leaves and a list of sibling hashes, and an array of boolean flags says, at each step, whether the second input comes from the queue of leaves and computed hashes, or from the proof.
  • Claim record. A mapping or a bitmap that marks a leaf, an index or an account as paid, so the same proof cannot be used twice.
  • @openzeppelin/merkle-tree. OpenZeppelin’s JavaScript library that builds the tree off chain. Its StandardMerkleTree ABI-encodes each leaf and hashes it twice with Keccak-256.

How a contract checks a proof

A distributor has three parts: an off-chain builder that turns the allocation list into a tree and a root, a setter that stores the root, and a claim function. The claim function rebuilds the leaf from its arguments, checks the proof, records the claim and pays. The diagram places the nine cases of this article on that path; solid arrows are the normal flow.

flowchart LR
    B["Off-chain builder<br/>list to tree to root"] --> S["Root setter<br/>owner, router, upgrade"]
    S --> R[("Stored root")]
    C["claim(args, proof)"] --> L["Rebuild the leaf<br/>from the arguments"]
    L --> V["MerkleProof.verify"]
    R --> V
    V --> K["Claim record<br/>bitmap or mapping"]
    K --> P["Payment"]
    L -.- X1["1 64-byte leaf<br/>2 packed encoding<br/>3 no claimant<br/>4 no chain id<br/>5 free index"]
    V -.- X2["6 empty multiproof<br/>7 library version"]
    K -.- X3["8 record reset<br/>by a new root"]
    S -.- X4["9 zero root,<br/>open setter"]

The verification itself is short. OpenZeppelin’s single-leaf version walks the proof and hashes each pair in sorted order:

// OpenZeppelin Contracts v5.7.0, utils/cryptography/MerkleProof.sol (default hash)
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
    bytes32 computedHash = leaf;
    for (uint256 i = 0; i < proof.length; i++) {
        computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
    }
    return computedHash;
}

Nothing in this loop knows how deep the tree is, what a leaf looks like or which position the leaf holds. Those facts must come from the leaf format and from the contract around the call, which is where the first five cases are.

What the leaf must commit to

1. A leaf hashed once from 64 bytes

An inner node is the hash of two 32-byte children, that is, the hash of 64 bytes. If a leaf is also the hash of 64 bytes, the verifier has no way to tell an inner node from a leaf. An attacker takes the two children of an inner node, passes them as the two fields of a leaf, and presents the rest of the path as the proof. The contract rebuilds a “leaf” equal to the inner node, and the shorter proof reaches the root.

This is a second-preimage attack on the tree: a second input, other than a real leaf, that hashes to a node on the path.

Because pairs are sorted before hashing, the inner node is H(lo, hi), where lo is the smaller of its two children and hi the larger. The attacker passes them in that order, lo as the first field of the leaf and hi as the second.

flowchart TB
    root["root"] --- n01["n01 = H(lo, hi)"]
    root --- n23["n23"]
    n01 --- l0["leaf 0"]
    n01 --- l1["leaf 1"]
    n23 --- l2["leaf 2"]
    n23 --- l3["leaf 3"]
    A["Attacker calls redeem(id = lo, amount = hi, proof = [n23])"] -.-> n01

The test builds a four-leaf tree whose leaves are keccak256(abi.encode(voucherId, amount)) and redeems the inner node n01: the call passes and credits an amount equal to the larger child hash read as a 256-bit integer. The attacker does not choose that number, and it is far above any real allocation. A distributor that transfers exactly amount reverts; one that caps the payout at its balance, or credits an internal balance as the test does, pays out.

OpenZeppelin’s library states the condition in its header:

WARNING: You should avoid using leaf values that are 64 bytes long prior to hashing, or use a hash function other than keccak256 for hashing leaves. This is because the concatenation of a sorted pair of internal nodes in the Merkle tree could be reinterpreted as a leaf value.

Two fixes follow from it:

  • Hash twice. The StandardMerkleTree of @openzeppelin/merkle-tree hashes the encoded leaf twice, keccak256(bytes.concat(keccak256(abi.encode(...)))), so a leaf is the hash of 32 bytes and never the hash of 64.
  • Encode more than two words. A leaf encoded from three or more 32-byte fields is longer than 64 bytes, so it never matches the input of an inner node.

The attack also needs both fields to accept any 32-byte value. When the first field is an address, abi.encode pads it with 12 zero bytes, so lo would need 96 leading zero bits (derived, not tested).

Implementation: VoucherSingleHash and VoucherDoubleHash in src/Cases.sol; tests test_1_* in test/Leaf.t.sol.

2. abi.encodePacked with two dynamic values

Packed encoding writes strings and byte arrays with no length, so two dynamic values next to each other have no visible boundary. A leaf that packs a handle and a code gives the same bytes for the pairs alice + bob1 and alic + ebob1: both are alicebob1. A proof issued for the first pair proves the second, so whatever the list grants to alice with code bob1 (access, a discount, a claim) is also granted to a handle alic that was never listed.

The test lists ("alice", "bob1") and checks that isListed("alic", "ebob1", proof) returns true. With abi.encode, each string carries an offset and a length, and the two leaves differ. Packed encoding is unambiguous only when at most one argument is dynamic; a fixed-size address followed by a uint256 is safe, two strings are not.

Implementation: PackedAllowlist and EncodedAllowlist; test_2_packedCollision.

3. A leaf that does not name the claimant

The tree and its proofs are public: a claim page usually lets anyone download the whole list. If the leaf is (index, amount) and the contract pays msg.sender, the first account to submit a proof takes the allocation, and a bot watching the mempool can copy a pending claim. The same happens when the leaf names an account but the contract pays msg.sender without comparing the two.

The fix puts the account in the leaf and pays that account, whoever sends the transaction. Paying the leaf’s account also keeps relayed or batched claims safe, since a relayer can submit the call but cannot redirect the funds. In the test, Eve submits Alice’s claim and Alice receives the tokens. A second call by Eve, this time naming herself as the account, reverts because index 0 is already claimed.

Implementation: AnonymousDrop and BoundDrop; test_3_*.

4. A leaf without its chain or its contract

A root is a commitment to a list, not to a place. Teams store the same root more than once when a distribution is deployed on several chains, when a contract is redeployed, or when one root is broadcast to several contracts. Every leaf is then valid in each of them. Across is a bridge with one “spoke pool” contract per chain; a “slow relay” is a transfer that the protocol fills from the destination spoke pool when no relayer has filled it. This is the critical finding of OpenZeppelin’s audit of UMA Across V2 (May 2022), “Slow relays on multiple chains”:

Notably, every spoke pool receives the same slowRelayRoot, which represents all slow relays in the batch across the whole system. When the slow relay is executed, the Spoke Pool does not filter on the destination chain id, which means that any slow relay can be executed on any spoke chain where the Spoke Pool has sufficient funds in the destinationToken.

OpenZeppelin recommended adding the destination chain id to the slow-relay data, and the report marks the issue fixed in pull request #79. In the test, a leaf for (index, account, amount) is claimed on chain 1 and again on chain 10 from a second deployment with the same root. The fixed contract hashes block.chainid and address(this) into the leaf, so the proof built for chain 1 fails on chain 10. A window or epoch number belongs in the leaf for the same reason when several distributions share a contract. The Across Protocol article shows where the current code rebuilds the leaf with the chain id.

Implementation: ChainlessDrop and ScopedDrop; test_4_*.

5. An index the leaf does not contain

Distributors usually mark claims in a bitmap keyed by the leaf’s index, because a bit is cheaper than a mapping slot per account. The index must then be part of the leaf. If the leaf is (account, amount) and the index is a free argument, one leaf can be claimed once per index: the test claims Alice’s 100 tokens under index 0, 1 and 7 and ends with 300.

Sorted-pair hashing makes this easy to miss. In a tree hashed in order, left child first, the left/right choices along a proof spell out the leaf’s index in binary, so a verifier could recover the index from the proof.

Sorted pairs remove that information: H(a, b) == H(b, a), and the test’s sorted-pair helper, which mirrors Hashes.commutativeKeccak256, gives the same root whichever order the two leaves take. With sorted pairs, a proof shows membership, not position, and anything positional has to be in the leaf. The KarmaAirdrop contract discussed in case 8 follows the rule, with a leaf keccak256(abi.encodePacked(index, account, amount)) and a bitmap keyed by index. That leaf packs 84 bytes of fixed-size values, so neither case 1 nor case 2 applies to it.

Implementation: FreeIndexDrop; test_5_*.

What the verifier accepts

6. The empty multiproof

A multiproof with no leaves and a single proof item is valid by definition. OpenZeppelin documents the case in v5.7.0:

NOTE: The empty set (i.e. the case where proof.length == 1 && leaves.length == 0) is considered a no-op, and therefore a valid multiproof (i.e. it returns proof[0]). Consider disallowing this case if you’re not validating the leaves elsewhere.

With leaves = [] and flags = [], the function returns proof[0], so a caller who passes the stored root as the single proof item gets a match: the call returns true whatever the root is, without any leaf. A contract that only marks or pays the leaves it receives loses nothing, since there are none. A contract that acts on the “true” itself does. In the test, a keeper contract pays a fixed fee per settled batch, and Eve earns it twice with two empty batches. The fix is one line: require(leaves.length > 0).

Implementation: KeeperBatch; test_6_* in test/ProofAndRoot.t.sol.

7. The library version: multiproofs in OpenZeppelin 4.7.0 to 4.9.1

multiProofVerify arrived in OpenZeppelin Contracts 4.7.0 (29 June 2022). Until 4.9.2 (16 June 2023) it could prove leaves that are not in the tree. The advisory GHSA-wprv-93r4-jj2p (CVE-2023-34459) gives the condition:

A contract may be vulnerable if it uses multiproofs for verification and the merkle tree that is processed includes a node with value 0 at depth 1 (just under the root). This could happen inadvertently for balanced trees with 3 leaves or less, if the leaves are not hashed. This could happen deliberately if a malicious tree builder includes such a node in the tree.

The cause is visible in the 4.8.3 code. The loop reads its inputs from a queue: first the leaves, then the hashes array that the loop itself fills, one entry per step.

The only length check compares the sizes of the three arrays. Nothing checks that every proof item was used, so a flag sequence can make the loop read entries of hashes that have not been written yet. Memory arrays start at zero, so those reads return zero, and a tree whose root has a zero child accepts the result. The code below is quoted with lines elided and one comment added; the nested ternary on the b line reads “if the flag is set, take the next leaf or the next hash, otherwise take the next proof item”.

// OpenZeppelin Contracts v4.8.3, utils/cryptography/MerkleProof.sol, processMultiProof (lines 122-161)
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
...
for (uint256 i = 0; i < totalHashes; i++) {
    bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
    bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
    hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
    return hashes[totalHashes - 1];   // no check that proofPos == proof.length
}

The test builds a two-leaf tree whose root is H(0, x) and proves a leaf that is not in it. In a two-leaf tree the nodes at depth 1 are the leaves themselves, so this is the advisory’s “node with value 0 at depth 1”: one leaf is stored unhashed and equals zero. With one leaf, a proof [x, anything] and the flags [true, false], the length check passes (1 + 2 − 1 = 2) and the loop runs twice:

Step a b Result
0 the forged leaf flag true, leaves exhausted: hashes[0], not yet written, so 0 hashes[0] = H(leaf, 0)
1 hashes[1], not yet written, so 0 flag false: proof[0] = x hashes[1] = H(0, x), the root

Version 4.9.2 adds require(proofPos == proofLen) after the loop. The second proof item was never read, so 4.9.6, the last 4.x release, tested here as the fixed 4.x line, reverts with MerkleProof: invalid multiproof, and 5.7.0 reverts with the custom error MerkleProofInvalidMultiproof(). The test runs the same inputs against the three vendored versions.

Single-leaf verify is not affected, and the advisory notes that trees built with @openzeppelin/merkle-tree are safe, because their leaves are hashed. An audit of a contract that pins an older OpenZeppelin should still read the version from the lockfile or the submodule commit: an import path such as @openzeppelin/contracts/... names no version, and a vendored folder or a remapping can name one version while holding another.

Implementation: vendored MerkleProof.sol from v4.8.3, v4.9.6 and v5.7.0; test_7_*.

On 7 October 2022 the BNB Chain bridge lost 2,000,000 BNB to a bug of the same family. Its IAVL proof verifier, written in Go, used Left and Right attributes on path nodes to place each sibling.

Immunefi’s analysis shows that the verifier compared a hash derived from the leaf with the path node’s Right field (if !bytes.Equal(derivedRoot, lpath.Right)), while “the right attribute of the node was not used to calculate the root hash of the tree”. The attacker took a legitimate proof, added a leaf for a forged payload, and wrote that leaf’s hash into Right: the comparison with Right passed, and the root, computed without Right, still matched the trusted one.

flowchart LR
    F["Forged payload leaf"] -->|"hash compared with"| RT["Path node: Right"]
    LT["Path node: Left"] -->|"used to compute"| ROOT["Root = trusted root"]
    RT -.-x|"never used"| ROOT

The general rule for any verifier that accepts structured proofs (IAVL, Merkle-Patricia, SSZ branches): every field of a proof node either enters the hash that is compared with the root, or is rejected. The bridge hacks article places the incident among other verification failures.

What the contract records

8. Claim records that a new root resets

Updating a root is routine: a list is corrected, a new round starts. The claim record must survive the update for every allocation that carries over. KarmaAirdrop (Status Network) kept its bitmap per epoch, claimedBitMap[epoch], and setMerkleRoot incremented the epoch, so each new root started with an empty record.

The migration relied on a pause. The owner pauses the contract, so the claim record stops changing, then sets the new root and unpauses.

In the reproduction’s description of the finding, the users listed again in the new root are those who had not claimed yet, and the pause is what keeps that list accurate until the switch. The weak point was that claim did not check the pause.

The registry’s reproduction of Cyfrin’s finding “User can double claim airdrop” describes the sequence: a user listed again in the coming root claims under the old root while the contract is paused, the epoch moves on, and the user claims again under the new one. The fix, commit ebbf84b in the status-network-monorepo repository, added whenNotPaused to claim, so the record cannot change between the snapshot and the new root.

sequenceDiagram
    participant O as Owner
    participant D as Airdrop
    participant A as Alice (listed in both roots)
    O->>D: pause()
    A->>D: claim(index 0, proof under root 1)
    Note over D: claimed[epoch 0][0] = true, 100 paid
    O->>D: setMerkleRoot(root 2)
    Note over D: epoch = 1, empty record
    O->>D: unpause()
    A->>D: claim(index 0, proof under root 2)
    Note over D: claimed[epoch 1][0] was false, 100 paid again

The test’s EpochDrop is a reduced model of that contract. The test sets the same root again to stand for a new root that lists Alice again, and Alice ends with 200 instead of 100; with the pause guard on claim, the first call reverts and she is paid once.

A per-round record is not a bug in itself: UMA’s MerkleDistributor keeps claimedBitMap[windowIndex] because each window is a separate distribution with its own funds. The question for a review is whether one allocation can be valid under two roots that use different records. For cumulative designs, where a leaf states the total earned so far and the contract pays the difference, the record claimed[account] must persist across roots and only grow; a new root with a lower total must not underflow or pay again. The record must also be written before the payment, on every claim path, or a token callback can reenter claim before the bit is set.

Implementation: EpochDrop; test_8_*.

Who sets the root

9. A zero root and an open setter

The root is the only on-chain input that the whole scheme trusts, so its default value and its setter deserve the same review as the proof check.

Nomad’s loss on 1 August 2022, the date Elliptic and TRM Labs give, came from the default value. TRM Labs places the flaw in Nomad’s Replica contract and its process() function, which executes a message from another chain once the message counts as proven. An upgrade initialised the trusted root to 0x00, which is also the value an unproven message has. Mandiant’s analysis, quoting Halborn:

In an upgrade to the protocol, Nomad decided to initialize the value of trusted roots to 0x00. While this is common practice, it also matches the value for an untrusted root, so all messages are automatically viewed as proven.

Every unproven message therefore counted as proven, and anyone could call process() with a message of their choice. The test’s reduced model behaves the same way: after initialize(bytes32(0)), an unproven message is processed. The fixed model refuses a zero root at initialisation and in the function that decides whether a root is trusted (acceptableRoot in the model).

The setter is the other half. Pashov Audit Group’s December 2025 review of AmpleEarn reported it as finding C-01: a router’s batchSetMerkleRootsStrict had no access control. The vault authorised its root setter by msg.sender, and the router was a registered caller, so anyone could set roots through the router and direct the payout to themselves. For each root setter, a review lists every path that reaches it (router, multicall, proxy admin, governance), the authorisation on each path and any delay before the new root takes effect. It also checks that the full list is published, so that anyone can rebuild the tree and compare its root with the stored one.

Implementation: ZeroRootReplica; test_9_*. AmpleEarn is not reproduced here; a PoC is in the EVM hack registry, entry 64041.

Worked example: mapping the sites before reading

A review starts by finding every place where a proof is checked, a leaf is built, a root is written and a claim is recorded. The audit workflow used for this article has a small helper, merkle_sites.py, that lists those sites with text patterns, without compiling, and flags three leaf patterns. It is part of the author’s private toolset, not published; its full output on the test contracts is in the verification directory. The three flags are:

  • SINGLE-HASH-64: one hash of two static 32-byte words;
  • PACKED-DYNAMIC: packed encoding with a string, bytes or array argument;
  • NO-SENDER: a leaf that names no account.

Run on the test contracts, it reports 12 verify sites, 10 leaves, 11 root writes and 6 claim records. An excerpt, with the case each line belongs to added as a comment:

LEAF     Cases.sol:22  SINGLE-HASH-64 NO-SENDER | bytes32 leaf = keccak256(abi.encode(voucherId, amount));   # case 1
LEAF     Cases.sol:58  PACKED-DYNAMIC NO-SENDER | return keccak256(bytes.concat(keccak256(abi.encodePacked(handle, code))));   # case 2
LEAF     Cases.sol:104  NO-SENDER | bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(index, amount))));   # case 3
LEAF     Cases.sol:181  bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount))));   # case 5
VERIFY   Cases.sol:204  require(MerkleProof.multiProofVerifyCalldata(proof, flags, root, leaves), "proof");   # case 6
CLAIMED  Cases.sol:221  mapping(uint256 => mapping(uint256 => bool)) public claimed;   # case 8

The flags find cases 1, 2 and 3. They also mark the fixed VoucherDoubleHash and both allowlists as NO-SENDER. For the allowlists the flag is noise, since they pay nothing. For VoucherDoubleHash it is a real lead: the leaf names no account and the contract pays msg.sender, so anyone holding a proof redeems the voucher. That is case 3’s flaw, acceptable only if the voucher is meant to be a bearer instrument.

The other six cases carry no flag. Line 181 is case 5, a leaf without the index used as the claim key; line 204 is the multiproof of case 6, with no check on the number of leaves; line 221 is the per-epoch record of case 8. Cases 4, 7 and 9 need facts that are not on any one line: the deployment plan, the OpenZeppelin version in the lockfile, the initialisation value and the setter’s call paths. The list is a map of where to read, and each case above is a question to ask at one of its sites.

Conclusion

A Merkle proof check proves one thing: the leaf the contract rebuilt is in the tree whose root is stored. The nine cases fail on the facts around that statement:

  • The leaf must not be one hash of 64 bytes, must not pack two dynamic values together, and must name the account paid and the index used as the claim key; it must also name the chain and the contract whenever the same root can be stored in more than one place. Sorted-pair proofs show membership, not position.
  • The verifier accepts an empty multiproof by design, and OpenZeppelin 4.7.0 to 4.9.1 accepted forged multiproofs for trees with a zero node under the root; proof fields that do not enter the hash, as in the BNB Chain bridge, are the same failure in another system.
  • The claim record must survive a root update for every allocation that appears in both roots.
  • The root must not have a default value that the contract treats as confirmed, and every path to its setter must be authorised.

All nine cases have a test in the verification directory, with the fix next to the vulnerable code, with two exceptions: case 5 has no separate fixed contract, since the leaves of BoundDrop and ScopedDrop already carry the index, and case 7 compares library versions instead of contracts. For case 9, the test covers the zero root, not the AmpleEarn setter. The tests use reduced models of the KarmaAirdrop and Nomad contracts, not the deployed code.

Mindmap of Merkle proof audit pitfalls in Solidity covering leaf design, verifier behaviour, claim records, root management, incidents and fixes

Annex

Key Terms

Term Definition
Merkle root The single hash at the top of a Merkle tree; a contract stores it as a commitment to the whole list.
Leaf The hash of one entry of the list, rebuilt on chain from the claim’s arguments.
Inner node The hash of two child nodes; with Keccak-256 over two 32-byte children it is a hash of 64 bytes.
Inclusion proof The sibling hashes on the path from a leaf to the root.
Sorted-pair (commutative) hashing Hashing the smaller of two nodes first, so the order of siblings does not matter and the proof carries no position.
Second preimage (64-byte leaf attack) Presenting the two children of an inner node as a leaf’s fields, so a shorter proof reaches the root.
Double-hashed leaf A leaf computed as keccak256(bytes.concat(keccak256(abi.encode(...)))), the format of StandardMerkleTree; it is never the hash of 64 bytes.
abi.encodePacked Solidity’s non-padded encoding; dynamic values carry no length, so two of them side by side can collide.
Multiproof A proof for several leaves at once, made of sibling hashes and a boolean flag per hashing step.
Empty multiproof A multiproof with no leaves and a proof of one item, which OpenZeppelin treats as valid and returns proof[0].
Claim record The bitmap or mapping that marks an allocation as paid.
Epoch or window A counter that separates distributions; a claim record keyed by it starts empty for each new value.
Root setter Any function that writes the stored root, reached directly or through a router, a multicall or an upgrade.
Cumulative allocation A leaf that states the total earned so far, with the contract paying the difference from what was already claimed.
IAVL proof The proof format of Cosmos SDK’s IAVL tree; its path nodes carry left and right hashes that must enter the root computation.

Security Implementation Checklist

The checklist applies to any contract that pays or authorises on a Merkle proof: airdrops, allowlists, reward distributors and bridge message roots.

Leaf format

A leaf that can be mistaken for another value, or that omits a fact the payment depends on, lets a valid proof authorise something the tree’s author never listed.

Check Security requirement Failure mode if violated
☐ Leaves are not one Keccak-256 hash of exactly 64 bytes: hash twice, or encode more than two words. An inner node is accepted as a leaf with a shorter proof.
☐ No abi.encodePacked with two or more dynamic values; prefer abi.encode. Two different argument sets give the same leaf.
☐ The leaf names the account, and the contract pays that account. Anyone holding the public proof claims, or redirects, the allocation.
☐ The leaf commits to the chain id, the paying contract and the window or epoch when the root can exist in more than one place. One root is replayed on another chain, contract or round.
☐ Any index used as the claim key is part of the leaf. One leaf is claimed once per index.

Verifier

These rows cover what the proof library accepts beyond ordinary inclusion.

Check Security requirement Failure mode if violated
☐ Multiproof callers reject an empty leaves array unless an empty batch is harmless. The call verifies with no leaf and any side effect of “true” runs.
☐ The OpenZeppelin version is read from the lockfile or submodule; multiproofs on 4.7.0 to 4.9.1 are flagged. Forged multiproofs pass for trees with a zero node at depth 1 (GHSA-wprv-93r4-jj2p).
☐ Every field of a structured proof node enters the hash compared with the root. A field the verifier ignores carries forged data (BNB Chain bridge, 2022).

Claim records and roots

A correct proof check is undone when the record of past claims or the root itself can change underneath it.

Check Security requirement Failure mode if violated
☐ The claim is recorded before the payment, on every claim path (single, batch, relayed). Reentrancy or an unguarded path pays twice.
☐ A root update cannot make an allocation claimable under two records; claims are closed while the root changes. A re-listed user claims under the old and the new root.
☐ Cumulative records persist across roots and only increase. A new root with a lower total underflows or pays again.
☐ The zero root and any default value are rejected wherever a root is trusted. Unproven entries map to the default root and count as proven.
☐ Every path to the root setter is authorised, including routers, multicall and upgrades, with a delay where users need time to react. Anyone sets a root that pays them.

Timeline

Events up to 2 December 2026.

Date Event Why it matters here Source
11 May 2022 OpenZeppelin publishes the UMA Across V2 audit with “Slow relays on multiple chains” as critical Case 4: a root shared by every chain with no chain id in the leaf OpenZeppelin
29 June 2022 OpenZeppelin Contracts 4.7.0 adds multiProofVerify Start of the affected range of case 7 CHANGELOG
1 August 2022 Nomad bridge drained after an upgrade set the trusted root to 0x00 Case 9: the default root counted as confirmed Elliptic, Mandiant
7 October 2022 BNB Chain bridge loses 2,000,000 BNB through a forged IAVL proof A proof field that never entered the hash Immunefi
16 June 2023 OpenZeppelin Contracts 4.9.2 fixes the multiproof bug End of the affected range of case 7 CHANGELOG
19 June 2023 GHSA-wprv-93r4-jj2p (CVE-2023-34459) published The advisory text quoted in case 7 GitHub Advisory
17 October 2024 OpenZeppelin Contracts 5.1.0 adds MerkleProof variants with custom hash functions Trees built with another hash need the matching variant CHANGELOG
December 2025 Pashov Audit Group reports AmpleEarn C-01, an unauthorised root setter through a router Case 9: the setter half Pashov audits

Frequently Asked Questions

Q: Why does hashing a leaf twice stop the 64-byte attack?

The attack needs a leaf computed as the hash of the same 64 bytes that form an inner node. With a double hash, the leaf is keccak256 of a 32-byte value, the inner hash of the encoding. An attacker who passes the two children of an inner node gets keccak256(keccak256(children)), which is not the inner node, and the proof fails.

Q: Is abi.encodePacked(account, amount) a problem?

No. An address takes exactly 20 bytes and a uint256 exactly 32, so the boundary between them is fixed and two different pairs cannot give the same bytes. The ambiguity needs at least two values whose length varies (strings, bytes, dynamic arrays). The pair is still 52 bytes, not 64, so the second-preimage condition of case 1 does not apply either.

Q: A proof verifies against the root. Why can the contract not trust the leaf’s position?

OpenZeppelin’s MerkleProof sorts each pair before hashing, so swapping two siblings does not change the root. The proof contains the siblings but not whether each was on the left or the right, so it proves that the leaf is in the tree and nothing about where. Any positional fact the contract needs, such as an index used as the claim key, has to be inside the leaf.

Q: A project uses OpenZeppelin 4.8 and only calls MerkleProof.verify. Is it affected by GHSA-wprv-93r4-jj2p?

No. The advisory covers the multiproof functions only. It names them verifyMultiProof and verifyMultiProofCalldata; in the library they are multiProofVerify and multiProofVerifyCalldata, together with processMultiProof and processMultiProofCalldata. Single-leaf verification walks the proof in order and never reads an unwritten array entry. Even with multiproofs, the bug needs a tree with a zero node just under the root, which a tree with hashed leaves does not have unless its builder is malicious.

Q: Which of the nine cases would still exist with a perfect proof library?

All of them except case 7:

  • Cases 1 to 5 depend on what the contract puts in the leaf.
  • Case 6 is documented library behaviour that the caller has to handle.
  • Case 8 is the contract’s claim record.
  • Case 9 is the contract’s root management.

The library checks that a leaf hashes up to a root; the meaning of the leaf, the record of what was paid and the authority over the root are the contract’s.

Q: How does a review check that a root update does not reopen claims?

List the allocations that appear in both the old and the new root, and follow one of them through the update:

  • Is the claim record keyed by something that changes with the root (an epoch, a window, the root itself)?
  • Can the user claim between the moment the update is decided and the moment it takes effect, as with KarmaAirdrop’s unguarded claim during the pause?
  • For cumulative allocations, does the record persist and only grow?

A per-window record is fine when each window is a separate distribution with its own funds; it is a bug when the same allocation is carried into the new window.

Gaps

The sources leave the following points open.

Gap Why it matters What to read or verify
KarmaAirdrop and Nomad are tested through reduced models, not their deployed code. A detail of the real contracts (other guards, legacy paths) may change how the bug is reached. The reproduction in evm-hack-registry entry 65323 and Nomad’s Replica.sol at the upgraded commit.
The Cyfrin report on KarmaAirdrop and its date were not read; the finding is known from the registry’s reproduction and its comments. The timeline has no row for it. Cyfrin’s Status Network report and the fix commit ebbf84b in the status-network-monorepo repository.
The AmpleEarn finding is summarised from the registry entry, not reproduced in this article’s tests. The router and the other call paths of the real vault are not checked here. Pashov Audit Group, AmpleEarn review, finding C-01.
The address padding argument in case 1 (96 leading zero bits) is derived, not tested. It decides whether a leaf (address, uint256) hashed once is exploitable in practice. A test that searches for an inner node with a zero-prefixed child, or a cost estimate.
The packed-encoding rule is stated from the Solidity encoding itself, not from a stored copy of the documentation. Wording and edge cases (arrays of short types are padded) may differ. Solidity documentation, non-standard packed mode.
The BNB Chain bridge case is described from Immunefi’s analysis; the Go code of the vulnerable and patched verifier was not read. The exact check added by the patch is not quoted. bnb-chain/bsc v1.1.14 (vulnerable) and v1.1.16 (urgent patch), core/vm/lightclient/multistoreproof.go, and the iavl version named in their go.mod.
Only OpenZeppelin’s MerkleProof is tested. Solady, Murky or hand-written verifiers handle empty multiproofs and leaf formats differently. The source of each library a project imports.

References

Analyzed source

Advisories, audits and incident analyses

Libraries and documentation

You might also enjoy