{"url":"http://public2.vulnerablecode.io/api/packages/1009362?format=json","purl":"pkg:npm/marko@5.0.0-next.77","type":"npm","namespace":"","name":"marko","version":"5.0.0-next.77","qualifiers":{},"subpath":"","is_vulnerable":true,"next_non_vulnerable_version":"5.38.36","latest_non_vulnerable_version":"5.38.36","affected_by_vulnerabilities":[{"url":"http://public2.vulnerablecode.io/api/vulnerabilities/15214?format=json","vulnerability_id":"VCID-ffpt-atty-w7aj","summary":"Marko: XSS via case-insensitive script/style closing tag bypass in runtime HTML escaping\n### 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.","references":[{"reference_url":"https://api.first.org/data/v1/epss?cve=CVE-2026-41591","reference_id":"","reference_type":"","scores":[{"value":"0.00011","scoring_system":"epss","scoring_elements":"0.0141","published_at":"2026-05-29T12:55:00Z"}],"url":"https://api.first.org/data/v1/epss?cve=CVE-2026-41591"},{"reference_url":"https://github.com/marko-js/marko","reference_id":"","reference_type":"","scores":[{"value":"6.4","scoring_system":"cvssv3.1","scoring_elements":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N"},{"value":"MODERATE","scoring_system":"generic_textual","scoring_elements":""}],"url":"https://github.com/marko-js/marko"},{"reference_url":"https://github.com/marko-js/marko/security/advisories/GHSA-x9fj-57fh-c8wq","reference_id":"","reference_type":"","scores":[{"value":"6.4","scoring_system":"cvssv3.1","scoring_elements":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N"},{"value":"MODERATE","scoring_system":"generic_textual","scoring_elements":""},{"value":"Track","scoring_system":"ssvc","scoring_elements":"SSVCv2/E:P/A:N/T:P/P:M/B:A/M:M/D:T/2026-05-08T17:08:43Z/"}],"url":"https://github.com/marko-js/marko/security/advisories/GHSA-x9fj-57fh-c8wq"},{"reference_url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41591","reference_id":"","reference_type":"","scores":[{"value":"6.4","scoring_system":"cvssv3.1","scoring_elements":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N"},{"value":"MODERATE","scoring_system":"generic_textual","scoring_elements":""}],"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41591"},{"reference_url":"https://github.com/advisories/GHSA-x9fj-57fh-c8wq","reference_id":"GHSA-x9fj-57fh-c8wq","reference_type":"","scores":[],"url":"https://github.com/advisories/GHSA-x9fj-57fh-c8wq"}],"fixed_packages":[{"url":"http://public2.vulnerablecode.io/api/packages/44659?format=json","purl":"pkg:npm/marko@5.38.36","is_vulnerable":false,"affected_by_vulnerabilities":[],"resource_url":"http://public2.vulnerablecode.io/packages/pkg:npm/marko@5.38.36"}],"aliases":["CVE-2026-41591","GHSA-x9fj-57fh-c8wq"],"risk_score":null,"exploitability":null,"weighted_severity":null,"resource_url":"http://public2.vulnerablecode.io/vulnerabilities/VCID-ffpt-atty-w7aj"}],"fixing_vulnerabilities":[],"risk_score":null,"resource_url":"http://public2.vulnerablecode.io/packages/pkg:npm/marko@5.0.0-next.77"}