<?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/" xmlns:webfeeds="http://webfeeds.org/rss/1.0"><channel><title>Django REST Framework (&gt;= 3.6.4) - CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/django-rest-framework--3.6.4/</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>Thu, 29 Oct 2026 22:22:23 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/django-rest-framework--3.6.4/feed.xml" rel="self" type="application/rss+xml"/><image><url>https://feed.craftedsignal.io/favicon-32x32.png</url><title>CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/</link><width>32</width><height>32</height></image><webfeeds:icon>https://feed.craftedsignal.io/favicon.svg</webfeeds:icon><item><title>Django REST framework: JSONParser memory exhaustion via charset parameter</title><link>https://feed.craftedsignal.io/briefs/2026-10-django-rest-framework-json-memory-exhaustion/</link><pubDate>Thu, 29 Oct 2026 22:22:23 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2026-10-django-rest-framework-json-memory-exhaustion/</guid><description>Django REST framework (DRF) JSONParser fails to validate charset codecs, allowing attackers to bypass DATA_UPLOAD_MAX_MEMORY_SIZE limits through malicious compression, leading to significant memory amplification.</description><content:encoded><![CDATA[<p>Django REST framework (DRF) versions 3.6.4 and later contain a vulnerability in <code>JSONParser</code> where the <code>Content-Type</code> charset parameter is used to apply arbitrary codecs to the request stream. Because DRF does not verify if the requested charset is a valid text encoding, an attacker can specify byte-transform codecs like <code>bz2_codec</code> or <code>zlib_codec</code>. This results in the request body being decompressed into memory before the <code>DATA_UPLOAD_MAX_MEMORY_SIZE</code> check is performed, allowing for massive memory expansion.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker crafts a highly compressed malicious JSON payload (e.g., 108 bytes).</li>
<li>Attacker initiates a POST request to a DRF endpoint accepting JSON.</li>
<li>Attacker sets the <code>Content-Type</code> header to <code>application/json; charset=bz2_codec</code>.</li>
<li>Django receives the request and initializes <code>JSONParser</code>.</li>
<li><code>JSONParser</code> calls <code>codecs.getreader()</code> with the attacker-provided <code>bz2_codec</code>.</li>
<li>The request stream is decompressed into memory by the codec reader.</li>
<li>The expanded data is passed to <code>json.load()</code> while the original <code>DATA_UPLOAD_MAX_MEMORY_SIZE</code> check remains satisfied by the small wire-size of the payload.</li>
<li>The worker process consumes significant memory, potentially causing a Denial of Service (DoS).</li>
</ol>
<h2 id="impact">Impact</h2>
<p>The vulnerability allows an amplification factor of over 400,000x, where a 108-byte request can force the allocation of ~50 MiB of memory, significantly increasing process peak RSS and facilitating memory-based DoS.</p>
<h2 id="recommendation">Recommendation</h2>
<p>Patch the <code>JSONParser</code> to validate that the provided encoding is a supported text-based encoding. Implement the following check within <code>rest_framework/parsers.py</code> before invoking the codec:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">codecs</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">rest_framework.exceptions</span> <span class="kn">import</span> <span class="n">ParseError</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">if</span> <span class="ow">not</span> <span class="n">codecs</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="n">encoding</span><span class="p">)</span><span class="o">.</span><span class="n">_is_text_encoding</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="k">raise</span> <span class="n">ParseError</span><span class="p">(</span><span class="s1">&#39;Unsupported charset in Content-Type&#39;</span><span class="p">)</span>
</span></span></code></pre></div><p>Until patches are applied, monitor for unusual <code>Content-Type</code> headers containing non-standard charset parameters in application access logs.</p>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category></item></channel></rss>