{"id":"CVE-2026-41591","aliases":["EUVD-2026-28790","GHSA-x9fj-57fh-c8wq"],"status":"published","title":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping","description":"Marko is a declarative, HTML-based language for building web apps. Prior to marko version 5.38.36 and prior to @marko/runtime-tags 6.0.164, when dynamic text is interpolated into a \u003cscript\u003e or \u003cstyle\u003e 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 \u003cscript\u003e or \u003cstyle\u003e block could break out of the tag with \u003c/SCRIPT\u003e, \u003c/Style\u003e, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.","severity":{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-10","score":0.00227,"percentile":0.13503,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-79"],"published":"2026-04-22T19:55:51Z","modified":"2026-10-28T02:31:11Z","fixes":[{"ecosystem":"npm","package":"marko","fixed_in":["5.38.36"],"sources":["ghsa","osv"]},{"ecosystem":"npm","package":"@marko/runtime-tags","fixed_in":["6.0.164"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"marko","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.38.36"}]}]},{"source":"ghsa","ecosystem":"npm","package":"@marko/runtime-tags","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"6.0.164"}]}]},{"source":"osv","ecosystem":"npm","package":"marko","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"5.38.36"}]}]},{"source":"osv","ecosystem":"npm","package":"@marko/runtime-tags","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"6.0.164"}]}]}],"products":[{"vendor":"marko-js","product":"marko"},{"vendor":"openjsf","product":"marko"},{"vendor":"openjsf","product":"marko\\/runtime-tags"}],"references":[{"url":"https://github.com/marko-js/marko/security/advisories/GHSA-x9fj-57fh-c8wq","tags":["x_refsource_CONFIRM","exploit","Exploit","Mitigation","Patch","Vendor Advisory","advisory","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41591","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-x9fj-57fh-c8wq"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/41xxx/CVE-2026-41591.json","tags":["advisory"]},{"url":"https://github.com/marko-js/marko","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-41591","title":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping","description":"Marko is a declarative, HTML-based language for building web apps. Prior to marko version 5.38.36 and prior to @marko/runtime-tags 6.0.164, when dynamic text is interpolated into a \u003cscript\u003e or \u003cstyle\u003e 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 \u003cscript\u003e or \u003cstyle\u003e block could break out of the tag with \u003c/SCRIPT\u003e, \u003c/Style\u003e, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.","status":"published","published":"2026-05-08T15:22:50.99Z","modified":"2026-05-08T21:26:58.356Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T13:40:57.334596Z"}],"euvd":[{"id":"EUVD-2026-28790","description":"Marko is a declarative, HTML-based language for building web apps. Prior to marko version 5.38.36 and prior to @marko/runtime-tags 6.0.164, when dynamic text is interpolated into a \u003cscript\u003e or \u003cstyle\u003e 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 \u003cscript\u003e or \u003cstyle\u003e block could break out of the tag with \u003c/SCRIPT\u003e, \u003c/Style\u003e, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.","status":"published","published":"2026-05-08T15:22:50Z","modified":"2026-05-08T21:26:58Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium"}],"updated_at":"2026-11-02T19:05:14.089367Z"}],"ghsa":[{"id":"GHSA-x9fj-57fh-c8wq","title":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping","description":"### Summary\n\nWhen dynamic text is interpolated into a `\u003cscript\u003e` or `\u003cstyle\u003e` 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 `\u003cscript\u003e` or `\u003cstyle\u003e` block could break out of the tag with `\u003c/SCRIPT\u003e`, `\u003c/Style\u003e`, 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 = /\u003c\\/script/g;\nconst unsafeStyleReg  = /\u003c\\/style/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-script-placeholder.js\nconst unsafeCharsReg = /\u003c\\/script/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-style-placeholder.js\nconst unsafeCharsReg = /\u003c\\/style/g;\n```\n\nHTML tag names are case-insensitive in the browser parser, so inputs such as `\u003c/SCRIPT\u003e`, `\u003c/Script\u003e`, or `\u003c/sTyLe\u003e` 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 `\u003cscript\u003e` and `\u003cstyle\u003e` 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 = \"\u003c/SCRIPT\u003e\u003cscript\u003ealert(1)//\";\n\u003cscript\u003e\n  const data = ${JSON.stringify(userCode)};\n\u003c/script\u003e\n```\n\nWould yield the following:\n\n```html\n\u003cscript\u003econst data = \"\u003c/SCRIPT\u003e\u003cscript\u003ealert(1)//\";\u003c/script\u003e\n```\n\nWhich is then parsed in any WHATWG-compliant browser as:\n```html\n\u003cscript\u003econst data = \"\u003c/script\u003e\n\u003cscript\u003ealert(1)//\";\u003c/script\u003e\n```\n\n### Impact\n\nCross-site scripting. Any Marko template that explicitly interpolates untrusted data inside a `\u003cscript\u003e` or `\u003cstyle\u003e` 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 \u003cscript\u003e or \u003cstyle\u003e tag.\n\n### Patch\n\nCommit `19d4b37d0` — `fix: html script, style, and comment escaping`.\n\n```diff\n- const unsafeScriptReg = /\u003c\\/script/g;\n+ const unsafeScriptReg = /\u003c\\/script/gi;\n\n- const unsafeStyleReg  = /\u003c\\/style/g;\n+ const unsafeStyleReg  = /\u003c\\/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 `\u003cscript\u003e` or `\u003cstyle\u003e` tag — e.g. normalize `\u003c/script`, `\u003c/style`, and their mixed-case variants before interpolation, or avoid direct interpolation of untrusted values inside these tags entirely.","status":"published","published":"2026-04-22T19:55:51Z","modified":"2026-05-13T13:29:44Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:40:07.01746Z"}],"nvd":[{"id":"CVE-2026-41591","description":"Marko is a declarative, HTML-based language for building web apps. Prior to marko version 5.38.36 and prior to @marko/runtime-tags 6.0.164, when dynamic text is interpolated into a \u003cscript\u003e or \u003cstyle\u003e 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 \u003cscript\u003e or \u003cstyle\u003e block could break out of the tag with \u003c/SCRIPT\u003e, \u003c/Style\u003e, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.","status":"published","published":"2026-05-08T16:16:11.167Z","modified":"2026-08-26T19:16:01.883Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium","assessor":"secondary"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:12:17.842772Z"}],"osv":[{"id":"CVE-2026-41591","title":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping","description":"Marko is a declarative, HTML-based language for building web apps. Prior to marko version 5.38.36 and prior to @marko/runtime-tags 6.0.164, when dynamic text is interpolated into a \u003cscript\u003e or \u003cstyle\u003e 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 \u003cscript\u003e or \u003cstyle\u003e block could break out of the tag with \u003c/SCRIPT\u003e, \u003c/Style\u003e, etc. and inject arbitrary HTML/JavaScript, resulting in cross-site scripting. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.","status":"published","published":"2026-05-08T15:22:50.99Z","modified":"2026-10-28T02:31:11.023581351Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T15:45:03.764807Z"},{"id":"GHSA-x9fj-57fh-c8wq","title":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping","description":"### Summary\n\nWhen dynamic text is interpolated into a `\u003cscript\u003e` or `\u003cstyle\u003e` 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 `\u003cscript\u003e` or `\u003cstyle\u003e` block could break out of the tag with `\u003c/SCRIPT\u003e`, `\u003c/Style\u003e`, 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 = /\u003c\\/script/g;\nconst unsafeStyleReg  = /\u003c\\/style/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-script-placeholder.js\nconst unsafeCharsReg = /\u003c\\/script/g;\n\n// packages/runtime-class/src/runtime/html/helpers/escape-style-placeholder.js\nconst unsafeCharsReg = /\u003c\\/style/g;\n```\n\nHTML tag names are case-insensitive in the browser parser, so inputs such as `\u003c/SCRIPT\u003e`, `\u003c/Script\u003e`, or `\u003c/sTyLe\u003e` 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 `\u003cscript\u003e` and `\u003cstyle\u003e` 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 = \"\u003c/SCRIPT\u003e\u003cscript\u003ealert(1)//\";\n\u003cscript\u003e\n  const data = ${JSON.stringify(userCode)};\n\u003c/script\u003e\n```\n\nWould yield the following:\n\n```html\n\u003cscript\u003econst data = \"\u003c/SCRIPT\u003e\u003cscript\u003ealert(1)//\";\u003c/script\u003e\n```\n\nWhich is then parsed in any WHATWG-compliant browser as:\n```html\n\u003cscript\u003econst data = \"\u003c/script\u003e\n\u003cscript\u003ealert(1)//\";\u003c/script\u003e\n```\n\n### Impact\n\nCross-site scripting. Any Marko template that explicitly interpolates untrusted data inside a `\u003cscript\u003e` or `\u003cstyle\u003e` 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 \u003cscript\u003e or \u003cstyle\u003e tag.\n\n### Patch\n\nCommit `19d4b37d0` — `fix: html script, style, and comment escaping`.\n\n```diff\n- const unsafeScriptReg = /\u003c\\/script/g;\n+ const unsafeScriptReg = /\u003c\\/script/gi;\n\n- const unsafeStyleReg  = /\u003c\\/style/g;\n+ const unsafeStyleReg  = /\u003c\\/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 `\u003cscript\u003e` or `\u003cstyle\u003e` tag — e.g. normalize `\u003c/script`, `\u003c/style`, and their mixed-case variants before interpolation, or avoid direct interpolation of untrusted values inside these tags entirely.","status":"published","published":"2026-04-22T19:55:51Z","modified":"2026-05-13T13:54:56.772894Z","cvss":[{"version":"3.1","score":6.4,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T15:46:59.835583Z"}]}}
