Serialize JavaScript: Cross-site scripting (XSS) via unescaped in serialized function bodies
### Impact `serialize-javascript` escapes its output so it is safe to embed inside a `` into the output, terminating the script element early so the remainder is parsed as HTML. `SCRIPT_CLOSE_REGEXP` used `<\/script[^>]*>` as its first alternative. The character class excludes only `>`, so a single match could run from one `` anywhere in the source — swallowing a second, complete `` along the way. Only one replacement is emitted per match, and the plain-code branch neutralizes just the leading `<` (`'< ' + match.slice(1)`), so the swallowed tag was re-emitted verbatim. Reaching that shape requires `' }} ``` Embedded as the README documents (``) and parsed by Chromium, the script element ends at the injected tag and the `` becomes a live DOM node with its `onerror` handler executing in the page origin. Only the function path is affected. The same payload passed as **data** is escaped correctly, and `options.isJSON` / non-function values are unaffected. ### Patches Fixed in **7.1.2**. The wildcard now excludes `<` as well as `>` (`[^<>]*`), so a match can never reach past a second `<`. Every ``, and emits anything else as text. ### Workarounds Upgrade to **7.1.2**. If you cannot upgrade, 7.1.0 and earlier are unaffected, or avoid serializing functions whose source text is attacker-influenced. ### Regression note This is a regression specific to 7.1.1, not a long-standing issue. 7.1.0 and earlier applied the same wildcard but escaped the **entire** match, so no tag survived. Dow
GHSA-gfhx-hw2g-v5hg
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: osv:GHSA-gfhx-hw2g-v5hg
serialize-javascript
Source reference: /affected/0/package/name
- Affected versions
- Not stated in this record
- Fixed versions
- 7.1.2
Source reference:
/affected/0/ranges - Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"ranges": [
{
"type": "SEMVER",
"events": [
{
"introduced": "7.1.1"
},
{
"fixed": "7.1.2"
}
]
}
],
"package": {
"name": "serialize-javascript",
"purl": "pkg:npm/serialize-javascript",
"ecosystem": "npm"
},
"database_specific": {
"source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-gfhx-hw2g-v5hg/GHSA-gfhx-hw2g-v5hg.json"
}
}
]- Related CVEs
- CVE-2026-97711
Source reference:
/aliases
Publisher severity
low
Source reference: /database_specific/severity
- Event
- #39374 · Revision 1
- Added to Heist Feed
- Publisher date