CVE-2024-27094: @openzeppelin/contracts OpenZeppelin Contracts Base64 Encoding May Vulnerability
MODERATECVE-2024-27094 is a MODERATE (CVSS 6.5) openzeppelin contracts base64 encoding may vulnerability (CWE-125: Out-of-bounds Read) affecting @openzeppelin/contracts libraries in the npm ecosystem. The issue involves openzeppelin contracts base64 encoding may read from potentially dirty memory. Remediation is available by upgrading affected packages to version 4.9.6, 5.0.2.
CVE-2024-27094 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H).
How to Fix CVE-2024-27094
To remediate this vulnerability, upgrade all affected @openzeppelin/contracts dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @openzeppelin/contracts@4.9.6
npm install @openzeppelin/contracts-upgradeable@5.0.2
npm install @openzeppelin/contracts@5.0.2
npm install @openzeppelin/contracts-upgradeable@4.9.6
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @openzeppelin/contracts
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-27094, inspect your project dependencies using npm:
npm ls @openzeppelin/contracts
Analyze the terminal output to locate any version of @openzeppelin/contracts in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.9.6), your application is affected.
Note: The npm ls @openzeppelin/contracts command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. In @openzeppelin/contracts, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-27094 Affected @openzeppelin/contracts Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@openzeppelin/contracts
|
npm |
≥ 4.5.0
< 4.9.6
|
4.9.6
|
|
@openzeppelin/contracts-upgradeable
|
npm |
≥ 5.0.0-rc.0
< 5.0.2
|
5.0.2
|
|
@openzeppelin/contracts
|
npm |
≥ 5.0.0-rc.0
< 5.0.2
|
5.0.2
|
|
@openzeppelin/contracts-upgradeable
|
npm |
≥ 4.5.0
< 4.9.6
|
4.9.6
|
References
Frequently Asked Questions
What is CVE-2024-27094?
Which @openzeppelin/contracts versions are affected?
What version fixes CVE-2024-27094?
Is @openzeppelin/contracts affected?
Is @openzeppelin/contracts-upgradeable affected?
What is the CVSS score of CVE-2024-27094?
What CWE is associated with CVE-2024-27094?
How can I check npm dependencies for CVE-2024-27094?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-9vx6-7xxf-x967",
"modified" : "2025-12-04T22:49:19Z",
"published" : "2024-02-29T20:09:53Z",
"aliases" : [ "CVE-2024-27094" ],
"summary" : "OpenZeppelin Contracts base64 encoding may read from potentially dirty memory",
"details" : "### Impact\n\nThe `Base64.encode` function encodes a `bytes` input by iterating over it in chunks of 3 bytes. When this input is not a multiple of 3, the last iteration may read parts of the memory that are beyond the input buffer.\n\nAlthough the `encode` function pads the output for these cases, up to 4 bits of data are kept between the encoding and padding, corrupting the output if these bits were dirty (i.e. memory after the input is not 0). These conditions are more frequent in the following scenarios:\n\n- A `bytes memory` struct is allocated just after the input and the first bytes of it are non-zero.\n- The memory pointer is set to a non-empty memory location before allocating the input.\n\nDevelopers should evaluate whether the extra bits can be maliciously manipulated by an attacker.\n\n### Patches\n\nUpgrade to 5.0.2 or 4.9.6.\n\n### References\n\nThis issue was reported by the Independent Security Researcher Riley Holterhus through Immunefi (@rileyholterhus on X)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@openzeppelin/contracts"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.5.0"
}, {
"fixed" : "4.9.6"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@openzeppelin/contracts-upgradeable"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0-rc.0"
}, {
"fixed" : "5.0.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@openzeppelin/contracts"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0-rc.0"
}, {
"fixed" : "5.0.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@openzeppelin/contracts-upgradeable"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.5.0"
}, {
"fixed" : "4.9.6"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-9vx6-7xxf-x967"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-27094"
}, {
"type" : "WEB",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/2d081f24cac1a867f6f73d512f2022e1fa987854"
}, {
"type" : "WEB",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/723f8cab09cdae1aca9ec9cc1cfa040c2d4b06c1"
}, {
"type" : "WEB",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts/commit/92224533b1263772b0774eec3134e132a3d7b2a6"
}, {
"type" : "WEB",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts/commit/a6286d0fded8771b3a645e5813e51993c490399c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/OpenZeppelin/openzeppelin-contracts"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-125" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-02-29T20:09:53Z",
"nvd_published_at" : "2024-03-21T02:52:18Z"
}
}