Skip to main content

Oj gem CVE-2026-54896

LOW
Heap-based Buffer Overflow (CWE-122)
2026-06-19 https://github.com/ohler55/oj GHSA-35w3-pjm6-wj95
2.1
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 Oj.dump endpoint exposing :indent
  2. Delivery
    Submit payload deserializing into Exception object
  3. Exploit
    Request serialization with indent: 5000
  4. Execution
    fill_indent writes past 13150-byte heap region
  5. Persist
    Adjacent heap corruption
  6. Impact
    Worker crash or memory corruption

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Heap 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

Exploitation requires three specific conditions all being true: (1) the application calls Oj.dump in :object mode (not :compat, :strict, or :rails mode), (2) the serialized value is or contains an Exception object so dump_obj_attrs is reached, and (3) the :indent option is set to an extreme value (the advisory demonstrates 5000) - either hard-coded or, more dangerously, derived from attacker-controlled input. Limiting factors: :indent is described by the maintainer as a developer-chosen option and is not typically exposed to end users, so attacker reach depends entirely on whether the application surfaces that parameter; default Oj.dump usage (small or zero indent) is not affected.

Impact

No CVSS, EPSS, or KEV signal is provided in the input, so prioritization rests on the description and CWE-122 classification. The trigger condition - Oj.dump called in :object mode against an Exception with indent: 5000 - is not a typical attacker-reachable surface: the advisory itself notes indent is a developer-controlled, non-public-facing option. Realistic impact is most plausibly memory corruption leading to process crash (DoS) on applications that mishandle the option; theoretical code-execution paths exist for any heap overflow but would require a target that exposes indent to untrusted input. Treat as a medium-priority library hygiene fix rather than an urgent internet-facing exposure, while still upgrading promptly because the Oj gem is widely deployed and dependency-pinned versions accumulate risk.

Exploit ScenarioDerived

An application using oj allows a user-tunable 'pretty print indent' field that is passed unchecked into Oj.dump in :object mode. An attacker submits a payload that causes an Exception to be serialized with indent set to a very large value, triggering the heap overflow and crashing the Ruby worker (denial of service), with theoretical potential for memory corruption depending on heap layout. No public exploit identified at time of analysis beyond the reproducer included in the advisory.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.1% exploitation probability (EPSS)

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

Alert me

AnalysisAIv1 – Jun 19, 2026

Heap buffer overflow in the Ruby Oj gem (versions before 3.17.3) occurs when Oj.dump serializes Exception objects in :object mode with an extreme :indent value. The pre-allocated output buffer does not account for indent padding bytes, allowing writes past the heap region and corrupting adjacent memory. No public exploit identified at time of analysis; the issue is triggered by developer-chosen serialization options rather than typical attacker-supplied input.

RemediationAI

Upgrade the oj gem to the vendor-released patch version 3.17.3 (per the package metadata in the GitHub advisory at https://github.com/ohler55/oj/security/advisories/GHSA-35w3-pjm6-wj95) by updating the Gemfile constraint and running bundle update oj, then redeploying. As a temporary mitigation until the upgrade is rolled out, audit application code that calls Oj.dump and remove or cap the :indent option (e.g., reject indent values above a small bound such as 16) and never expose the indent parameter to untrusted input, with the trade-off that pretty-printed JSON output for legitimate use will be less configurable. Do not switch away from :object mode purely as a workaround unless you understand the deserialization implications, since :object mode itself has separate security considerations.

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 popular high-performance Ruby JSON parser/serializer with a C extension (ext/oj). The flaw lives in ext/oj/dump.h's fill_indent helper, which performs memset(out->buf + out->cur, ' ', indent * depth) without verifying the destination buffer has room. Buffer sizing in dump_obj_attrs (dump_object.c) accounts for serialized attribute content but omits cumulative indent padding, so deeply nested Exception serialization with large indent multiplies past the allocation - the ASAN trace shows a 5000-byte write at the boundary of a 13150-byte region. This is a classic CWE-122 heap-based buffer overflow rooted in incorrect size calculation.

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 2.1 LOW
CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
vuln.today AI 3.0 LOW

Indent is a developer-controlled, non-public option so PR:H and AC:H; impact is realistically heap corruption causing crash, hence I:L/A:L and no confidentiality loss.

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

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

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

Attack Vector
Local
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
2.1 (LOW)

DescriptionCVE.org

Summary

Oj.dump in object mode is vulnerable to a heap buffer overflow when serializing Exception objects with a large :indent value. The serializer allocates a buffer sized for the object's attributes but does not account for the indent bytes added on each write. With indent: 5000, the accumulation of 5,000-byte indent strings overflows the 13,150-byte heap allocation, corrupting adjacent heap memory.

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 75-77:

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

When dumping an Exception object in :object mode, dump_obj_attrs calls fill_indent repeatedly for each attribute. The buffer is pre-allocated based on the serialized content but not the indentation overhead. With indent: 5000 the indent block for a nested object exceeds the remaining buffer space, producing a heap-buffer-overflow of size 5,000 at the end of the allocated region.

ASAN report:

==101656==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x527000022c5e
WRITE of size 5000 at 0x527000022c5e thread T0
    #0 memset
    #1 fill_indent       /ext/oj/dump.h:77
    #2 dump_obj_attrs    /ext/oj/dump_object.c:552
    #3 dump_obj          /ext/oj/dump_object.c:80
    #4 oj_dump_obj_val   /ext/oj/dump_object.c:708
    #5 oj_dump_obj_to_json_using_params  /ext/oj/dump.c:817
    #6 dump_body         /ext/oj/oj.c:1429
    #7 dump              /ext/oj/oj.c:1480
0x527000022c5e is located 0 bytes after 13150-byte region [0x52700001f900, 0x527000022c5e)

Reproduce

ruby
require "oj"
obj = Oj.load('{"^o":"RuntimeError"}', mode: :object)
Oj.dump(obj, mode: :object, indent: 5000)

Workarounds

This is at the discretion of the developer and not a public facing option so the workaround is 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 Ruby Oj JSON serialization library used in production services contains a memory corruption vulnerability (CVE-2026-54896) affecting versions before 3.17.3. Risk is contained to applications explicitly using specific serialization configurations, but exploitation could lead to system compromise. With no patch currently available, immediate workarounds and monitoring are required to protect Ruby-based production environments.

Business Impact: High
Compensating Controls

Disable Exception object serialization in :object mode; use alternative serialization modes (:compat or :json) if Exception serialization is required; validate and constrain :indent parameter values to prevent extreme values; restrict Oj serialization operations to trusted, internally-controlled data rather than arbitrary object inputs.

Threat Intelligence Overview

EPSS Score
0.1%
Top 98% exploitable
Threat Intel
1
1 source
Data Quality
4 sources
Confidence: Medium

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 LOW
CISA KEV No
Public POC No
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.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
Small
Automatable· derived
No
Human Impact
High

Priority Score

10
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +10
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 heap overflow occurs when a program writes data beyond the bounds of a buffer allocated in the heap memory region.

Affected Products (CPE)CVE.org

pkg:rubygems/oj

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