CVE-2026-54897

Oj : Use-After-Free in Oj::Doc Iterators via Reentrant Close

Published Jun 30, 2026 CVSS 4.0 · 2.1 Low EPSS < 1% KEV · Not listed
Description
Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. Prior to 3.17.2, Oj::Doc iterators (each_value, each_child, each_leaf) were vulnerable to a heap use-after-free. When a Ruby block yielded during iteration calls doc.close or d.close, the document's heap memory is freed while the C iterator is still running. When control returns from the block, the iterator reads from the freed region, producing a use-after-free accessible from pure Ruby. This issue has been fixed in version 3.17.2.

Analysis

AI-generated

Technical impact

Oj is a Ruby gem that parses JSON. Prior to version 3.17.2, its iterators (each_value, each_child, each_leaf) contain a heap use-after-free. When a Ruby block yields during iteration calls doc.close or d.close, the document's heap memory is freed while the C iterator continues, causing a use-after-free that can be triggered from pure Ruby. This use-after-free aligns with CWE-416 and involves reentrant memory access (CWE-364).

Affected Systems

The affected product is the Oj Ruby gem, versions older than 3.17.2, developed by the vendor ohler55.

Risk and Exploitability

The CVSS score of 2.1 is low, and the EPSS score of less than 1% indicates a very low probability of exploitation. The flaw is not listed in CISA’s KEV catalog. Exploitation requires invoking doc.close or d.close during an iterating block, which is observable from Ruby code. No public exploits are documented in the provided references.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the Oj Ruby gem to version 3.17.2 or newer to eliminate the vulnerability.
  • Refactor any iterator blocks that invoke doc.close or d.close; remove such calls or guard against them.
  • Verify that your application does not call doc.close or d.close within iterator blocks when processing JSON, particularly untrusted data.

Generated by OpenCVE AI on July 31, 2026 at 15:44 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4803-1 ruby-oj security update
Debian DSA Debian DSA DSA-6521-1 ruby-oj security update
Github GHSA Github GHSA GHSA-9ppp-w3g4-fh4q Oj: Use-After-Free in Oj::Doc Iterators via Reentrant Close
History
Type Values Removed Values Added
Weaknesses CWE-364
References
Metrics threat_severity

None

cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'}

threat_severity

Important

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Ohler
Ohler oj
Ohler55
Ohler55 oj
Vendors & Products Ohler
Ohler oj
Ohler55
Ohler55 oj
Type Values Removed Values Added
Description Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. Prior to 3.17.2, Oj::Doc iterators (each_value, each_child, each_leaf) were vulnerable to a heap use-after-free. When a Ruby block yielded during iteration calls doc.close or d.close, the document's heap memory is freed while the C iterator is still running. When control returns from the block, the iterator reads from the freed region, producing a use-after-free accessible from pure Ruby. This issue has been fixed in version 3.17.2.
Title Oj : Use-After-Free in Oj::Doc Iterators via Reentrant Close
Weaknesses CWE-416
References
Metrics cvssV4_0

{'score': 2.1, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N'}

Weaknesses

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 1, 2026, 12:43 PM
Reserved
Jun 16, 2026, 1:49 PM
Status
Deferred
Published
Jul 1, 2026, 12:16 AM
Modified
Oct 25, 2026, 5:10 PM
Severity
Important
Public date
Jun 30, 2026, 11:22 PM