CVE-2026-54898

Oj: Use-After-Free in Oj::Parser SAJ Callback via Input Mutation

Published Jun 30, 2026 CVSS 4.0 · 2.1 Low EPSS < 1% KEV · Not listed
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.

Analysis

AI-generated

Technical 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.

Remediation

No solution or workaround provided in the CVE record.

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
Debian DLA Debian DLA DLA-4803-1 ruby-oj security update
Debian DSA Debian DSA DSA-6521-1 ruby-oj security update
Github GHSA Github GHSA GHSA-q2gm-54r6-8fwm Oj: Use-After-Free in Oj::Parser SAJ Callback via Input Mutation
History
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

Type Values Removed Values Added
Metrics ssvc

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

Type Values Removed Values Added
First Time appeared Ohler
Ohler oj
Vendors & Products Ohler
Ohler oj
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'}

Weaknesses

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 1, 2026, 1:36 PM
Reserved
Jun 16, 2026, 1:49 PM
Status
Deferred
Published
Jul 1, 2026, 12:16 AM
Modified
Oct 25, 2026, 5:10 PM
Severity
Moderate
Public date
Jun 30, 2026, 11:24 PM