# CVE-2026-54592: Oj: Stack Buffer Overflow in Oj::Doc#each_child via Deeply Nested Input

> A stack buffer overflow in the Oj Ruby gem allows attackers to cause a denial of service via deeply nested JSON input.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 Jun 2026
- **Updated:** 1 Jul 2026
- **Also known as:** DEBIAN-CVE-2026-54592, GHSA-3m6q-jj5j-38c9, MINI-45mf-hr3r-4jqr, MINI-4jvm-38qx-qg9r, MINI-7vw4-xcwv-w6w3, MINI-cvr9-2qpm-8962, MINI-f263-2pw5-9m3v, MINI-h3fm-p5xg-fc98, MINI-mh65-r63g-hc9v, MINI-mpwj-qhc9-95v9, MINI-p33g-xwrf-pxj7, MINI-x649-frrp-vp25, UBUNTU-CVE-2026-54592

## What is CVE-2026-54592?

CVE-2026-54592 is a high-severity memory corruption vulnerability in ohler55 oj, published on 30 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-787 (Out-of-bounds Write), CWE-125 (Out-of-bounds Read)

## Which versions are affected by CVE-2026-54592?

2 open source packages ship an affected version, including oj.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `oj` | RubyGems | All versions | 3.17.3 |
| `oj` | RubyGems | All versions | 3.17.3 |

## How do I fix CVE-2026-54592?

Upgrade oj to 3.17.3 or later.

## Is CVE-2026-54592 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-54592 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-54592 and fix it if it is affected.

What it is: CVE-2026-54592 is a high-severity memory corruption vulnerability in ohler55 oj, published on 30 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-54592 exists.

Affected packages and fixed versions:
- oj (RubyGems): affected all versions; fixed in 3.17.3
- oj (RubyGems): affected all versions; fixed in 3.17.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-54592/ (Markdown: https://insights.sbomify.com/CVE-2026-54592/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-54592
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-54592
- OSV: https://osv.dev/vulnerability/CVE-2026-54592

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-54592/
Summaries are generated and may contain mistakes; the official description above is the record.
