Description
Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.2,Oj::Parser#parse is vulnerable to a heap use-after-free when a SAJ/SAJ2 callback mutates the input JSON string during parsing. The C engine holds a raw const byte * pointer into the Ruby string's internal buffer. If a callback (e.g. hash_start) resizes the string — for example by calling String#replace with a longer value — Ruby reallocates the string buffer and frees the old one. The C parser's pointer is left dangling; the next character read at parser.c:607 is a use-after-free. This issue has been fixed in version 3.17.2.
Published: 2026-06-30
Score: 2.1 Low
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

OJ (Optimized JSON) is a Ruby gem that parses JSON and provides object marshalling. In versions prior to 3.17.2, the C parser holds a raw const byte * pointer into a Ruby string. A SAJ/SAJ2 callback that mutates the JSON string, such as by calling String#replace with a longer value, triggers Ruby to reallocate and free the original buffer. The parser’s pointer remains dangling, and the next byte read triggers a heap use‑after‑free. This vulnerability is a memory corruption flaw (CWE‑416) and a data structure inconsistency (CWE‑825), and can lead to program crashes or potential exploitation.

Affected Systems

The vulnerability affects the Ruby gem ohler55:oj in all releases before 3.17.2. Any application that leverages Oj with SAJ or SAJ2 callbacks when parsing JSON is susceptible. The issue is fixed in version 3.17.2 and later, so updating the gem removes the vulnerability.

Risk and Exploitability

The EPSS score of < 1% indicates a very low probability of exploitation, and the CVE is not listed in CISA KEV. Exploitation requires a crafted JSON payload that triggers a mutating SAJ/SAJ2 callback, making the risk primarily application‑level. Attackers who control the input to Oj could trigger the use‑after‑free, which may cause a program crash. The low CVSS score and exploitation likelihood suggest that the overall risk to affected users is modest.

Generated by OpenCVE AI on July 21, 2026 at 15:16 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Oj gem to version 3.17.2 or later.
  • Modify application code to avoid mutating JSON strings during parsing with SAJ/SAJ2 callbacks, or configure the parser not to use such callbacks.
  • Ensure that any packages or applications that depend on Oj are also updated to version 3.17.2 or later, and update all dependencies accordingly.

Generated by OpenCVE AI on July 21, 2026 at 15:16 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-q2gm-54r6-8fwm Oj: Use-After-Free in Oj::Parser SAJ Callback via Input Mutation
History

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

Type Values Removed Values Added
Weaknesses CWE-825
References
Metrics threat_severity

None

cvssV3_1

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

threat_severity

Moderate


Wed, 01 Jul 2026 14: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 10:30:00 +0000

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

Tue, 30 Jun 2026 23:45:00 +0000

Type Values Removed Values Added
Description Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.2,Oj::Parser#parse is vulnerable to a heap use-after-free when a SAJ/SAJ2 callback mutates the input JSON string during parsing. The C engine holds a raw const byte * pointer into the Ruby string's internal buffer. If a callback (e.g. hash_start) resizes the string — for example by calling String#replace with a longer value — Ruby reallocates the string buffer and frees the old one. The C parser's pointer is left dangling; the next character read at parser.c:607 is a use-after-free. This issue has been fixed in version 3.17.2.
Title Oj: Use-After-Free in Oj::Parser SAJ Callback via Input Mutation
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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-01T13:36:50.924Z

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

Link: CVE-2026-54898

cve-icon Vulnrichment

Updated: 2026-07-01T13:36:22.111Z

cve-icon NVD

No data.

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-06-30T23:24:23Z

Links: CVE-2026-54898 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-07-21T15:30:07Z

Weaknesses