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 is a Ruby gem that parses JSON and can marshal objects. In versions before 3.17.2, the C parser creates a raw const byte * pointer into the Ruby string buffer. If a SAJ or SAJ2 callback mutates the JSON string, for example by calling String#replace and increasing the string length, Ruby reallocates the buffer and frees the original memory. The parser's pointer becomes dangling, and the next byte read triggers a heap use‑after‑free. This memory corruption flaw (CWE‑416) and improper handling of mutated data (CWE‑825) can result in a crash and, in worst‑case, potentially allow exploitation of corrupted memory.

Affected Systems

The vulnerability affects the Ruby gem 'oj' produced by the vendor ohler55, specifically any version before 3.17.2. Any Ruby application that utilizes this gem and employs SAJ or SAJ2 callbacks that mutate JSON strings during parsing is susceptible.

Risk and Exploitability

The CVSS score of 2.1 indicates low severity. EPSS < 1% shows a very low probability of exploitation, and the vulnerability is not in the CISA KEV catalog. Exploitation requires an attacker that can supply specially crafted JSON to a Ruby process that uses a mutating SAJ/SAJ2 callback. The risk is primarily local to the application; it could cause a crash or destabilization but is unlikely to be used in widespread attacks. Therefore, the overall risk to affected users is modest.

Generated by OpenCVE AI on August 3, 2026 at 06:15 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the Oj gem to version 3.17.2 or newer.
  • Remove or disable any SAJ/SAJ2 callbacks that mutate JSON strings during parsing, or configure the parser to avoid such mutations.
  • Ensure all Ruby projects that depend on oj are updated to the patched version, including Gemfile updates and running bundle install to lock the dependency.

Generated by OpenCVE AI on August 3, 2026 at 06:15 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

Status : Deferred

Published: 2026-07-01T00:16:33.103

Modified: 2026-07-01T15:27:14.107

Link: CVE-2026-54898

cve-icon Redhat

Severity : Moderate

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

Links: CVE-2026-54898 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-08-03T06:30:17Z

Weaknesses