<?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>Gem - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/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:47:47 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/gem/feed.xml" rel="self" type="application/rss+xml"/><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>