CVE-2026-54897: ohler55 Oj heap use-after-free in Oj::Doc iterators

CVE-2026-54897 · Severity: high · CVSS 4 · Published 2026-07-01

Oj is a high-performance JSON processing library for the Ruby programming language. A flaw in how the library handles document iteration allows the underlying memory to be deleted while it is still being read. This can lead to application instability or crashes when processing specifically structured JSON data.

Technologies: oj (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-54897 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-54897 being exploited in the wild.
How severe is CVE-2026-54897?
High severity, with a CVSS score of 4, published 1 July 2026.
Which products and versions are affected?
oj (RubyGems) < 3.17.2, ECOSYSTEM:introduced=0,fixed=3.17.3.
Is there a fix for CVE-2026-54897?
Yes. oj (RubyGems): upgrade to 3.17.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-54897 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-54897?
Check whether you run oj (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • oj (RubyGems): upgrade to 3.17.3 or later
    bundle update oj

Technical details

A heap use-after-free vulnerability exists in the Oj::Doc iterators (each_value, each_child, and each_leaf) within ext/oj/fast.c. The issue occurs because rb_yield allows execution of arbitrary Ruby code during iteration; if the Ruby block calls doc.close or d.close, the document's backing heap memory is freed via ruby_sized_xfree. When control returns to the C iterator, it attempts to read the 'next' pointer from the now-freed memory region. This vulnerability is accessible from pure Ruby and has been addressed in version 3.17.2.

Affected products

  • ohler55 oj < 3.17.2

Identifiers

  • CVE-2026-54897
  • GHSA-9ppp-w3g4-fh4q

Timeline

  • 2026-06-16: advisory: GitHub Security Advisory published
  • 2026-06-30: disclosed: CVE published to NVD
  • 2026-07-01: other: Advisory updated

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.