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.
Published: 2026-06-30
Score: 6.3 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

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.

Generated by OpenCVE AI on July 1, 2026 at 13:16 UTC.

Remediation

No vendor fix or workaround currently provided.

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
Github GHSA Github GHSA GHSA-3v45-f3vh-wg7m Oj: Stack Buffer Overflow in Oj.dump via Large Indent
History

Tue, 07 Jul 2026 12:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

threat_severity

Moderate


Wed, 01 Jul 2026 16:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'total'}, 'version': '2.0.3'}


Wed, 01 Jul 2026 10:30:00 +0000

Type Values Removed Values Added
First Time appeared Ohler
Ohler oj
Vendors & Products Ohler
Ohler oj

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.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'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-01T15:50:28.392Z

Reserved: 2026-06-15T18:01:15.512Z

Link: CVE-2026-54502

cve-icon Vulnrichment

Updated: 2026-07-01T15:50:11.147Z

cve-icon NVD

No data.

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-06-30T23:10:27Z

Links: CVE-2026-54502 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-07-01T13:30:15Z

Weaknesses
  • CWE-121

    Stack-based Buffer Overflow