CVE-2026-54592

CVE-2026-54592 is a high-severity out-of-bounds read vulnerability in oj (rubygems), affecting versions < 3.17.3. It is fixed in 3.17.3.

Check whether CVE-2026-54592 affects your applications

Kodem tells you whether this CVE is present, reachable, and actually executing in your application, so you know if it matters.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence. Only the CVEs that actually run in production.

Summary

Oj: Stack Buffer Overflow in Oj::Doc#each_child via Deeply Nested Input

Full technical description

Oj::Doc#each_child, when invoked recursively over a deeply nested JSON
document, overflows a fixed-size stack buffer and aborts the process. This is a
denial of service reachable from untrusted JSON.

Details

Two-step chain in ext/oj/fast.c:

  1. doc_each_child (~line 1501) increments doc->where past the
    where_path[MAX_STACK = 100] array with no bounds check, and never restores
    it (doc->where-- is missing). Calling each_child recursively from inside
    the yield block therefore drives doc->where beyond the array.

  2. On the next entry (~line 1478) the function copies the path into a
    stack-local buffer:

    Leaf  save_path[MAX_STACK];           // 800-byte stack buffer
    size_t wlen = doc->where - doc->where_path;
    if (0 < wlen) {
        memcpy(save_path, doc->where_path, sizeof(Leaf) * (wlen + 1));
    }
    

    When the previous recursive call left doc->where past where_path[100],
    wlen exceeds MAX_STACK and the memcpy overflows save_path on the C
    stack.

The Oj::Doc parser imposes no JSON nesting-depth limit (it relies on a
C-stack pressure check), so deeply nested attacker input reaches this path.

Proof of Concept

require 'oj'
depth = 200
payload = '[' * depth + '1' + ']' * depth
Oj::Doc.open(payload) do |doc|
  r = lambda { doc.each_child { |_| r.call } }
  r.call
end

Recursion depth <= 99 iterates normally; depth >= 101 aborts. lldb backtrace
on the affected build (ruby 3.3.8 / arm64-darwin24):

SIGABRT
#2 __abort
#3 __stack_chk_fail
#4 doc_each_child   (oj.bundle, fast.c)

Credit

Reported by Zac Wang (@7a6163).

Impact

Reliable denial of service: any endpoint that calls
Oj::Doc.open(untrusted) { |d| d.each_child ... } recursively can be crashed
with a small deeply-nested payload. On builds with a stack protector (the
default, -fstack-protector-strong) the canary aborts the process before the
saved return address is used. The Step-1 heap OOB writes into struct _doc
fields do occur, but are masked in practice because the Step-2 stack overflow
crashes first; turning them into anything beyond a crash has not been
demonstrated.

A read operation accesses a memory location beyond the intended buffer boundary. Typical impact: sensitive data disclosure or crash.

CVE-2026-54592 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.17.3); upgrading removes the vulnerable code path.

Affected versions

oj (< 3.17.3)

Security releases

oj → 3.17.3 (rubygems)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Fixed in 3.17.3: doc_each_child now bounds-checks before incrementing
doc->where (raising Oj::DepthError) and restores doc->where after the
loop, matching the existing each_leaf pattern. Verified on the fixed build:
depth >= 101 raises a clean Oj::DepthError instead of aborting.

Frequently Asked Questions

  1. What is CVE-2026-54592? CVE-2026-54592 is a high-severity out-of-bounds read vulnerability in oj (rubygems), affecting versions < 3.17.3. It is fixed in 3.17.3. A read operation accesses a memory location beyond the intended buffer boundary.
  2. How severe is CVE-2026-54592? CVE-2026-54592 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of oj are affected by CVE-2026-54592? oj (rubygems) versions < 3.17.3 is affected.
  4. Is there a fix for CVE-2026-54592? Yes. CVE-2026-54592 is fixed in 3.17.3. Upgrade to this version or later.
  5. Is CVE-2026-54592 exploitable, and should I be worried? Whether CVE-2026-54592 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-54592 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-54592? Upgrade oj to 3.17.3 or later.

Other vulnerabilities in oj

Stop the waste.
Protect your environment with Kodem.