{"id":"CVE-2026-115754","aliases":["CVE-2026-115754","GHSA-m5mm-p8h7-m29v"],"related":["CVE-2026-115897"],"kind":"vulnerability","state":"published","title":"serialize-javascript 7.0.1 before 7.1.3 XSS via unescaped </script in function body","summary":"serialize-javascript from 7.0.1 before 7.1.3 contains a cross-site scripting vulnerability that allows attackers to break out of HTML script elements by ending serialized function source text with an unescaped </script. Attackers controlling a function's source via a spoofed toString() can combine surrounding output delimiters and later values to inject live markup such as img onerror handlers.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"serialize-javascript from 7.0.1 before 7.1.3 contains a cross-site scripting vulnerability that allows attackers to break out of HTML script elements by ending serialized function source text with an unescaped </script. Attackers controlling a function's source via a spoofed toString() can combine surrounding output delimiters and later values to inject live markup such as img onerror handlers.","source":"cvelist"},{"lang":"en","text":"### Impact\n\n`serialize-javascript` escapes its output so it is safe to embed inside a\n`<script>` element. Before 7.1.3 that guarantee did not hold for a **function\nvalue whose source ends in a bare `</script`**.\n\nEach function body is escaped on its own, and a bare `</script` was only\nneutralized when followed — within the same body — by a character the HTML\ntokenizer treats as ending the tag name (TAB, LF, FF, CR, SPACE, `/` or `>`).\nA body ending exactly at `</script` has no following character, so it was\nemitted unescaped. The delimiter is then supplied by the surrounding output\n(for example the newline the `space` option emits after the value), and a\nlater serialized value can supply the closing `>` followed by markup:\n\n```js\nconst serialize = require('serialize-javascript');\nfunction f() {} f.toString = () => 'function f(){ return 1 }//</script';\nfunction g() {} g.toString = () => 'function g(x){ return x } > <img src=x onerror=alert(1)>';\nserialize({ a: { f }, g }, { space: 2 });\n// {\n//   \"a\": {\n//     \"f\": function f(){ return 1 }//</script\n//   },\n//   \"g\": function g(x){ return x } > <img src=x onerror=alert(1)>\n// }\n```\n\nEmbedded in a `<script>` element, the script ends at the injected tag and the\n`<img>` becomes a live element in the page.\n\nExploitation requires an attacker to control the **source text** of a\nserialized function, in practice through a spoofed `toString()`. Real\nfunctions always end in `}`, so ordinary function values are not affected,\nand non-function values (including strings containing `</script`) are\nescaped correctly.\n\n### Patches\n\nFixed in **7.1.3** (#235). The bare `</script` form is now also matched at\nthe end of the function body, so it is escaped regardless of what follows it\nin the output.\n\n### Workarounds\n\nUpgrade to **7.1.3**. If you cannot upgrade, do not serialize function values\nwhose source text (or `toString()`) can be influenced by an attacker.\n\n### Credits\n\nReported by **ha_kr25** via the Yahoo bug bounty program.","format":"markdown","source":"ghsa"}],"published":"2026-10-23T13:20:43.932Z","modified":"2026-10-24T02:55:55.507Z","severity":{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":2.3,"rating":"LOW"},"severities":[{"scorer":"VulnCheck","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","score":2.3,"rating":"LOW"},{"scorer":"VulnCheck","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","score":4.7,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:P/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N","rating":"LOW"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"type":"semver","introduced":"7.0.1","fixed":"7.1.3","status":"affected"}],"vendor":"yahoo","product":"serialize-javascript","repo":"https://github.com/yahoo/serialize-javascript","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"7.1.3"}],"ecosystem":"npm","package":"serialize-javascript","purl":"pkg:npm/serialize-javascript","source":"ghsa"}],"references":[{"url":"https://github.com/yahoo/serialize-javascript/security/advisories/GHSA-m5mm-p8h7-m29v","tags":["vendor-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/yahoo/serialize-javascript/pull/235","tags":["issue-tracking","patch","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/yahoo/serialize-javascript/commit/2864b3c6260a3bfd52d2db3e70d1a079de108a61","tags":["patch","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/yahoo/serialize-javascript/releases/tag/v7.1.3","tags":["release-notes","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.vulncheck.com/advisories/serialize-javascript-7.0.1-before-7.1.3-xss-via-unescaped-script-in-function-body","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://github.com/yahoo/serialize-javascript","tags":["package"],"sources":["ghsa"]}],"credits":["Zachariah Mithani (AploSec)"],"assigner":"VulnCheck","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-10-23T14:48:53.139Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-115754","url":"https://www.cve.org/CVERecord?id=CVE-2026-115754","licence":"CVE Terms of Use","modified":"2026-10-23T14:58:11.402Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-m5mm-p8h7-m29v","url":"https://github.com/advisories/GHSA-m5mm-p8h7-m29v","licence":"CC-BY-4.0","modified":"2026-10-24T02:55:55.507Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-115754","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-115754","licence":"Public domain","modified":"2026-10-23T19:45:03.547Z"}],"updatedAt":"2026-11-25T22:59:46.978Z","epss":{"score":0.00228,"percentile":0.14516,"date":"2026-12-01T12:00:22.000Z"}}