Executive brief
OpenZeppelin Contracts is a widely-used library providing cryptographic and access-control building blocks for blockchain applications. The MerkleProof multiproof verification functions contain a flaw that allows an attacker to forge valid proofs for arbitrary data in certain merkle trees, potentially enabling unauthorized claims or transactions in smart contracts that rely on this verification mechanism.
Technical details
The vulnerability exists in the verifyMultiProof, verifyMultiProofCalldata, processMultiProof, and processMultiProofCalldata functions when processing merkle trees that contain a node with value 0 at depth 1 (directly below the root). This allows an attacker to construct valid multiproofs for arbitrary leaf sets. The flaw is most likely to occur inadvertently in balanced trees with 3 or fewer unhashed leaves, or may be deliberately introduced by a malicious tree builder. Single-leaf proof functions and multiproofs using hashed leaves are not affected. The vulnerability was patched in version 4.9.2; affected versions include 4.7.0 through 4.9.1.
Affected products
- OpenZeppelin Contracts 4.7.0 to 4.9.1
- OpenZeppelin Contracts Upgradeable 4.7.0 to 4.9.1
Timeline
- 2023-06-16: disclosed: Advisory published on GitHub
- 2023-06-19: patched: Patch released in version 4.9.2