Skip to main content

LiquidJS CVE-2026-44644

MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-05-27 https://github.com/harttle/liquidjs GHSA-2qv6-9wx5-cwv4
6.1
CVSS 3.1 · Vendor: https://github.com/harttle/liquidjs
Share

Severity by source

Vendor (https://github.com/harttle/liquidjs) PRIMARY
6.1 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Primary rating from Vendor (https://github.com/harttle/liquidjs) · only source for this CVE.

CVSS VectorVendor: https://github.com/harttle/liquidjs

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

Lifecycle Timeline

2
Source Code Evidence Fetched
May 27, 2026 - 00:30 vuln.today
Analysis Generated
May 27, 2026 - 00:30 vuln.today

Blast Radius

ecosystem impact
† from your stack dependencies † transitive graph · vuln.today resolves 4-path depth
  • 22 npm packages depend on liquidjs (11 direct, 11 indirect)

Ecosystem-wide dependent count for version 10.25.7.

DescriptionCVE.org

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:

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:

  1. <script[\s\S]*?<\/script> - uses [\s\S], matches across newlines.
  2. <style[\s\S]*?<\/style> - uses [\s\S], matches across newlines.
  3. <.*?> - uses ., which in JavaScript does not match \n or \r (no s/dotAll flag set).
  4. <!--[\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_html returns 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:

bash
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:

bash
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:

  1. Renders attacker-controlled strings via {{ x | strip_html }} to defend against HTML injection, AND
  2. Does not separately HTML-escape that output (default behavior - outputEscape is 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.

Recommended Fix

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:

ts
// 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):

ts
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.

AnalysisAI

XSS sanitizer bypass in LiquidJS's strip_html filter (all versions through 10.25.7) allows stored or reflected cross-site scripting via newline-embedded HTML tags. The filter's catch-all regex branch uses JavaScript's dot operator without the dotAll flag, causing tags containing literal newline or carriage-return characters (e.g., <img\nsrc=x\nonerror=alert(1)>) to pass through unmodified - while browsers parse such tags as fully valid HTML elements and execute embedded event handlers. Publicly available exploit code exists; no vendor-released patch has been identified at time of analysis.

Technical ContextAI

The vulnerability is in src/filters/html.ts within the npm package liquidjs (pkg:npm/liquidjs). The strip_html filter applies a four-branch regex to remove HTML tags: branches for script blocks, style blocks, and HTML comments all use [\s\S] to match across line terminators, but the catch-all branch - responsible for stripping any other HTML tag - uses <.*?>, where JavaScript's . operator does not match \n or \r unless the dotAll (s) flag is set. This flag is absent from the regex. The HTML specification (CWE-79: Improper Neutralization of Input During Web Page Generation) permits ASCII whitespace, including newlines, between attribute names and values, so browsers parse <img\nsrc=x\nonerror=alert(1)> as a valid img element with an executing onerror handler. Compounding this, LiquidJS's default engine configuration leaves outputEscape undefined (src/liquid-options.ts), meaning filter output is not auto-escaped before being written into HTML responses. The inconsistency is internal to the same regex - the other three branches correctly handle multi-line content, while only the catch-all was missed.

RemediationAI

No vendor-released patch has been identified at time of analysis. The code-level fix requires changing <.*?> to <[\s\S]*?> in the strip_html regex in src/filters/html.ts, or applying the JavaScript dotAll flag (s) to the entire regex - both approaches are explicitly documented in the advisory at https://github.com/harttle/liquidjs/security/advisories/GHSA-2qv6-9wx5-cwv4. As an immediate compensating control, replace all uses of {{ input | strip_html }} in security-sensitive contexts with the escape filter ({{ input | escape }}), which HTML-encodes output rather than attempting tag stripping, eliminating the bypass entirely at the cost of displaying encoded HTML entities to end users rather than rendered output. Alternatively, apply a server-side HTML sanitizer (such as DOMPurify via jsdom on the server) before passing content to LiquidJS, accepting the added dependency and processing overhead. Restricting user input at ingestion to block newline characters within angle-bracket sequences is a fragile control given multiple CR/LF encoding variations and should not be relied upon as a sole defense. Monitor the upstream repository at https://github.com/harttle/liquidjs for a patched release.

CVE-2024-55591 CRITICAL POC
9.8 Jan 14

FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote

CVE-2014-7205 CRITICAL POC
10.0 Oct 08

Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t

CVE-2025-59528 CRITICAL POC
10.0 Sep 22

Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete

CVE-2017-14849 HIGH POC
7.5 Sep 28

Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc

CVE-2017-5941 CRITICAL POC
9.8 Feb 09

An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner

CVE-2014-3744 HIGH POC
7.5 Oct 23

Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi

CVE-2014-9566 HIGH POC
7.5 Mar 10

Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin

CVE-2013-4660 MEDIUM POC
6.8 Jun 28

The JS-YAML module before 2.0.5 for Node.js parses input without properly considering the unsafe !!js/function tag, whic

CVE-2015-5688 MEDIUM POC
5.0 Sep 04

Directory traversal vulnerability in lib/app/index.js in Geddy before 13.0.8 for Node.js allows remote attackers to read

CVE-2026-45321 CRITICAL POC
9.6 May 12

Credential-harvesting malware compromised 84 versions of 42 TanStack npm packages on 2026-05-11 via chained GitHub Actio

CVE-2014-7192 CRITICAL POC
10.0 Dec 11

Eval injection vulnerability in index.js in the syntax-error package before 1.1.1 for Node.js 0.10.x, as used in IBM Rat

CVE-2013-4450 MEDIUM POC
5.0 Oct 21

The HTTP server in Node.js 0.10.x before 0.10.21 and 0.8.x before 0.8.26 allows remote attackers to cause a denial of se

Share

CVE-2026-44644 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy