Description
Oj (Optimized JSON) is a JSON parser and Object marshaller packaged as a Ruby gem. In versions prior to 3.17.3, Oj::Doc#each_child, when invoked recursively over a deeply nested JSON document, overflows a fixed-size stack buffer and aborts the process, leading to DoS. In a two-step chain in ext/oj/fast.c, doc_each_child increments doc->where past the where_path[MAX_STACK = 100] array with no bounds check and never restores it (the doc->where-- is missing), so calling each_child recursively from inside the yield block drives doc->where beyond the array. On the next entry the function copies the path into the 800-byte stack-local buffer save_path[MAX_STACK] using wlen = doc->where - doc->where_path, so when the previous recursive call left doc->where past where_path[100] the wlen exceeds MAX_STACK and the memcpy overflows save_path on the C stack; because the Oj::Doc parser imposes no JSON nesting-depth limit (relying on a C-stack pressure check), deeply nested attacker input reaches this path. This issue has been fixed in version 3.17.3.
Published: 2026-06-30
Score: 7.5 High
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

In Oj (Optimized JSON), a stack buffer overflow occurs in the Oj::Doc#each_child method when parsing deeply nested JSON. The recursive call increments the internal pointer past the fixed‑size where_path array, and due to a missing decrement the pointer remains beyond the array bounds. When the parser later copies the path to an 800‑byte stack buffer, it overflows the stack because the length calculation exceeds the 100‑element limit. The resulting memory corruption causes an abort of the Ruby process, creating a denial of service. The weakness involves unchecked memory writes (CWE‑125) and malformed buffer handling (CWE‑787).

Affected Systems

The vulnerability affects the Oj (Optimized JSON) Ruby gem distributed by ohler55. Any installation of the gem with a version earlier than 3.17.3 is susceptible, as those releases lack the bounds fixes introduced in 3.17.3.

Risk and Exploitability

The CVSS score of 7.5 indicates a high severity; the EPSS value is not available, so exploit likelihood is uncertain, but the denial of service impact is tangible if an attacker can deliver nested JSON to the parser. The vulnerability is not listed in CISA’s KEV catalog. The likely attack vector is an input provider that supplies deeply nested JSON to the affected application, which can be local or from an external source depending on the context of the parser’s usage. By causing the parser to recurse beyond the maximum stack depth, an attacker can repeatedly crash the process, exhausting resources and forcing restarts.

Generated by OpenCVE AI on July 1, 2026 at 03:11 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Oj to version 3.17.3 or later
  • Avoid parsing untrusted JSON with older Oj releases
  • If upgrading is not immediately possible, limit the depth of JSON input or reject overly nested payloads before invoking the parser

Generated by OpenCVE AI on July 1, 2026 at 03:11 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-3m6q-jj5j-38c9 Oj: Stack Buffer Overflow in Oj::Doc#each_child via Deeply Nested Input
History

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.3, Oj::Doc#each_child, when invoked recursively over a deeply nested JSON document, overflows a fixed-size stack buffer and aborts the process, leading to DoS. In a two-step chain in ext/oj/fast.c, doc_each_child increments doc->where past the where_path[MAX_STACK = 100] array with no bounds check and never restores it (the doc->where-- is missing), so calling each_child recursively from inside the yield block drives doc->where beyond the array. On the next entry the function copies the path into the 800-byte stack-local buffer save_path[MAX_STACK] using wlen = doc->where - doc->where_path, so when the previous recursive call left doc->where past where_path[100] the wlen exceeds MAX_STACK and the memcpy overflows save_path on the C stack; because the Oj::Doc parser imposes no JSON nesting-depth limit (relying on a C-stack pressure check), deeply nested attacker input reaches this path. This issue has been fixed in version 3.17.3.
Title Oj: Stack Buffer Overflow in Oj::Doc#each_child via Deeply Nested Input
Weaknesses CWE-125
CWE-787
References
Metrics cvssV3_1

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


Subscriptions

No data.

cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-06-30T23:16:24.378Z

Reserved: 2026-06-15T19:45:23.539Z

Link: CVE-2026-54592

cve-icon Vulnrichment

No data.

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-01T03:15:15Z

Weaknesses