CVE-2026-54902 Oj: Use-After-Free in Oj::Parser SAJ Long Key Callback

Medium 6.3 Published Updated

A use-after-free vulnerability in the Oj Ruby gem allows attackers to cause a crash or potentially execute code via crafted JSON input.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2026-54902?

CVE-2026-54902 is a medium-severity use after free vulnerability in ohler55 oj, published on 30 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. Prior to version 3.17.2, is vulnerable to Use-After-Free when in SAJ mode. The Oj::Parser does not protect cached object keys (≥ 35 bytes) from garbage collection, and a Ruby callback that triggers GC inside hash_end can cause the key string to be reclaimed while the C parser still holds a pointer to it. The subsequent access to the freed string VALUE results in a segfault, confirmed by an RIP pointing to address 0x4242 (a canary-style pattern suggesting control over the freed memory's content). This issue has been fixed in version 3.17.2.

Weakness: CWE-416

Which versions are affected by CVE-2026-54902?

2 open source packages ship an affected version, including oj.

PackageAffectedFixed in
oj RubyGemsAll versions3.17.3
oj RubyGemsAll versions3.17.3

How do I fix CVE-2026-54902?

Upgrade oj to 3.17.3 or later.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is CVE-2026-54902 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-54902 exists.

Sources

Also known as DEBIAN-CVE-2026-54902, GHSA-m578-w5vf-rfcm, MINI-85hx-8hpm-hp6m, MINI-9f9x-frrg-qgrc, MINI-c47c-825h-73fp, MINI-chh4-pfv9-c7qx and 8 more.

Is CVE-2026-54902 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free