Summary
The strip_html filter in liquidjs is intended to remove HTML tags from a string before rendering, and is widely used as an XSS sanitizer. The implementation uses a regex whose catch-all branch (<.*?>) does not match line terminators, so any HTML tag containing a \n or \r character passes through unmodified. An attacker who can place a newline inside a tag (e.g. <img\nsrc=x\nonerror=alert(1)>) bypasses sanitization entirely, since browsers treat newlines as whitespace within a tag and execute the resulting onerror/onload/etc. handler. This results in stored or reflected XSS in any application that relies on strip_html to neutralize untrusted HTML.
Details
The vulnerable code is in src/filters/html.ts:
// src/filters/html.ts:45-49
export function strip_html (this: FilterImpl, v: string) {
const str = stringify(v)
this.context.memoryLimit.use(str.length)
return str.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<.*?>|<!--[\s\S]*?-->/g, '')
}
The regex has four alternations:
<script[\s\S]*?<\/script>, uses[\s\S], matches across newlines.<style[\s\S]*?<\/style>, uses[\s\S], matches across newlines.<.*?>, uses., which in JavaScript does not match\nor\r(nos/dotAll flag set).<!--[\s\S]*?-->, uses[\s\S], matches across newlines.
Branch 3 is the catch-all for "any other tag." Because . excludes line terminators, a tag containing a newline does not match any alternative. The literal characters of the tag are passed through to the output.
Browsers, however, parse HTML tag content with whitespace tolerance: per the HTML spec, attribute names and values may be separated by ASCII whitespace, which includes \n and \r. So <img\nsrc=x\nonerror=alert(1)> is parsed as a valid img element with an onerror handler.
liquidjs' default rendering pipeline does not auto-escape filter output (the outputEscape engine option is undefined by default, see src/liquid-options.ts), so the unescaped HTML is delivered verbatim to the consumer's HTML response.
Trust path:
- Application receives untrusted input (e.g. user comment field).
- Developer renders it as
{{ comment | strip_html }}to "safely" embed user content as plaintext. - Attacker submits
<img\u000Asrc=x\u000Aonerror=alert(document.cookie)>. strip_htmlreturns the input unchanged.- Output is written into the HTML response with no further escaping.
- Victim's browser executes the attacker's JavaScript in the application's origin.
This is an inconsistency bug: the same regex correctly uses [\s\S] for <script>, <style>, and comment branches, but reverts to . for the catch-all. The other branches' authors clearly knew to handle multi-line content; the catch-all was missed.
PoC
Reproduces against current HEAD (10.25.7) using the published dist/liquid.node.js build:
node -e "
const { Liquid } = require('./dist/liquid.node.js');
const engine = new Liquid();
engine.parseAndRender(
'Safe output: {{ input | strip_html }}',
{ input: '<img\nsrc=x\nonerror=\"alert(document.cookie)\">' }
).then(r => console.log(JSON.stringify(r)));
"
Verified output:
"Safe output: <img\nsrc=x\nonerror=\"alert(document.cookie)\">"
The <img ... onerror=...> tag is delivered to the output completely unmodified. When this string is placed into an HTML document and parsed by a browser, the onerror handler executes.
Same bypass works with \r (carriage return), \r\n, or any combination of CR/LF inside the tag. It also works with other event-handler vectors (<svg\nonload=alert(1)>, <body\nonload=alert(1)>, <iframe\nsrc="javascript:alert(1)">, etc.) and is not specific to <img>.
For comparison, the same input without a newline is correctly stripped:
node -e "
const { Liquid } = require('./dist/liquid.node.js');
const engine = new Liquid();
engine.parseAndRender(
'Safe output: {{ input | strip_html }}',
{ input: '<img src=x onerror=\"alert(1)\">' }
).then(r => console.log(JSON.stringify(r)));
"
# → "Safe output: "
This confirms strip_html is intended to remove tags of this shape, and the newline form is a sanitizer bypass rather than expected behavior.
Impact
Any liquidjs-using application that:
- Renders attacker-controlled strings via
{{ x | strip_html }}to defend against HTML injection, AND - Does not separately HTML-escape that output (default behavior,
outputEscapeis unset by default),
Is vulnerable to stored or reflected XSS. The attacker can execute arbitrary JavaScript in the victim's browser in the application's origin, enabling session theft, account takeover, CSRF with origin-scoped credentials, and arbitrary actions in the victim's authenticated session. The XSS is triggered with simple, well-known event-handler payloads, no exotic encoding, no character set tricks, just a literal newline inside the tag.
The blast radius matches the deployment of liquidjs as a server-side template engine: liquidjs is one of the most popular Liquid implementations on npm (millions of downloads/week) and strip_html is documented as the sanitization filter for HTML stripping, so the vulnerable pattern ({{ user | strip_html }}) is the natural and recommended use of the filter.
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
CVE-2026-44644 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. No fixed version is listed yet, so configuration controls and monitoring matter more in the interim.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Replace <.*?> with <[\s\S]*?> (or apply the s/dotAll flag to the entire regex) so the catch-all branch matches across line terminators, consistent with the other branches:
// src/filters/html.ts
export function strip_html (this: FilterImpl, v: string) {
const str = stringify(v)
this.context.memoryLimit.use(str.length)
return str.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<[\s\S]*?>|<!--[\s\S]*?-->/g, '')
}
Equivalent fix using the dotAll flag (requires ES2018+, which liquidjs already targets):
return str.replace(/<script.*?<\/script>|<style.*?<\/style>|<.*?>|<!--.*?-->/gs, '')
After the fix, the PoC input is correctly reduced to an empty string. Note that strip_html should still not be relied on as a primary XSS defense, the project README/documentation should recommend HTML-escaping (escape filter) for untrusted content rendered into HTML contexts. A brief security note in the filter's documentation would help users who currently treat strip_html as a sanitizer.
Frequently Asked Questions
- What is CVE-2026-44644? CVE-2026-44644 is a medium-severity cross-site scripting (XSS) vulnerability in liquidjs (npm), affecting versions <= 10.25.7. No fixed version is listed yet. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- How severe is CVE-2026-44644? CVE-2026-44644 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of liquidjs are affected by CVE-2026-44644? liquidjs (npm) versions <= 10.25.7 is affected.
- Is there a fix for CVE-2026-44644? No fixed version is listed for CVE-2026-44644 yet. Monitor the advisory for updates and apply mitigations in the interim.
- Is CVE-2026-44644 exploitable, and should I be worried? Whether CVE-2026-44644 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-44644 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-44644? No fixed version is listed yet. In the interim: Validate and encode untrusted input before rendering it as HTML. Applying a Content Security Policy reduces the impact if encoding is bypassed.