CVE-2026-41591: Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping

Published Apr 22, 2026
·
Updated

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 escapescript and escapestyle 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 escapecomment 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.

Other sources

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 <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. This issue has been patched in marko version 5.38.36 and @marko/runtime-tags 6.0.164.

MITRE

Affected Software

4 affected componentsFixes available
npm/@marko/runtime-tags<6.0.164
6.0.164
npm/marko<5.38.36
5.38.36
Openjsf Marko Node.js<5.38.36
Openjsf Marko\/runtime-tags Node.js<6.0.164

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/@marko/runtime-tags to a version that resolves this vulnerability.

    Fixed in 6.0.164
  2. Upgrade

    Upgrade npm/marko to a version that resolves this vulnerability.

    Fixed in 5.38.36
  3. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 5.38.36
  4. Upgrade

    Upgrade @marko/runtime-tags to a version that resolves this vulnerability.

    Fixed in 6.0.164
  5. Configuration

    Ensure the runtime escape helpers for script/style (and related comment escaping) treat closing tag detection as case-insensitive to prevent tag-breakout via mixed-case end tags.

    Marko runtime HTML escaping helpers (script/style/comment) case-insensitive detection for closing tags = use case-insensitive regexes (e.g., replace /<\/script/g with /<\/script/gi and replace /<\/style/g with /<\/style/gi) so mixed-case closing tags like </SCRIPT>, </Style>, and </sTyLe> are matched and escaped
  6. Compensating control

    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; normalize "</script", "</style", and their mixed-case variants before interpolation, or avoid direct interpolation of untrusted values inside these tags entirely.

Event History

Apr 22, 2026
Advisory Published
via GitHub·07:55 PM
Data Sourced
via GitHub·07:55 PM
DescriptionSeverityWeaknessAffected Software
May 8, 2026
CVE Published
via MITRE·03:22 PM
Data Sourced
via MITRE·03:22 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·04:16 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-41591?

CVE-2026-41591 is classified as a high-severity vulnerability due to its potential to allow unauthorized script execution.

2

How do I fix CVE-2026-41591?

To fix CVE-2026-41591, update the @marko/runtime-tags package to version 6.0.164 or the marko package to version 5.38.36.

3

What type of attack does CVE-2026-41591 enable?

CVE-2026-41591 enables attackers to execute arbitrary scripts through tag breakout in `<script>` or `<style>` blocks.

4

In which software is CVE-2026-41591 found?

CVE-2026-41591 affects the @marko/runtime-tags and marko packages.

5

What are the implications of exploiting CVE-2026-41591?

Exploiting CVE-2026-41591 could lead to Cross-Site Scripting (XSS) vulnerabilities, compromising user data and site integrity.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203