<?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>Memory-Amplification — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/memory-amplification/</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>Wed, 25 Mar 2026 17:44:23 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/memory-amplification/feed.xml" rel="self" type="application/rss+xml"/><item><title>LiquidJS replace_first Filter Exponential Memory Amplification DoS</title><link>https://feed.craftedsignal.io/briefs/2024-02-liquidjs-dos/</link><pubDate>Wed, 25 Mar 2026 17:44:23 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-02-liquidjs-dos/</guid><description>The `replace_first` filter in LiquidJS is vulnerable to exponential memory amplification due to its use of JavaScript's `String.prototype.replace()` and mishandling of the `$&amp;` backreference pattern, allowing attackers to bypass the `memoryLimit` and cause denial of service.</description><content:encoded><![CDATA[<p>LiquidJS version 10.24.0 and earlier contains a vulnerability in its <code>replace_first</code> filter that allows for exponential memory amplification. The <code>replace_first</code> filter delegates to JavaScript&rsquo;s native <code>String.prototype.replace()</code>, which interprets <code>$&amp;</code> as a backreference to the matched substring. The filter only charges the input string length against the configured <code>memoryLimit</code>, not the amplified output. An attacker can exploit this by crafting a Liquid template with a replacement string containing multiple repetitions of <code>$&amp;</code>, causing the output string to grow exponentially with each replacement. By chaining this technique across multiple variable assignments, an attacker can easily exhaust available memory, leading to a denial-of-service condition. This vulnerability affects applications that render user-provided Liquid templates, such as CMS platforms, newsletter editors, and SaaS platforms.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>The attacker crafts a malicious Liquid template.</li>
<li>The template uses the <code>replace_first</code> filter with a pattern containing multiple <code>$&amp;</code> backreferences. For example: <code>{% assign s = &quot;A&quot; %}{% assign s = s | replace_first: s, &quot;$&amp;$&amp;$&amp;...(50 times)...$&amp;&quot; %}</code>.</li>
<li>The LiquidJS engine parses the template.</li>
<li>The <code>replace_first</code> filter is called.</li>
<li>The filter utilizes the native <code>String.prototype.replace()</code> method to perform the replacement.</li>
<li>Each instance of <code>$&amp;</code> in the replacement string is expanded to the matched substring, causing the output string to grow exponentially.</li>
<li>The expanded string consumes excessive memory, potentially exceeding available resources.</li>
<li>The application crashes or becomes unresponsive, resulting in a denial-of-service condition.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of this vulnerability can lead to a denial-of-service condition. A single request can allocate hundreds of megabytes of memory, and concurrent requests can cause complete service unavailability. The Node.js event loop is blocked, and legitimate user requests are stalled. Empirical results have demonstrated that with 20 concurrent requests, legitimate users experience up to 13-second delays. Each attack request costs only a few hundred bytes, making it easy to launch a large-scale attack.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Apply a patch to LiquidJS that properly accounts for memory usage when using the <code>replace_first</code> filter with backreferences.</li>
<li>Alternatively, disable or remove the <code>replace_first</code> filter entirely and use the <code>replace</code> filter instead, which treats <code>$&amp;</code> as a literal string.</li>
<li>Implement input validation and sanitization to prevent the use of <code>$&amp;</code> backreferences in user-provided Liquid templates.</li>
<li>Monitor web server logs for suspicious requests containing Liquid templates with excessive use of the <code>replace_first</code> filter and <code>$&amp;</code> patterns using the Sigma rule below.</li>
<li>Implement rate limiting to mitigate the impact of denial-of-service attacks.</li>
<li>Increase the <code>memoryLimit</code> configuration value to provide a temporary buffer against memory exhaustion, but this will not fully prevent the attack.</li>
</ul>
]]></content:encoded><category domain="severity">critical</category><category domain="type">advisory</category><category>liquidjs</category><category>denial-of-service</category><category>memory-amplification</category></item></channel></rss>