Vulnerabilities in pkg:npm/marko

PACKAGE
Advisory Identifier: GHSA-x9fj-57fh-c8wq
Advisory Summary

CVE-2026-41591 is a MODERATE (CVSS 6.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Marko libraries in the npm ecosystem. The issue involves xss via case-insensitive script/style closing tag bypass in runtime html escaping. Remediation is available by upgrading affected packages to version 5.38.36, 6.0.164.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/marko

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/marko. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-x9fj-57fh-c8wq CVE-2026-41591 MODERATE Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping

CVE-2026-41591 at a Glance

CVE Identifier CVE-2026-41591
GHSA Identifier GHSA-x9fj-57fh-c8wq
Severity MODERATE
CVSS v3.1 Base Score 6.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Marko
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N).

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

How to Fix CVE-2026-41591

To remediate this vulnerability, upgrade all affected Marko dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

marko fixed: 5.38.36
npm install marko@5.38.36
@marko/runtime-tags fixed: 6.0.164
npm install @marko/runtime-tags@6.0.164
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls marko

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-41591, inspect your project dependencies using npm:

npm ls marko

Analyze the terminal output to locate any version of Marko in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.38.36), your application is affected.

Note: The npm ls marko command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Marko, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary When dynamic text is interpolated into a `<script>` or `<style>` tag the Marko runtime failed to prevent tag breakout when the closing tag used non-lowercase casing. An attacker able to place input inside a `<script>` or `<style>` block could break out of the tag with `</SCRIPT>`, `</Style>`, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. ### Details The affected helpers used case-sensitive regular expressions to detect attempts at closing the surrounding tag: ```js // packages/runtime-tags/src/html/content.ts const unsafeScriptReg = /<\/script/g; const unsafeStyleReg = /<\/style/g; // packages/runtime-class/src/runtime/html/helpers/escape-script-placeholder.js const unsafeCharsReg = /<\/script/g; // packages/runtime-class/src/runtime/html/helpers/escape-style-placeholder.js const unsafeCharsReg = /<\/style/g; ``` HTML tag names are case-insensitive in the browser parser, so inputs such as `</SCRIPT>`, `</Script>`, or `</sTyLe>` were not matched by these regexes and passed through the helpers unchanged. A browser rendering the output treats the mixed-case end tag as a valid closing tag, terminating the script or style context, and then parses anything that follows as HTML. The Marko compiler routes interpolated values inside `<script>` and `<style>` tags through these helpers automatically (see `native-tag.ts:1080-1085`), so application code following the framework's conventions had no way to detect or compensate for the gap. ### PoC ```marko $ const userCode = "</SCRIPT><script>alert(1)//"; <script> const data = ${JSON.stringify(userCode)}; </script> ``` Would yield the following: ```html <script>const data = "</SCRIPT><script>alert(1)//";</script> ``` Which is then parsed in any WHATWG-compliant browser as: ```html <script>const data = "</script> <script>alert(1)//";</script> ``` ### Impact Cross-site scripting. Any Marko template that explicitly interpolates untrusted data inside a `<script>` or `<style>` block is affected. Stored XSS is trivial if the value originates from any persisted user input (username, profile bio, comment body, etc.) that is later embedded in a script tag during rendering. Exploitation yields arbitrary JavaScript execution in the victim's browser, enabling session token theft, account takeover, and arbitrary actions as the victim. Since the internal `_escape_script` and `_escape_style` helpers are the framework's designated defense against script/style tag breakout, applications following standard Marko patterns had no obvious reason to add a second layer of sanitization. This does not affect scripts or hydration state serialized by Marko itself — only templates that explicitly interpolate untrusted values inside a <script> or <style> tag. ### Patch Commit `19d4b37d0` — `fix: html script, style, and comment escaping`. ```diff - const unsafeScriptReg = /<\/script/g; + const unsafeScriptReg = /<\/script/gi; - const unsafeStyleReg = /<\/style/g; + const unsafeStyleReg = /<\/style/gi; ``` The same commit also introduced an `_escape_comment` helper and corresponding `escape-comment-placeholder.js`, hardening HTML comment escaping as a related preventative fix. Test fixtures were added under `escape-script-case`, `escape-style-case`, and `escape-comment`. ### Workarounds Upgrade to the patched release. As a short-term mitigation on affected versions, pre-sanitize any untrusted data before it reaches a template position rendered inside a `<script>` or `<style>` tag — e.g. normalize `</script`, `</style`, and their mixed-case variants before interpolation, or avoid direct interpolation of untrusted values inside these tags entirely.

CVE-2026-41591 Affected Marko Versions

2 component(s)
Fixed Versions:
5.38.366.0.164
Product / Package Ecosystem Affected Versions Fixed Version
marko
npm
< 5.38.36
5.38.36
@marko/runtime-tags
npm
< 6.0.164
6.0.164

References

Frequently Asked Questions

