CVE-2026-54902: ohler55 Oj use-after-free in Oj::Parser SAJ mode

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

The Oj library, a high-performance JSON parser for Ruby, contains a memory management flaw when processing specific types of data. An attacker could provide a specially crafted JSON file that causes the application to crash or potentially execute unauthorized code. This occurs because the library fails to properly protect certain data from being cleared by the system while it is still in use.

Technologies: oj (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-54902 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-54902 being exploited in the wild.
How severe is CVE-2026-54902?
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-54902?
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-54902 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-54902?
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 Use-After-Free (UAF) vulnerability exists in Oj::Parser when operating in SAJ mode. The C implementation fails to protect heap-allocated Ruby String objects used for long keys (≥ 35 bytes) from garbage collection (GC). If a Ruby callback (such as hash_end) triggers a GC cycle, the key string may be reclaimed while the C parser still maintains a pointer to it. Subsequent access to this dangling pointer results in a segmentation fault. Exploitation is possible if an attacker can control the content of the freed memory, as evidenced by the ability to influence the instruction pointer (RIP) during crashes. The issue is fixed in version 3.17.2.

Affected products

  • ohler55 oj < 3.17.2

Identifiers

  • CVE-2026-54902
  • GHSA-m578-w5vf-rfcm

Timeline

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

References

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