{"id":"CVE-2024-27094","aliases":["CVE-2024-27094","GHSA-9vx6-7xxf-x967"],"related":[],"kind":"vulnerability","state":"published","title":"OpenZeppelin Contracts base64 encoding may read from potentially dirty memory","summary":"OpenZeppelin Contracts is a library for secure smart contract development. The `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. The vulnerability is fixed in 5.0.2 and 4.9.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"OpenZeppelin Contracts is a library for secure smart contract development. The `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. The vulnerability is fixed in 5.0.2 and 4.9.6.","source":"cvelist"},{"lang":"en","text":"### 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)","format":"markdown","source":"ghsa"},{"lang":"es","text":"OpenZeppelin Contracts es una librería para el desarrollo seguro de contratos inteligentes. La función `Base64.encode` codifica una entrada de `bytes` iterándola en fragmentos de 3 bytes. Cuando esta entrada no es múltiplo de 3, la última iteración puede leer partes de la memoria que están más allá del búfer de entrada. La vulnerabilidad se solucionó en 5.0.2 y 4.9.6.","source":"nvd"}],"published":"2024-02-29T18:18:24.721Z","modified":"2026-06-17T07:19:09.020Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H","score":6.5,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H","score":6.5,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H","score":6.5,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:H","score":7.4,"rating":"HIGH"}],"cwes":["CWE-125"],"affected":[{"ranges":[{"version":">= 4.5.0, < 4.9.6","status":"affected"},{"version":">= 5.0.0-rc.0, < 5.0.2","status":"affected"}],"vendor":"OpenZeppelin","product":"openzeppelin-contracts","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"4.5.0","status":"affected","fixed":"4.9.6"}],"ecosystem":"npm","package":"@openzeppelin/contracts","purl":"pkg:npm/%40openzeppelin/contracts","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"5.0.0-rc.0","status":"affected","fixed":"5.0.2"}],"ecosystem":"npm","package":"@openzeppelin/contracts-upgradeable","purl":"pkg:npm/%40openzeppelin/contracts-upgradeable","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"5.0.0-rc.0","status":"affected","fixed":"5.0.2"}],"ecosystem":"npm","package":"@openzeppelin/contracts","purl":"pkg:npm/%40openzeppelin/contracts","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"4.5.0","status":"affected","fixed":"4.9.6"}],"ecosystem":"npm","package":"@openzeppelin/contracts-upgradeable","purl":"pkg:npm/%40openzeppelin/contracts-upgradeable","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"4.5.0","fixed":"4.9.6"},{"status":"affected","introduced":"5.0.0","fixed":"5.0.2"}],"vendor":"openzeppelin","product":"contracts","cpe":"cpe:2.3:a:openzeppelin:contracts:*:*:*:*:*:node.js:*:*","source":"nvd"},{"ranges":[{"status":"affected","introduced":"4.5.0","lastAffected":"4.9.6"},{"status":"affected","introduced":"5.0.0","fixed":"5.0.2"}],"vendor":"openzeppelin","product":"contracts_upgradeable","cpe":"cpe:2.3:a:openzeppelin:contracts_upgradeable:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-9vx6-7xxf-x967","tags":["vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/2d081f24cac1a867f6f73d512f2022e1fa987854","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/723f8cab09cdae1aca9ec9cc1cfa040c2d4b06c1","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts/commit/92224533b1263772b0774eec3134e132a3d7b2a6","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts/commit/a6286d0fded8771b3a645e5813e51993c490399c","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27094","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/OpenZeppelin/openzeppelin-contracts","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-08-02T19:34:52.561Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-27094","url":"https://www.cve.org/CVERecord?id=CVE-2024-27094","licence":"CVE Terms of Use","modified":"2024-08-02T19:35:12.184Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-9vx6-7xxf-x967","url":"https://github.com/advisories/GHSA-9vx6-7xxf-x967","licence":"CC-BY-4.0","modified":"2025-12-05T12:36:38.324Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-27094","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27094","licence":"Public domain","modified":"2026-06-17T07:19:09.020Z"}],"updatedAt":"2026-11-25T22:58:37.788Z","epss":{"score":0.00763,"percentile":0.56587,"date":"2026-12-01T12:00:22.000Z"}}