in serialized function bodies under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)."}},{"@type":"Question","name":"Which Serialize JavaScript versions are affected?","acceptedAnswer":{"@type":"Answer","text":"Affected versions include releases prior to 7.1.2 across affected packages: serialize-javascript."}},{"@type":"Question","name":"What version fixes CVE-2026-97711?","acceptedAnswer":{"@type":"Answer","text":"Upgrading to 7.1.2 (or the latest patched release for your respective branch) resolves the vulnerability."}},{"@type":"Question","name":"Is serialize-javascript affected?","acceptedAnswer":{"@type":"Answer","text":"Yes, serialize-javascript is affected in releases prior to 7.1.2. Upgrade your dependency to 7.1.2 or later."}},{"@type":"Question","name":"What CWE is associated with CVE-2026-97711?","acceptedAnswer":{"@type":"Answer","text":"CVE-2026-97711 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as \"<\", \">\", and \"&\" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.)."}},{"@type":"Question","name":"How can I check npm dependencies for CVE-2026-97711?","acceptedAnswer":{"@type":"Answer","text":"Run the dependency tree command: 'npm ls serialize-javascript'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved."}}]}

CVE-2026-97711: Serialize JavaScript Cross-Site Scripting Vulnerability

LOW
Advisory Identifier: GHSA-gfhx-hw2g-v5hg
CWE-80 CWE-79
Published
Advisory Summary

CVE-2026-97711 is a LOW cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Serialize JavaScript libraries in the npm ecosystem. The issue involves cross-site scripting (xss) via unescaped </script> in serialized function bodies. Remediation is available by upgrading affected packages to version 7.1.2.

CVE-2026-97711 at a Glance

CVE Identifier CVE-2026-97711
GHSA Identifier GHSA-gfhx-hw2g-v5hg
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Serialize JavaScript
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2026-97711

To remediate this vulnerability, upgrade all affected Serialize JavaScript dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

serialize-javascript fixed: 7.1.2
npm install serialize-javascript@7.1.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls serialize-javascript

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-97711, inspect your project dependencies using npm:

npm ls serialize-javascript

Analyze the terminal output to locate any version of Serialize JavaScript in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.1.2), your application is affected.

Note: The npm ls serialize-javascript command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Serialize JavaScript, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact `serialize-javascript` escapes its output so it is safe to embed inside a `<script>` element. In 7.1.1 that guarantee does not hold for **function values**: a crafted function body can carry a literal, unescaped `</script>` 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 `</script` all the way to the next `>` anywhere in the source — swallowing a second, complete `</script>` 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 `</script` in code position, which is legal JavaScript: `x</script=+/` parses as `x < /script=+/`, a comparison against a regex literal. ```js const serialize = require('serialize-javascript'); const src = "function f(x){ return x</script=+/ + '</script><img src=x onerror=alert(1)>' }"; const out = serialize({ h: new Function('return ' + src)() }); // {"h":function f(x){ return x< /script=+/ + '</script><img src=x onerror=alert(1)>' }} ``` Embedded as the README documents (`<script>window.S = <%= serialize(state) %></script>`) and parsed by Chromium, the script element ends at the injected tag and the `<img>` 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 `</script` in the source therefore either begins its own match or is followed by a character the HTML tokenizer does not accept as ending a tag name — it ends the tag name only on TAB, LF, FF, CR, SPACE, `/` or `>`, 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. Downstream scanners defaulting to a `>= 7.1.0` range would be overly broad.

CVE-2026-97711 Affected Serialize JavaScript Versions

1 component(s)
Fixed Versions:
7.1.2
Product / Package Ecosystem Affected Versions Fixed Version
serialize-javascript
npm
≥ 7.1.1
< 7.1.2
7.1.2

References

Frequently Asked Questions

