Skip to main content

Oj gem CVE-2026-54502

MEDIUM
Stack-based Buffer Overflow (CWE-121)
2026-06-19 https://github.com/ohler55/oj GHSA-3v45-f3vh-wg7m
6.3
CVSS 4.0 · Vendor: https://github.com/ohler55/oj
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify endpoint forwarding indent option
  2. Delivery
    Submit indent value INT_MAX
  3. Exploit
    Oj.dump invokes fill_indent
  4. Execution
    memset overruns stack 'out' buffer
  5. Persist
    Ruby worker process crashes
  6. Impact
    Denial of service

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Stack buffer bounds checking
MITRE ATT&CK

1 technique across 1 tactic: Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Triggering the bug requires the application to call Oj.dump with the :indent option set to an attacker-influenced or extremely large integer (the PoC uses 2_147_483_647); the value must originate from outside the codebase, because no Oj defaults or internal callers pass such a value. Limiting factors: the Oj gem must be loaded (native C extension build), the vulnerable :indent option must be reachable from untrusted input, and exploitation as demonstrated produces a process crash (DoS) rather than confirmed code execution. Default usage of Oj.dump without a developer-supplied extreme indent is not affected.

Impact

No CVSS vector (3.1 or 4.0), EPSS score, KEV status, or SSVC decision is provided in the input, so real-world risk must be inferred from the technical detail. The vulnerability requires the application to deliberately pass an extreme :indent value to Oj.dump - a configuration that no realistic application would use - so widespread remote exploitation is unlikely; the practical impact is denial of service via process crash when untrusted input reaches the indent parameter. While CWE-121 stack-overflow conditions can theoretically enable code execution, the ASAN report shows a deterministic 2 GB memset that will trip guard pages immediately, making weaponization beyond DoS difficult to demonstrate. Treat this as a low-to-medium priority hardening fix for gems that expose Oj.dump options to user input; no public exploit identified at time of analysis.

Exploit ScenarioDerived

An application accepts a user-supplied JSON formatting preference (for example, a pretty-print toggle that also passes a numeric indent width) and forwards that value into Oj.dump(obj, mode: :compat, indent: user_value). An attacker submits indent: 2147483647, fill_indent issues a multi-gigabyte memset against the 4 KB stack buffer, and the worker process crashes - repeated requests cause sustained denial of service. No publicly available exploit demonstrating code execution is identified at time of analysis.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.3% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 19, 2026

Stack-based buffer overflow in the Oj Ruby JSON gem (versions prior to 3.17.3) allows a developer-controlled large :indent value passed to Oj.dump to overwrite up to 2 GB of stack memory, crashing the Ruby process. The flaw is reachable only when application code forwards an untrusted or extreme indent value into Oj.dump, and no public exploit identified at time of analysis demonstrates code execution beyond denial of service.

RemediationAI

Vendor-released patch: upgrade the oj gem to version 3.17.3 or later (bundle update oj, then redeploy) as published in GHSA-3v45-f3vh-wg7m (https://github.com/ohler55/oj/security/advisories/GHSA-3v45-f3vh-wg7m). If immediate patching is not possible, audit application code for any call site that forwards user-controlled values into Oj.dump's :indent option and clamp the value to a small bound (for example, reject indents greater than 64) before invoking the serializer; this preserves indented output for legitimate values while preventing the overflow, at the cost of one extra validation check per call. Avoid exposing Oj dump options directly to API consumers or configuration files that untrusted parties can influence.

Affected Packages

rubygems oj fix: 3.17.3

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in rubygems

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Oj is a high-performance native C extension that serializes Ruby objects to JSON, distributed via RubyGems (pkg:rubygems/oj). The root cause is CWE-121 (Stack-based Buffer Overflow): in ext/oj/dump.h:77, fill_indent computes len = (size_t)(opts->indent * depth) and calls memset on a fixed-size stack buffer 'out' (4,184 bytes) without bounding opts->indent. Because the indent option is taken as a plain Ruby integer and stored in a C int without range validation, INT_MAX (2,147,483,647) survives the size_t cast and the subsequent multiplication by depth, allowing memset to write far past the stack frame allocated in dump() (oj.c:1453).

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/ohler55/oj) PRIMARY 6.3 MEDIUM
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
vuln.today AI 5.3 MEDIUM

