enhancement
major
minor
major
minor
critical
#29984
Update dependency serialize-javascript to ^7.1.3 [SECURITY]
This PR contains the following updates:
| Package | Type | Update | Change |
| --- | --- | --- | --- |
| serialize-javascript | overrides | patch | ^7.0.3 → ^7.1.3 |
---
⚠️ Warning
Some dependencies could not be looked up. Check the warning logs for more information.
---
Serialize JavaScript: Cross-site scripting (XSS) via unescaped </script at the end of a serialized function body
CVE-2026-115754 / CVE-2026-115897 / GHSA-m5mm-p8h7-m29v
Details
##### Impact
serialize-javascript escapes its output so it is safe to embed inside a <script> element. Before 7.1.3 that guarantee did not hold for a **function value whose source ends in a bare </script **.
Each function body is escaped on its own, and a bare </script was only neutralized when followed — within the same body — by a character the HTML tokenizer treats as ending the tag name (TAB, LF, FF, CR, SPACE, / or > ). A body ending exactly at </script has no following character, so it was emitted unescaped. The delimiter is then supplied by the surrounding output (for example the newline the space option emits after the value), and a later serialized value can supply the closing > followed by markup:
{{{js const serialize = require('serialize-javascript'); function f() {} f.toString = () => 'function f(){ return 1 }//</script'; function g() {} g.toString = () => 'function g(x){ return x } > <img src=x onerror=alert(1)>'; serialize({ a: { f }, g }, { space: 2 }); // { // "a": { // "f": function f(){ return 1 }//</script // }, // "g": function g(x){ return x } > <img src=x onerror=alert(1)> // }
Embedded in a <script> element, the script ends at the injected tag and the <img> becomes a live element in the page. Exploitation requires an attacker to control the '''source text''' of a serialized function, in practice through a spoofed toString() . Real functions always end in } , so ordinary function values are not affected, and non-function values (including strings containing </script ) are escaped correctly. ##### Patches Fixed in '''7.1.3''' (#235). The bare </script form is now also matched at the end of the function body, so it is escaped regardless of what follows it in the output. ##### Workarounds Upgrade to '''7.1.3'''. If you cannot upgrade, do not serialize function values whose source text (or toString() ) can be influenced by an attacker. ##### Credits Reported by '''ha_kr25''' via the Yahoo bug bounty program. === Severity === - CVSS Score: 2.1 / 10 (Low) - Vector String: 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 === References === - [https://github.com/yahoo/serialize-javascript/security/advisories/GHSA-m5mm-p8h7-m29v https://github.com/yahoo/serialize-javascript/security/advisories/GHSA-m5mm-p8h7-m29v] - [https://github.com/yahoo/serialize-javascript/pull/235 https://github.com/yahoo/serialize-javascript/pull/235] - [https://github.com/yahoo/serialize-javascript/commit/2864b3c6260a3bfd52d2db3e70d1a079de108a61 https://github.com/yahoo/serialize-javascript/commit/2864b3c6260a3bfd52d2db3e70d1a079de108a61] - [https://github.com/yahoo/serialize-javascript https://github.com/yahoo/serialize-javascript] - [https://github.com/yahoo/serialize-javascript/releases/tag/v7.1.3 https://github.com/yahoo/serialize-javascript/releases/tag/v7.1.3] This data is provided by [https://osv.dev/vulnerability/GHSA-m5mm-p8h7-m29v OSV] and the [https://github.com/github/advisory-database GitHub Advisory Database] ([https://github.com/github/advisory-database/blob/main/LICENSE.md CC-BY 4.0]). --- == Release Notes == == [https://github.com/yahoo/serialize-javascript/releases/tag/v7.1.3 v7.1.3 ] == [https://github.com/yahoo/serialize-javascript/compare/v7.1.2...v7.1.3 Compare Source] See: <https://github.com/yahoo/serialize-javascript/security/advisories/GHSA-m5mm-p8h7-m29v> === What's Changed === - fix: escape </script at the end of a serialized function body by [https://github.com/redonkulus @redonkulus] in [https://github.com/yahoo/serialize-javascript/pull/235 #235] - Fix serialization of Dates with expanded ISO years by [https://github.com/Shubham-Padkonde @Shubham-Padkonde] in [https://github.com/yahoo/serialize-javascript/pull/232 #232] - fix: ignore functions without mutating input objects by [https://github.com/Shubham-Padkonde @Shubham-Padkonde] in [https://github.com/yahoo/serialize-javascript/pull/233 #233] - release: v7.1.3 by [https://github.com/redonkulus @redonkulus] in [https://github.com/yahoo/serialize-javascript/pull/236 #236] ##### Note on ignoreFunction With ignoreFunction: true , function values are now omitted the same way JSON.stringify omits them, without deleting them from the input object. Functions inside arrays are emitted as null (previously this produced Array.prototype.slice.call(...) output). === New Contributors === - [https://github.com/Shubham-Padkonde @Shubham-Padkonde] made their first contribution in [https://github.com/yahoo/serialize-javascript/pull/232 #232] '''Full Changelog''': <https://github.com/yahoo/serialize-javascript/compare/v7.1.2...v7.1.3> ---