CVE-2025-54070: openzeppelin-contracts · Out-of-bounds Read
Affects openzeppelin-contractsSource CVE Database V5
Not known to be exploited · CVSS 6.9 Medium : upgrade to 5.4.0 when convenient.
Data as of 25 Oct 2026, 19:02 UTC
- EPSS
- 0.3% chance of exploitation in 30 days – higher than 33% of CVEsExploit Prediction Scoring System: the likelihood attackers will use this flaw soon.
- Patch
- Available – fixed in 5.4.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:NExploitation evidence
Disclosed: evidence found.
CVE published 17 Jul 2025
Detectable: no evidence on record.
No public nuclei template indexed
Weaponised: no evidence on record.
No public exploit code indexed in Metasploit or Exploit-DB
Exploited in the wildExploited: no evidence on record.
Not in CISA KEV and no source reports exploitation
Observed by OffSeq MirageSeen by Mirage: no evidence on record.
No attack traffic recorded by OffSeq Mirage sensors
A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 2026-10-25.
What to do
Upgrade openzeppelin/openzeppelin-contracts to 5.4.0.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
GitHubopenzeppelin/openzeppelin-contractspkg:github/openzeppelin/openzeppelin-contractsOther threats | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
AI-suggested
European organizations should immediately upgrade all instances of OpenZeppelin Contracts to version 5.4.0 or later to incorporate the official patch addressing this vulnerability. Beyond upgrading, developers must conduct thorough code reviews and audits of smart contracts that utilize the lastIndexOf function to ensure that returned indices are validated against buffer boundaries before any memory access. Implementing defensive programming practices such as explicit bounds checking and fail-safe error handling will mitigate risks of undefined behavior. Additionally, organizations should integrate static analysis tools specialized for smart contracts to detect unsafe memory access patterns. For deployed contracts that cannot be upgraded, consider deploying wrapper contracts or patches that validate inputs and outputs of vulnerable functions. Monitoring blockchain transactions for anomalous patterns targeting the affected function can provide early warning of exploitation attempts. Finally, educating development teams about secure smart contract coding standards and the importance of dependency management will reduce future vulnerabilities.
Description
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.