Exploitation reaches Oj.dump via application input (AV:N, PR:N, UI:N) but requires the app to forward :indent unchanged, and demonstrated impact is a process crash only (A:L, C:N, I:N).

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
4.0 AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
Red Hat MEDIUM

Primary rating from Vendor (https://github.com/ohler55/oj).

CVSS VectorVendor: https://github.com/ohler55/oj

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
Present
Privileges Required
None
User Interaction
None
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

1
CVSS changed
Jul 01, 2026 - 00:22 NVD
6.3 (MEDIUM)

DescriptionCVE.org

Summary

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.

Version

  • Software: oj gem
  • Affected: all versions with ext/oj/dump.h
  • Latest tested: 3.17.1 (confirmed present)

Details

ext/oj/dump.h, line 77:

c
static void fill_indent(Out out, int depth) {
    if (0 < out->opts->indent) {
        size_t len = (size_t)(out->opts->indent * depth);
        // ...
        memset(out->buf + ..., ' ', len);  // len = 2147483647 * depth

The indent option is accepted as a plain Ruby integer and stored as int without range validation. Multiplying by depth can produce a value larger than any stack or heap buffer.

ASAN report:

==69820==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fd1fc201278
WRITE of size 2147483647 at 0x7fd1fc201278 thread T0
    #0 memset
    #1 fill_indent  /ext/oj/dump.h:77
    #2 dump_array   /ext/oj/dump_compat.c:165
    #3 oj_dump_obj_to_json_using_params  /ext/oj/dump.c:818
    #4 dump_body    /ext/oj/oj.c:1429
    #5 dump         /ext/oj/oj.c:1480
Address is in stack of thread T0 at offset 4728 in frame:
    #0 dump /ext/oj/oj.c:1453
  [544, 4728) 'out'  <== Memory access at offset 4728 overflows this variable

Reproduce

ruby
require "oj"
obj = [0]
Oj.dump(obj, mode: :compat, indent: 2_147_483_647)

Workaround

The develop should not use extreme indents and should not offer the option for users to dump Ruby data with unlimited indentation size.

Executive ViewAI

Why It Matters

The Oj Ruby JSON gem (versions prior to 3.17.3) is vulnerable to a stack buffer overflow that crashes Ruby processes when exposed to extreme indent parameter values, creating denial-of-service risk for production applications. Exposure is limited to applications that accept untrusted input for the indent parameter, but organizations must urgently identify these vulnerable systems before public exploit code emerges.

Business Impact: High
Compensating Controls

No vendor-released patch identified at time of analysis. Interim mitigations: (1) Input validation to restrict indent values to safe positive integers below 256; (2) Code refactoring to prevent untrusted input from reaching indent parameter; (3) Enhanced monitoring and alerting on unexpected Ruby process crashes; (4) Rate limiting on any API endpoints exposing indent control; (5) Process isolation and memory limits on Ruby application containers; (6) Regular code review and scanning for dangerous Oj.dump patterns accepting external input.

Threat Intelligence Overview

EPSS Score
0.3%
Top 83% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA Vendor GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.3%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
Yes
Human Impact
High

Priority Score

32
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +32
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

A buffer overflow occurs when a program writes more data to a memory buffer than it was allocated to hold, causing the excess data to spill into adjacent memory regions.

A stack-based buffer overflow occurs when a program writes more data to a buffer located on the stack than it was allocated to hold.

Affected Products (CPE)CVE.org

pkg:rubygems/oj

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy