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.
Published: 2026-06-30
Score: 6.3 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

This vulnerability, present in Oj versions prior to 3.17.2, is a use‑after‑free flaw (CWE‑416) in the Oj JSON parser when operating in SAJ mode. The parser does not protect cached object keys that are 35 bytes or longer from garbage collection, and a Ruby callback that triggers GC during the hash_end phase can cause the key string to be reclaimed while the native C parser still holds a pointer to it. The subsequent access to the freed string results in a segmentation fault; the reference to the canary‑style pattern 0x4242 suggests that an attacker might be able to influence the contents of the freed memory, although the advisory does not confirm successful exploitation.

Affected Systems

The issue affects applications that use the ohler55:oj gem older than version  configured to use SAJ parsing with keys longer than 35 bytes. Any Ruby project that parses JSON through Oj 3.15.x or 3.16.x while processing long key strings in SAJ mode is vulnerable.

Risk and Exploitability

With a CVSS score of 6.3 the flaw is classified as moderate severity. EPSS data is not available and the vulnerability is not listed in CISA KEV, indicating no widespread exploitation has been observed. Exploitation requires control of the Ruby callback or the hash processing context to trigger garbage collection at the precise moment. Mitigated by a memory corruption that leads to a crash; while the advisory hints at possible arbitrary code execution through manipulation of the freed memory, this potential outcome is inferred from the description and not confirmed.

Generated by OpenCVE AI on July 1, 2026 at 13:14 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Oj gem to version 3.17.2 or later to apply the vendor‑issued fix.
  • Reconfigure Oj to disable SAJ mode, falling back to standard JSON parsing to eliminate the use‑after‑free path.
  • If an upgrade is not possible, avoid using keys longer than 35 characters in SAJ mode or enforce that Ruby callbacks do not trigger garbage collection during hash_end.

Generated by OpenCVE AI on July 1, 2026 at 13:14 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-m578-w5vf-rfcm Oj: Use-After-Free in Oj::Parser SAJ Long Key Callback
History

Tue, 07 Jul 2026 12:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

threat_severity

Moderate


Mon, 06 Jul 2026 23:15:00 +0000

Type Values Removed Values Added
First Time appeared Ohler
Ohler oj
Vendors & Products Ohler
Ohler oj

Wed, 01 Jul 2026 13:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Wed, 01 Jul 2026 00:15:00 +0000

Type Values Removed Values Added
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.
Title Oj: Use-After-Free in Oj::Parser SAJ Long Key Callback
Weaknesses CWE-416
References
Metrics cvssV4_0

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


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-01T12:37:40.878Z

Reserved: 2026-06-16T13:49:33.555Z

Link: CVE-2026-54902

cve-icon Vulnrichment

Updated: 2026-07-01T12:37:07.520Z

cve-icon NVD

No data.

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-06-30T23:40:32Z

Links: CVE-2026-54902 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-07-06T22:48:50Z

Weaknesses