CVE-2026-54502

Oj: Stack Buffer Overflow in Oj.dump via Large Indent

Published Jun 30, 2026 CVSS 4.0 · 6.3 Medium 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.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.

Analysis

AI-generated

Technical impact

The vulnerability exists in the Oj (Optimized JSON) Ruby gem. When Oj.dump is called with a :indent option that is extremely large, the library writes that many spaces into a 4,184‑byte stack buffer using memset, which results in a stack-based buffer overflow. The overflow corrupts the stack and causes the process to crash, yielding only a denial of service. The flaw does not provide a path to arbitrary code execution, consistent with its CWE‑121 classification.

Affected Systems

The defect affects the ohler55 Oj Ruby gem in all versions prior to 3.17.2. Any Ruby application that incorporates this gem and calls Oj.dump with a large :indent value, such as the maximum INT_MAX (2,147,483,647), is vulnerable. The issue was remediated in version 3.17.2 and later.

Risk and Exploitability

The CVSS score of 6.3 indicates moderate severity. EPSS is not available, so the real‑world exploitation probability is unknown, and the vulnerability is not listed in CISA KEV. The most likely attack vector is a developer or application that supplies a large :indent value, for example through configuration or an API endpoint. An attacker who can influence the value could trigger a crash, causing a denial of Service. No documented exploit leads to code execution.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the Oj gem to version 3.17.2 or newer.
  • If an immediate upgrade is not possible, restrict the :indent parameter to a reasonable upper bound (e.g., 100) before invoking Oj.dump.
  • Implement input validation to ensure any supplied :indent value does not exceed the size of the internal buffer during marshalling.

Generated by OpenCVE AI on July 1, 2026 at 13:16 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-3v45-f3vh-wg7m Oj: Stack Buffer Overflow in Oj.dump via Large Indent
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'total'}, '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.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.
Title Oj: Stack Buffer Overflow in Oj.dump via Large Indent
Weaknesses CWE-121
References
Metrics cvssV4_0

{'score': 6.3, 'vector': 'CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N'}

Weaknesses
  • CWE-121

    Stack-based Buffer Overflow

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 1, 2026, 3:50 PM
Reserved
Jun 15, 2026, 6:01 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:10 PM