<?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>Smallbitvec (&gt;= 1.0.1, &lt;= 2.6.0) — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/smallbitvec--1.0.1--2.6.0/</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>Tue, 23 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/smallbitvec--1.0.1--2.6.0/feed.xml" rel="self" type="application/rss+xml"/><item><title>smallbitvec Integer Overflow Leads to Heap Buffer Overflow</title><link>https://feed.craftedsignal.io/briefs/2024-01-23-smallbitvec-overflow/</link><pubDate>Tue, 23 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-23-smallbitvec-overflow/</guid><description>An integer overflow in the `smallbitvec` crate leads to an undersized heap allocation, enabling heap buffer overflows through safe APIs, affecting versions 1.0.1 through 2.6.0.</description><content:encoded><![CDATA[<p>The <code>smallbitvec</code> crate in Rust versions 1.0.1 through 2.6.0 is vulnerable to an integer overflow within the internal capacity calculation, specifically in the <code>buffer_len</code> function. This function computes the required buffer size based on the provided capacity (<code>cap</code>). When <code>cap</code> approaches <code>usize::MAX</code>, the addition <code>cap + bits_per_storage() - 1</code> can overflow in release builds, resulting in a wraparound due to Rust’s default wrapping semantics for integer overflow in optimized builds. This overflow leads to an undersized heap allocation. Subsequent safe API calls like <code>set</code>, <code>push</code>, and <code>reserve</code> rely on this corrupted metadata, leading to out-of-bounds memory access and heap buffer overflows. This vulnerability allows memory corruption without requiring the use of <code>unsafe</code> code by the caller.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>A <code>SmallBitVec</code> is instantiated using a large capacity (e.g., <code>usize::MAX</code> in <code>from_elem</code> or a large value passed to <code>reserve</code>).</li>
<li>The <code>buffer_len(cap)</code> function is called internally to calculate the required buffer size.</li>
<li>The addition within <code>buffer_len(cap)</code> overflows, resulting in a smaller-than-expected value.</li>
<li>The backing storage is allocated based on the overflowed, smaller size.</li>
<li>Internal metadata (logical length/capacity) is set based on the original, large capacity value, creating a mismatch between metadata and actual buffer size.</li>
<li>A safe API call (e.g., <code>set</code>, <code>push</code>, <code>reserve</code>) is invoked, using the corrupted metadata for index calculations.</li>
<li>The index calculation assumes sufficient backing storage based on the logical length/capacity, which is incorrect.</li>
<li>The operation reaches unsafe internal code paths, leading to out-of-bounds memory access and a heap buffer overflow, resulting in undefined behavior.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability results in a heap buffer overflow, potentially leading to arbitrary code execution. The vulnerability is detectable with tools like ASAN (AddressSanitizer) and Miri. While the exact number of affected projects is unknown, any project using vulnerable versions of the <code>smallbitvec</code> crate is susceptible to this vulnerability. This issue allows for memory corruption and could compromise the integrity and security of applications utilizing the affected crate.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade the <code>smallbitvec</code> crate to a version greater than 2.6.0 to remediate CVE-2026-44983.</li>
<li>Implement runtime checks on capacity values before allocating memory to prevent integer overflows.</li>
<li>Deploy the Sigma rule &ldquo;Detect <code>smallbitvec</code> Integer Overflow via Large Capacity&rdquo; to detect attempts to trigger the vulnerability through excessively large capacity values in <code>SmallBitVec</code> instantiation.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>integer-overflow</category><category>heap-buffer-overflow</category><category>memory-corruption</category></item></channel></rss>