<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Oj Gem - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/oj-gem/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata. Fed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Fri, 19 Jun 2026 19:57:25 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/oj-gem/feed.xml" rel="self" type="application/rss+xml"/><item><title>Heap Buffer Overflow in Oj.dump Exception Serialization via Large Indent (CVE-2026-54896)</title><link>https://feed.craftedsignal.io/briefs/2026-06-oj-heap-buffer-overflow/</link><pubDate>Fri, 19 Jun 2026 19:57:25 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-06-oj-heap-buffer-overflow/</guid><description>The `Oj.dump` function in the Ruby `oj` gem, when operating in object mode, is vulnerable to a heap buffer overflow (CVE-2026-54896) when serializing `Exception` objects with an excessively large `:indent` value, leading to memory corruption and potential denial of service or remote code execution.</description><content:encoded><![CDATA[<p>The <code>oj</code> Ruby gem, specifically its <code>Oj.dump</code> function in object serialization mode, is affected by a heap buffer overflow vulnerability, identified as CVE-2026-54896. This flaw impacts all versions of the gem that include the <code>ext/oj/dump.h</code> component, up to and including version 3.17.1. The vulnerability occurs when an application attempts to serialize an <code>Exception</code> object using <code>Oj.dump</code> with a particularly large <code>:indent</code> value (e.g., 5000). The underlying C implementation pre-allocates a buffer based on the object's attributes but fails to account for the substantial additional memory required by the indent string, leading to repeated writes beyond the buffer's boundary. This memory corruption can result in application crashes, denial of service, or potentially enable arbitrary code execution. Defenders should prioritize patching and validating <code>oj</code> gem versions in their Ruby applications.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li><strong>Initial Input</strong>: An attacker sends crafted JSON input to a vulnerable application that utilizes the <code>oj</code> gem.</li>
<li><strong>Object Deserialization</strong>: The application processes the attacker's input using <code>Oj.load</code> in object mode, which creates a Ruby <code>Exception</code> object (e.g., <code>RuntimeError</code>) from the JSON.</li>
<li><strong>Vulnerable Serialization Call</strong>: A legitimate application component subsequently attempts to serialize this <code>Exception</code> object back to JSON using <code>Oj.dump</code>, with an excessively large <code>:indent</code> value (e.g., 5000), which might be attacker-controlled or a misconfigured application setting.</li>
<li><strong>Insufficient Buffer Allocation</strong>: Internally, <code>Oj.dump</code> (specifically <code>dump_obj_attrs</code>) allocates a memory buffer for the serialization output, but this buffer's size is based on the object's attributes and does not adequately account for the combined size of the large indentation strings.</li>
<li><strong>Heap Buffer Overflow</strong>: The <code>fill_indent</code> function is repeatedly called during serialization to add indentation. When writing the large indent string (e.g., 5000 bytes) into the pre-allocated buffer, it exceeds the available space.</li>
<li><strong>Memory Corruption and Impact</strong>: This repeated out-of-bounds writing causes a heap buffer overflow, corrupting adjacent memory. This typically leads to a denial of service through an application crash or, in more advanced scenarios, could be leveraged for arbitrary code execution.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The primary impact of CVE-2026-54896 is memory corruption, leading to the affected Ruby application crashing and resulting in a denial of service. If an attacker can reliably control the execution flow after the overflow, it could potentially be escalated to remote code execution. Although no specific victim counts or targeted sectors have been disclosed, any Ruby application utilizing the <code>oj</code> gem in a manner that deserializes untrusted input and subsequently reserializes <code>Exception</code> objects with large indent values is at risk.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li><strong>Patch CVE-2026-54896</strong>: Immediately upgrade the <code>oj</code> gem to version <code>3.17.2</code> or later to mitigate CVE-2026-54896.</li>
<li><strong>Implement Application-Level Controls</strong>: Developers should ensure that user-controlled input does not dictate the <code>:indent</code> parameter for <code>Oj.dump</code> calls and avoid using excessively large hardcoded indent values.</li>
<li><strong>Deploy Sigma Rules</strong>: Deploy the provided Sigma rules to your SIEM solution to detect abnormal <code>ruby</code> process terminations or crash dump creations, which may indicate exploitation attempts.</li>
<li><strong>Enable Process Monitoring</strong>: Ensure robust process creation and termination logging is enabled for Ruby applications (e.g., Sysmon on Windows, Auditd on Linux) to capture potential crash-related events.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>ruby</category><category>vulnerability</category><category>heap-overflow</category></item></channel></rss>