CVE-2026-54502 Oj: Stack Buffer Overflow in Oj.dump via Large Indent
A stack buffer overflow in the Oj Ruby gem allows attackers to crash the application or potentially execute code by providing a large indent value.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2026-54502?
CVE-2026-54502 is a medium-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.2, Oj.dump is vulnerable to a stack-based buffer overflow when a large :indent value is provided by the developer. fill_indent in dump.h calls memset(indent_str, ' ', (size_t)opts->indent) without validating the size. When opts->indent is set to INT_MAX (2,147,483,647), the (size_t) cast preserves the large value and memset writes 2 GB into the stack-allocated out buffer (4,184 bytes), corrupting the stack and crashing the process. This issue has been fixed in version 3.17.2.
Weakness: CWE-121
Which versions are affected by CVE-2026-54502?
2 open source packages ship an affected version, including oj.
| Package | Affected | Fixed in |
|---|---|---|
oj RubyGems | All versions | 3.17.3 |
oj RubyGems | All versions | 3.17.3 |
How do I fix CVE-2026-54502?
Upgrade oj to 3.17.3 or later.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is CVE-2026-54502 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-54502 exists.
Sources
Also known as DEBIAN-CVE-2026-54502, GHSA-3v45-f3vh-wg7m, MINI-2cxv-gw8f-3fcm, MINI-3v85-84cm-wx44, MINI-5r28-9q5x-392r, MINI-666m-9j4r-68gx and 7 more.