<?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 - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/vendors/oj/</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/vendors/oj/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><item><title>Oj: Use-After-Free in Oj::Doc Iterators via Reentrant Close</title><link>https://feed.craftedsignal.io/briefs/2026-06-oj-use-after-free/</link><pubDate>Fri, 19 Jun 2026 19:56:18 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-06-oj-use-after-free/</guid><description>A heap use-after-free vulnerability (CVE-2026-54897) exists in `Oj::Doc` iterators (`each_value`, `each_child`, `each_leaf`) in the `oj` Ruby gem, allowing an attacker to cause application crashes or unpredictable behavior when a Ruby block yielded during iteration reentrantly calls `doc.close` or `d.close`.</description><content:encoded><![CDATA[<p>A critical heap use-after-free vulnerability, identified as CVE-2026-54897, affects the <code>Oj::Doc</code> iterators within the <code>oj</code> Ruby gem. Specifically, the <code>each_value</code>, <code>each_child</code>, and <code>each_leaf</code> methods are vulnerable. The issue arises when a Ruby block, executed during the iteration process, makes a reentrant call to <code>doc.close</code> or <code>d.close</code> on the document or one of its child nodes. This premature closing operation frees the associated heap memory while the underlying C iterator in <code>ext/oj/fast.c</code> is still active. Upon returning from the Ruby block, the C code attempts to access memory that has already been deallocated, leading to a use-after-free condition. This vulnerability, present in all <code>oj</code> gem versions utilizing <code>ext/oj/fast.c</code> (confirmed up to v3.17.1), can be triggered from pure Ruby code and results in application instability, crashes, or potential arbitrary code execution. Organizations running Ruby applications that parse JSON via the <code>oj</code> gem are at risk.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>A Ruby application integrates and uses the <code>oj</code> gem for JSON data processing.</li>
<li>The application opens a JSON document for parsing using the <code>Oj::Doc.open</code> method.</li>
<li>The application initiates an iteration over the document's elements using a vulnerable iterator method such as <code>each_value</code>, <code>each_child</code>, or <code>each_leaf</code>, providing a Ruby block for processing.</li>
<li>During the execution of the yielded Ruby block, a call is inadvertently made to <code>doc.close</code> or <code>d.close</code> on the <code>Oj::Doc</code> instance or one of its child nodes.</li>
<li>This <code>close</code> operation triggers the <code>ruby_sized_xfree</code> function within the <code>ext/oj/fast.c</code> source, leading to the premature deallocation of the underlying heap memory buffer associated with the <code>Oj::Doc</code> object.</li>
<li>Control returns from the Ruby block to the original C iterator function in <code>ext/oj/fast.c</code> (e.g., <code>doc_each_child</code>).</li>
<li>The C iterator attempts to access or dereference pointers (like <code>cur-&gt;next</code>) that point to the heap memory region which was previously freed in step 5.</li>
<li>This access to deallocated memory results in a use-after-free condition, manifesting as application crashes, segmentation faults, or unpredictable program behavior.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The primary impact of CVE-2026-54897 is application instability and denial-of-service via crashing. Applications utilizing the vulnerable <code>oj</code> gem can be forced to terminate unexpectedly, leading to service disruption. Depending on the memory layout and the specific memory contents at the time of the use-after-free, this vulnerability could potentially be exploited for arbitrary code execution, though this has not been specifically detailed in the advisory. This could compromise the integrity and confidentiality of data processed by the Ruby application. Any Ruby application that handles untrusted JSON input and uses the vulnerable <code>oj</code> gem iterations is at risk.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade the <code>oj</code> gem to version 3.17.2 or later immediately to patch CVE-2026-54897.</li>
<li>Review application code for instances where <code>doc.close</code> or <code>d.close</code> might be called reentrantly within <code>Oj::Doc</code> iterator blocks, as described in the overview.</li>
<li>Deploy the <code>Detects Ruby Process Access Violation (Windows)</code> Sigma rule to monitor for unusual crashes in Ruby applications.</li>
<li>Deploy the <code>Detects Ruby Process Segmentation Fault (Linux)</code> Sigma rule to monitor for crashes in Ruby applications on Linux systems.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>ruby</category><category>use-after-free</category><category>library-vulnerability</category><category>dos</category></item></channel></rss>