<?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 (&lt; 3.17.2) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/oj-gem--3.17.2/</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:56:18 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/oj-gem--3.17.2/feed.xml" rel="self" type="application/rss+xml"/><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><item><title>Stack Buffer Overflow in Oj Ruby Gem (CVE-2026-54502)</title><link>https://feed.craftedsignal.io/briefs/2026-06-stack-buffer-overflow-oj-gem/</link><pubDate>Fri, 19 Jun 2026 19:47:47 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-06-stack-buffer-overflow-oj-gem/</guid><description>The `Oj.dump` function in the `Oj` Ruby gem is vulnerable to a stack-based buffer overflow (CVE-2026-54502) due to improper validation of the `:indent` parameter, allowing an attacker to trigger a process crash or potentially remote code execution by providing an excessively large integer value, affecting all `Oj` gem versions prior to `3.17.2`.</description><content:encoded><![CDATA[<p>An attacker can exploit a critical stack-based buffer overflow vulnerability, identified as CVE-2026-54502, within the <code>Oj.dump</code> function of the <code>Oj</code> Ruby gem. This vulnerability affects all versions of the <code>Oj</code> gem prior to <code>3.17.2</code>. The flaw stems from insufficient input validation of the <code>:indent</code> parameter; when an application passes an extremely large integer value (such as <code>INT_MAX</code>, 2,147,483,647) to this parameter, the internal <code>fill_indent</code> function in <code>ext/oj/dump.h</code> calls <code>memset</code> without proper size checks. This leads to an attempt to write gigabytes of data into a small, stack-allocated buffer, corrupting the process's stack and resulting in an immediate denial of service through a crash. If exploited precisely, this could also enable remote code execution, posing a significant risk to the availability and integrity of Ruby applications using the vulnerable gem.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li><strong>Initial Access</strong>: An attacker identifies a Ruby application utilizing a vulnerable <code>Oj</code> gem version (prior to 3.17.2) and exposing a parameter or input field that directly or indirectly controls the <code>indent</code> argument for the <code>Oj.dump</code> function. This could be a web API endpoint, a file processing service, or another untrusted input vector.</li>
<li><strong>Input Provision</strong>: The attacker crafts a request (e.g., an HTTP GET/POST parameter, an API call payload, or a crafted data file) containing an excessively large integer value (such as <code>2,147,483,647</code> representing <code>INT_MAX</code>) for the <code>indent</code> parameter.</li>
<li><strong>Application Processing</strong>: The vulnerable Ruby application receives and processes this malicious input, passing the large integer value to the <code>Oj.dump</code> function's <code>indent</code> option without adequate validation.</li>
<li><strong>Vulnerable Function Call</strong>: Internally, <code>Oj.dump</code> invokes its C extension <code>fill_indent</code> function (located in <code>ext/oj/dump.h</code>), which receives the large <code>indent</code> value.</li>
<li><strong>Buffer Overflow</strong>: Within <code>fill_indent</code>, the <code>memset</code> function is called with the attacker-controlled large size, causing it to attempt to write gigabytes of data (<code>(size_t)opts-&gt;indent * depth</code>) into a much smaller, fixed-size stack-allocated <code>out</code> buffer (approximately 4KB).</li>
<li><strong>Stack Corruption and Crash</strong>: This massive write operation overflows the <code>out</code> buffer, severely corrupting the stack memory of the Ruby process.</li>
<li><strong>Denial of Service</strong>: The stack corruption immediately triggers an abnormal termination of the Ruby application process, leading to a denial of service for the affected service or application.</li>
<li><strong>Potential Code Execution</strong>: In specific, carefully crafted scenarios, this stack corruption could potentially be leveraged to overwrite critical program control flow data (e.g., return addresses), allowing the attacker to achieve arbitrary code execution within the context of the vulnerable Ruby process.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of CVE-2026-54502 primarily leads to a denial of service (DoS) for Ruby applications relying on the vulnerable <code>Oj</code> gem, causing immediate process crashes and service unavailability. Depending on the application's design, this can severely impact business operations and user access. In more sophisticated attack scenarios, the stack-based buffer overflow might be exploited to achieve arbitrary remote code execution (RCE). If RCE is successful, attackers could compromise the underlying server, execute commands with the privileges of the Ruby process, exfiltrate sensitive data, or establish further persistence within the environment, leading to significant data breaches, system compromise, and financial losses.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Patch CVE-2026-54502 immediately by upgrading the <code>oj</code> gem to version 3.17.2 or later in all affected Ruby applications.</li>
<li>Deploy the webserver Sigma rule &quot;Detect CVE-2026-54502 Exploitation Attempt - Large Oj.dump Indent&quot; in this brief to your SIEM to identify attempts at exploiting this vulnerability.</li>
<li>Implement robust input validation for all user-supplied data, particularly for parameters that influence data formatting or transformation, to prevent excessively large integer values from reaching sensitive functions.</li>
<li>Deploy the process creation Sigma rules &quot;Detect Ruby Process Spawning Suspicious Child Process (Windows)&quot; and &quot;Detect Ruby Process Spawning Suspicious Child Process (Linux)&quot; to monitor for potential remote code execution payloads from Ruby processes.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>overflow</category><category>ruby</category><category>gem</category><category>denial-of-service</category><category>remote-code-execution</category><category>application-vulnerability</category></item></channel></rss>