Out-of-bounds read in openzeppelin-contracts
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- —
- Confidentiality · integrity · availability
- None · Low · Low
- Fix status
- Fixed
Attack profile from CVSS 4.0 · CNA. Fix status from CNA and GitHub.
Summary
OpenZeppelin Contracts is a library for secure smart contract development. Starting in version 5.2.0 and prior to version 5.4.0, the `lastIndexOf(bytes,byte,uint256)` function of the `Bytes.sol` library may access uninitialized memory when the following two conditions hold: 1) the provided buffer length is empty (i.e. `buffer.length == 0`) and position is not `2**256 - 1` (i.e. `pos != type(uint256).max`). The `pos` argument could be used to access arbitrary data outside of the buffer bounds. This could lead to the operation running out of gas, or returning an invalid index (outside of the empty buffer). Processing this invalid result for accessing the `buffer` would cause a revert under normal conditions. When triggered, the function reads memory at offset `buffer + 0x20 + pos`. If memory at that location (outside the `buffer`) matches the search pattern, the function would return an out of bound index instead of the expected `type(uint256).max`. This creates unexpected behavior where callers receive a valid-looking index pointing outside buffer bounds. Subsequent memory accesses that don't check bounds and use the returned index must carefully review the potential impact depending on their setup. Code relying on this function returning `type(uint256).max` for empty buffers or using the returned index without bounds checking could exhibit undefined behavior. Users should upgrade to version 5.4.0 to receive a patch.
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Partial
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| OpenZeppelin | openzeppelin-contracts | 5.2.0 to before 5.4.0 | 5.4.0 | Patch available | CNA |
| — | @openzeppelin/contracts (npm) | 5.2.0 to before 5.4.0 | 5.4.0 | Patch available | GHSA-9rcw-c2f9-2j55 |
| — | @openzeppelin/contracts-upgradeable (npm) | 5.2.0 to before 5.4.0 | 5.4.0 | Patch available | GHSA-9rcw-c2f9-2j55 |
- openzeppelin-contracts VendorOpenZeppelin Affected 5.2.0 to before 5.4.0 Fixed in 5.4.0 Patch available CNA
- @openzeppelin/contracts (npm) Vendor— Affected 5.2.0 to before 5.4.0 Fixed in 5.4.0 Patch available GHSA-9rcw-c2f9-2j55
- @openzeppelin/contracts-upgradeable (npm) Vendor— Affected 5.2.0 to before 5.4.0 Fixed in 5.4.0 Patch available GHSA-9rcw-c2f9-2j55
Remediation
- Fix · CNA openzeppelin-contracts (OpenZeppelin) Fixed in 5.4.0
- Fix · GHSA-9rcw-c2f9-2j55 @openzeppelin/contracts (npm) Fixed in 5.4.0 Advisory →
- Fix · GHSA-9rcw-c2f9-2j55 @openzeppelin/contracts-upgradeable (npm) Fixed in 5.4.0 Advisory →
Timeline
- 2026-10-02 Threatist record created from CVE-2025-54070
- 2026-10-03 Alias added: GHSA-9rcw-c2f9-2j55
References
More OpenZeppelin vulnerabilities
- TI-2022-13196 OpenZeppelin Contracts for Cairo account cannot process transactions on Goerli CVSS 3.1MEDIUM 6.5
- TI-2021-16554 TimelockController vulnerability in OpenZeppelin Contracts CVSS 3.1CRITICAL 10.0
- TI-2021-16553 TimelockController vulnerability in OpenZeppelin Contracts CVSS 3.1CRITICAL 10.0
- TI-2021-18096 UUPSUpgradeable vulnerability in OpenZeppelin Contracts CVSS 3.1CRITICAL 9.8
- TI-2026-35496 Code injection in OpenZeppelin contracts-wizard CVSS 3.1HIGH 8.8
- TI-2022-13238 GovernorVotesQuorumFraction updates to quorum may affect past defeated proposals in @openzeppelin/contracts CVSS 3.1HIGH 7.5
Sources
- CVE-2025-54070 · CVE Program
- CVE-2025-54070 · NVD
- FIRST EPSS
- GHSA-9rcw-c2f9-2j55 · GitHub Advisory Database · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences