6.5medium
OpenZeppelin Contracts base64 encoding may read from potentially dirty memory
- Severity
- 6.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.76% (higher than 56% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-9vx6-7xxf-x967
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| OpenZeppelin openzeppelin-contracts | >= 4.5.0, < 4.9.6, >= 5.0.0-rc.0, < 5.0.2 | CVE List |
| @openzeppelin/contracts (npm) | from 4.5.0 before 4.9.6, from 5.0.0-rc.0 before 5.0.2 | GitHub Advisory Database |
| @openzeppelin/contracts-upgradeable (npm) | from 5.0.0-rc.0 before 5.0.2, from 4.5.0 before 4.9.6 | GitHub Advisory Database |
| openzeppelin contracts | from 4.5.0 before 4.9.6, from 5.0.0 before 5.0.2 | NVD |
| openzeppelin contracts_upgradeable | from 4.5.0 up to 4.9.6, from 5.0.0 before 5.0.2 | NVD |
All scores
| GitHub_M | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H |
| GitHub | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H |
| NVD | 7.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:H |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
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.
GitHub Advisory Database
Impact
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.
Although 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:
- A
bytes memorystruct is allocated just after the input and the first bytes of it are non-zero. - The memory pointer is set to a non-empty memory location before allocating the input.
Developers should evaluate whether the extra bits can be maliciously manipulated by an attacker.
Patches
Upgrade to 5.0.2 or 4.9.6.
References
This issue was reported by the Independent Security Researcher Riley Holterhus through Immunefi (@rileyholterhus on X)
NVD (es)
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.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-27094 changed 2024-08-02 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-9vx6-7xxf-x967 changed 2025-12-05 | CC-BY-4.0 |
| NVD | CVE-2024-27094 changed 2026-06-17 | Public domain |