<?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>Diesel — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/diesel/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Fri, 26 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/diesel/feed.xml" rel="self" type="application/rss+xml"/><item><title>Diesel SQLite Backend UTF-8 Corruption Vulnerability</title><link>https://feed.craftedsignal.io/briefs/2024-01-diesel-utf8-corruption/</link><pubDate>Fri, 26 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-diesel-utf8-corruption/</guid><description>Diesel versions before 2.3.8 are vulnerable to UTF-8 corruption due to the `sqlite3_value_text` function not always returning UTF-8 encoded strings, potentially leading to invalid UTF-8 string processing without validation.</description><content:encoded><![CDATA[<p>Diesel, a Rust ORM, is vulnerable to UTF-8 corruption in versions prior to 2.3.8. The vulnerability stems from the use of the <code>sqlite3_value_text</code> function when deserializing query results from SQLite. Diesel incorrectly assumed this function always returns UTF-8 encoded strings. However, for SQLite <code>BLOB</code> storage types, the function can return arbitrary bytes, leading to the use of <code>str::from_utf8_unchecked</code> on potentially invalid UTF-8 data. This violates Rust&rsquo;s safety contract and can lead to memory corruption or unexpected behavior. The vulnerability was identified and patched in Diesel version 2.3.8. This matters to defenders because a compromised application could exhibit unpredictable behavior or be exploited to bypass security measures.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker crafts a malicious SQLite database file.</li>
<li>The database includes a <code>BLOB</code> field containing non-UTF-8 data.</li>
<li>A Diesel-based application connects to the malicious database.</li>
<li>The application executes a query that retrieves the <code>BLOB</code> field.</li>
<li>Diesel uses <code>sqlite3_value_text</code> to read the field&rsquo;s content.</li>
<li><code>sqlite3_value_text</code> returns a pointer to the raw (non-UTF-8) bytes.</li>
<li>Diesel&rsquo;s vulnerable code uses <code>str::from_utf8_unchecked</code> to create a Rust string slice without validating the UTF-8 encoding.</li>
<li>The application processes the invalid UTF-8 string, potentially leading to memory corruption or unexpected behavior.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability can lead to memory corruption within applications using Diesel versions before 2.3.8 when interacting with SQLite databases containing <code>BLOB</code> fields with non-UTF-8 data. While the exact impact depends on how the corrupted string is used, it can range from application crashes to potential remote code execution if the corrupted data is used in a sensitive context. There are no specific victim counts or sectors targeted available, but any application using Diesel with SQLite is potentially vulnerable.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Upgrade Diesel to version 2.3.8 or later to remediate the vulnerability as outlined in the overview.</li>
<li>Implement UTF-8 validation on all strings received from external sources, especially when interacting with SQLite <code>BLOB</code> fields, regardless of the Diesel version, to provide defense in depth.</li>
<li>Consider using static analysis tools to identify potential uses of <code>str::from_utf8_unchecked</code> in your codebase and ensure proper validation is performed before using the resulting strings.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>utf-8</category><category>diesel</category><category>sqlite</category><category>corruption</category></item></channel></rss>