What is CVE-2026-41591?
CVE-2026-41591 is a security vulnerability in Marko involving XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Marko versions are affected?
Affected versions include releases prior to 5.38.36, 6.0.164 across affected packages: marko, @marko/runtime-tags.
What version fixes CVE-2026-41591?
Upgrading to 5.38.36, 6.0.164 (or the latest patched release for your respective branch) resolves the vulnerability.
Is marko affected?
Yes, marko is affected in releases prior to 5.38.36. Upgrade your dependency to 5.38.36 or later.
Is @marko/runtime-tags affected?
Yes, @marko/runtime-tags is affected in releases prior to 6.0.164. Upgrade your dependency to 6.0.164 or later.
What is the CVSS score of CVE-2026-41591?
CVE-2026-41591 has a CVSS v3.1 base score of 6.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-41591?
CVE-2026-41591 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2026-41591?
Run the dependency tree command: 'npm ls marko'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-x9fj-57fh-c8wq",
  "modified" : "2026-05-13T13:29:43Z",
  "published" : "2026-04-22T19:55:51Z",
  "aliases" : [ "CVE-2026-41591" ],
  "summary" : "Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping",
  "details" : "### Summary\n\nWhen dynamic text is interpolated into a `<script>` or `<style>` tag the Marko runtime failed to prevent tag breakout when the closing tag used non-lowercase casing.\nAn attacker able to place input inside a `<script>` or `<style>` block could break out of the tag with `</SCRIPT>`, `</Style>`, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting.\n\n### Details\n\nThe affected helpers used case-sensitive regular expressions to detect attempts at closing the surrounding tag:\n\n```js\n// packages/runtime-tags/src/html/content.ts\nconst unsafeScriptReg = /<\\/script/g;\nconst unsafeStyleReg  = /<\\/style/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-script-placeholder.js\nconst unsafeCharsReg = /<\\/script/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-style-placeholder.js\nconst unsafeCharsReg = /<\\/style/g;\n```\n\nHTML tag names are case-insensitive in the browser parser, so inputs such as `</SCRIPT>`, `</Script>`, or `</sTyLe>` were not matched by these regexes and passed through the helpers unchanged. A browser rendering the output treats the mixed-case end tag as a valid closing tag, terminating the script or style context, and then parses anything that follows as HTML.\n\nThe Marko compiler routes interpolated values inside `<script>` and `<style>` tags through these helpers automatically (see `native-tag.ts:1080-1085`), so application code following the framework's conventions had no way to detect or compensate for the gap.\n\n### PoC\n\n```marko\n$ const userCode = \"</SCRIPT><script>alert(1)//\";\n<script>\n  const data = ${JSON.stringify(userCode)};\n</script>\n```\n\nWould yield the following:\n\n```html\n<script>const data = \"</SCRIPT><script>alert(1)//\";</script>\n```\n\nWhich is then parsed in any WHATWG-compliant browser as:\n```html\n<script>const data = \"</script>\n<script>alert(1)//\";</script>\n```\n\n### Impact\n\nCross-site scripting. Any Marko template that explicitly interpolates untrusted data inside a `<script>` or `<style>` block is affected.\n\nStored XSS is trivial if the value originates from any persisted user input (username, profile bio, comment body, etc.) that is later embedded in a script tag during rendering. Exploitation yields arbitrary JavaScript execution in the victim's browser, enabling session token theft, account takeover, and arbitrary actions as the victim.\n\nSince the internal `_escape_script` and `_escape_style` helpers are the framework's designated defense against script/style tag breakout, applications following standard Marko patterns had no obvious reason to add a second layer of sanitization.\n\nThis does not affect scripts or hydration state serialized by Marko itself — only templates that explicitly interpolate untrusted values inside a <script> or <style> tag.\n\n### Patch\n\nCommit `19d4b37d0` — `fix: html script, style, and comment escaping`.\n\n```diff\n- const unsafeScriptReg = /<\\/script/g;\n+ const unsafeScriptReg = /<\\/script/gi;\n\n- const unsafeStyleReg  = /<\\/style/g;\n+ const unsafeStyleReg  = /<\\/style/gi;\n```\n\nThe same commit also introduced an `_escape_comment` helper and corresponding `escape-comment-placeholder.js`, hardening HTML comment escaping as a related preventative fix. Test fixtures were added under `escape-script-case`, `escape-style-case`, and `escape-comment`.\n\n### Workarounds\n\nUpgrade to the patched release. As a short-term mitigation on affected versions, pre-sanitize any untrusted data before it reaches a template position rendered inside a `<script>` or `<style>` tag — e.g. normalize `</script`, `</style`, and their mixed-case variants before interpolation, or avoid direct interpolation of untrusted values inside these tags entirely.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "marko"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.38.36"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@marko/runtime-tags"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.0.164"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/marko-js/marko/security/advisories/GHSA-x9fj-57fh-c8wq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-41591"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/marko-js/marko"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-22T19:55:51Z",
    "nvd_published_at" : "2026-05-08T16:16:11Z"
  }
}