What is CVE-2026-97711?
CVE-2026-97711 is a security vulnerability in Serialize JavaScript involving Cross-site scripting (XSS) via unescaped </script> in serialized function bodies under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Serialize JavaScript versions are affected?
Affected versions include releases prior to 7.1.2 across affected packages: serialize-javascript.
What version fixes CVE-2026-97711?
Upgrading to 7.1.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is serialize-javascript affected?
Yes, serialize-javascript is affected in releases prior to 7.1.2. Upgrade your dependency to 7.1.2 or later.
What CWE is associated with CVE-2026-97711?
CVE-2026-97711 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check npm dependencies for CVE-2026-97711?
Run the dependency tree command: 'npm ls serialize-javascript'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gfhx-hw2g-v5hg",
  "modified" : "2026-09-30T15:40:06Z",
  "published" : "2026-09-30T15:40:05Z",
  "aliases" : [ "CVE-2026-97711" ],
  "summary" : "Serialize JavaScript: Cross-site scripting (XSS) via unescaped </script> in serialized function bodies",
  "details" : "### Impact\n\n`serialize-javascript` escapes its output so it is safe to embed inside a\n`<script>` element. In 7.1.1 that guarantee does not hold for **function\nvalues**: a crafted function body can carry a literal, unescaped `</script>`\ninto the output, terminating the script element early so the remainder is\nparsed as HTML.\n\n`SCRIPT_CLOSE_REGEXP` used `<\\/script[^>]*>` as its first alternative. The\ncharacter class excludes only `>`, so a single match could run from one\n`</script` all the way to the next `>` anywhere in the source — swallowing a\nsecond, complete `</script>` along the way. Only one replacement is emitted\nper match, and the plain-code branch neutralizes just the leading `<`\n(`'< ' + match.slice(1)`), so the swallowed tag was re-emitted verbatim.\n\nReaching that shape requires `</script` in code position, which is legal\nJavaScript: `x</script=+/` parses as `x < /script=+/`, a comparison against a\nregex literal.\n\n```js\nconst serialize = require('serialize-javascript');\nconst src = \"function f(x){ return x</script=+/ + '</script><img src=x onerror=alert(1)>' }\";\nconst out = serialize({ h: new Function('return ' + src)() });\n// {\"h\":function f(x){ return x< /script=+/ + '</script><img src=x onerror=alert(1)>' }}\n```\n\nEmbedded as the README documents (`<script>window.S = <%= serialize(state) %></script>`)\nand parsed by Chromium, the script element ends at the injected tag and the\n`<img>` becomes a live DOM node with its `onerror` handler executing in the\npage origin.\n\nOnly the function path is affected. The same payload passed as **data** is\nescaped correctly, and `options.isJSON` / non-function values are unaffected.\n\n### Patches\n\nFixed in **7.1.2**. The wildcard now excludes `<` as well as `>`\n(`[^<>]*`), so a match can never reach past a second `<`. Every `</script`\nin the source therefore either begins its own match or is followed by a\ncharacter the HTML tokenizer does not accept as ending a tag name — it ends\nthe tag name only on TAB, LF, FF, CR, SPACE, `/` or `>`, and emits anything\nelse as text.\n\n### Workarounds\n\nUpgrade to **7.1.2**. If you cannot upgrade, 7.1.0 and earlier are\nunaffected, or avoid serializing functions whose source text is\nattacker-influenced.\n\n### Regression note\n\nThis is a regression specific to 7.1.1, not a long-standing issue. 7.1.0 and\nearlier applied the same wildcard but escaped the **entire** match, so no tag\nsurvived. Downstream scanners defaulting to a `>= 7.1.0` range would be\noverly broad.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "serialize-javascript"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.1.1"
      }, {
        "fixed" : "7.1.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/yahoo/serialize-javascript/security/advisories/GHSA-gfhx-hw2g-v5hg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-97711"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yahoo/serialize-javascript/commit/2bdbaaff9cb8a4639135eb24cfcd383d3fefb534"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yahoo/serialize-javascript"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yahoo/serialize-javascript/releases/tag/v7.1.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-30T15:40:05Z",
    "nvd_published_at" : "2026-09-29T16:17:19Z"
  }
}