Live › vulnerability › CVE-2026-115897
Go to dashboardserialize-javascript fails to escape a bare closing script tag at the end of a serialized function's source text before version 7.1.3. An attacker who controls a function's toString output can break out of a script element and inject HTML such as an img tag that runs JavaScript in the page.
Summary written from the sources below. Check the originals before acting.
First seen by InfraStack 2026-10-23 22:15 UTC, 0h before NVD. All times on this page are UTC.
Applications that embed output from serialize-javascript inside a script element in a page and serialize function values. Exposure also requires that an attacker can control the source text of a serialized function, in practice through a spoofed toString. Ordinary function values and non-function values are not affected, so projects that serialize only data can skip it.
| Product | Ecosystem | Affected | Fixed in |
|---|---|---|---|
| serialize-javascript | npm | < 7.1.3 | 7.1.3 |
npm ls serialize-javascript in each project to find the installed version.package-lock.json, yarn.lock, pnpm-lock.yaml) for serialize-javascript below 7.1.3.serialize-javascript to 7.1.3 or later.Each row is the first time that source carried this signal. The analyst’s rows are its own findings.
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.
This page as .md · .json · in your agent: get_signal("CVE-2026-115897")
GitHub Advisory Database, CC-BY 4.0 · NVD data is provided by NIST and is public domain · EPSS scores by FIRST, used with attribution. Posts quoted belong to their authors.