Executive brief
LiquidJS is a JavaScript template engine used in content management systems and SaaS platforms to render user-provided templates. The replace_first filter has a vulnerability that allows attackers to consume massive amounts of memory (up to 625,000 times more than the configured limit) while bypassing the engine's memory safeguards, causing the application to crash or become unresponsive.
Technical details
The replace_first filter in LiquidJS delegates to JavaScript's native String.prototype.replace(), which interprets special patterns like
amp; (matched substring backreference). The vulnerability occurs because the filter charges memoryLimit only for the input string length, not the potentially amplified output. By chaining multiple replace_first operations with amp; repetitions in the replacement string, an attacker can achieve exponential memory amplification (up to 625,000:1 ratio): a 1-byte input expanding through 5 stages produces 312.5 MB of output while only charging ~6.38 MB against the memory limit. The attack requires no authentication and can be triggered by submitting a malicious Liquid template. The sibling replace and replace_last filters are not vulnerable as they use safe string manipulation methods.Affected products
- harttle LiquidJS <= 10.24.x
Timeline
- 2026-03-25: disclosed
- 2026-03-25: advisory