CVE-2026-115897Low· 2.1▾ SunlitSerialize JavaScript: Cross-site scripting (XSS) via unescaped </script at the end of a serialized function body
▾ Sunlit zone — Low / medium · no exploitation signal
impact 11.6 · likelihood 0 · exploitation 0
Need a working PoC? Pro members can cast a request and our team develops one — it lands right here.
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:
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.
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.
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.
Reported by ha_kr25 via the Yahoo bug bounty program.
serialize-javascript < 7.1.3Upgrade to a patched release:
serialize-javascript 7.1.3Connected by shared product, vendor, weakness, or advisory.
CVE-2026-115754Medium· 4.7serialize-javascript 7.0.1 before 7.1.3 XSS via unescaped </script in function body
CVE-2026-97711Low· 2.3Serialize JavaScript serializes JavaScript values to a superset of JSON that includes regular expressions and functions
CVE-2024-11831Medium· 5.4A flaw was found in npm-serialize-javascript
CVE-2021-41164High· 8.2CKEditor4 is an open source WYSIWYG HTML editor
CVE-2021-41184Medium· 6.5jQuery-UI is the official jQuery user interface library
CVE-2021-41183Medium· 6.5jQuery-UI is the official jQuery user interface library