Skip to content

GHSA-wprv-93r4-jj2p CVE-2023-34459

OpenZeppelin Contracts using MerkleProof multiproofs may allow proving arbitrary leaves for specific trees

Medium npm
Severity
5.3 / 10
Medium · CVSS 3.1
Exploit chance (EPSS)
0.37%
Chance of exploitation in the next 30 days. Higher than 31.03% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-354 Improper Validation of Integrity Check Value
Fix
Available
2 packages have a fixed version

Description

Impact

When the verifyMultiProof, verifyMultiProofCalldata, processMultiProof, or processMultiProofCalldata functions are in use, it is possible to construct merkle trees that allow forging a valid multiproof for an arbitrary set of leaves.

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.

A contract is not vulnerable if it uses single-leaf proving (verify, verifyCalldata, processProof, or processProofCalldata), or if it uses multiproofs with a known tree that has hashed leaves. Standard merkle trees produced or validated with the @openzeppelin/merkle-tree library are safe.

Patches

The problem has been patched in 4.9.2.

Workarounds

If you are using multiproofs: When constructing merkle trees hash the leaves and do not insert empty nodes in your trees. Using the @openzeppelin/merkle-tree package eliminates this issue. Do not accept user-provided merkle roots without reconstructing at least the first level of the tree. Verify the merkle tree structure by reconstructing it from the leaves.

Affected versions

npm

PackageVulnerableFixed in
@openzeppelin/contracts
>= 4.7.0, < 4.9.2
4.9.2
@openzeppelin/contracts-upgradeable
>= 4.7.0, < 4.9.2
4.9.2

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

@openzeppelin/contracts npm → 4.9.2

npm
npm install @openzeppelin/contracts@4.9.2
yarn
yarn add @openzeppelin/contracts@4.9.2
pnpm
pnpm add @openzeppelin/contracts@4.9.2

@openzeppelin/contracts-upgradeable npm → 4.9.2

npm
npm install @openzeppelin/contracts-upgradeable@4.9.2
yarn
yarn add @openzeppelin/contracts-upgradeable@4.9.2
pnpm
pnpm add @openzeppelin/contracts-upgradeable@4.9.2

Severity breakdown

CVSS 3.1 5.3

CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:N

Attack vector
Network
Attack complexity
High
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

Weakness

CWE-354: Improper Validation of Integrity Check Value

The product does not validate or incorrectly validates the integrity check values or "checksums" of a message. This may prevent it from detecting if the data has been modified or corrupted in transmission.

How to prevent it
  • Implementation: Ensure that the checksums present in messages are properly checked in accordance with the protocol specification before they are parsed and used.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-9rcw-c2f9-2j55
OpenZeppelin Contracts Bytes's lastIndexOf function with position argument performs out-of-bound memory access on empty buffers
Medium Also affects @openzeppelin/contracts
GHSA-9vx6-7xxf-x967
OpenZeppelin Contracts base64 encoding may read from potentially dirty memory
High Also affects @openzeppelin/contracts
GHSA-699g-q6qh-q4v8
OpenZeppelin Contracts and Contracts Upgradeable duplicated execution of subcalls in v4.9.4
High Also affects @openzeppelin/contracts
GHSA-g4vp-m682-qqmp
OpenZeppelin Contracts vulnerable to Improper Escaping of Output
Medium Also affects @openzeppelin/contracts
GHSA-5h3x-9wvq-w4m2
OpenZeppelin Contracts's governor proposal creation may be blocked by frontrunning
Medium Also affects @openzeppelin/contracts
GHSA-mx2q-35m2-x2rh
OpenZeppelin Contracts TransparentUpgradeableProxy clashing selector calls may not be delegated
Medium Also affects @openzeppelin/contracts
GHSA-93hq-5wgc-jc82
GovernorCompatibilityBravo may trim proposal calldata
High Also affects @openzeppelin/contracts
GHSA-878m-3g6q-594q
OpenZeppelin Contracts contains Incorrect Calculation
Medium Also affects @openzeppelin/contracts
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor