serialize-javascript

Ecosystem: npm

Downloads: 200.12 Mln

Vulnerabilities from the last (months)
  • 0CriticalAffects 0 versions
  • 2HighAffects 2 versions
  • 0MediumAffects 0 versions
  • 3ModerateAffects 3 versions
  • 2LowAffects 2 versions
Severity distribution (all time)
7vulnerabilities
  • Critical0 (0.0%)
  • High2 (28.6%)
  • Medium0 (0.0%)
  • Moderate3 (42.9%)
  • Low2 (28.6%)

Monthly breakdown

  • Critical
  • High
  • Medium
  • Moderate
  • Low
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 0
    • Low: 1
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 0
    • Low: 1
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 1
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 1
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 1
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 1
    • Medium: 0
    • Moderate: 0
    • Low: 0
  • 1 vulnerabilities
    • Critical: 0
    • High: 0
    • Medium: 0
    • Moderate: 1
    • Low: 0

Vulnerabilities (7)

Known vulnerabilities affecting serialize-javascript, based on data from OSV.

Vulnerabilities affecting serialize-javascript
IDSeveritySummaryAffected versionsPublishedSource
GHSA-m5mm-p8h7-m29vLowSerialize JavaScript: Cross-site scripting (XSS) via unescaped </script at the end of a serialized function body### 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 exampl
  • < 7.1.3
GitHub (opens in a new tab)
GHSA-gfhx-hw2g-v5hgLowSerialize JavaScript: Cross-site scripting (XSS) via unescaped </script> in serialized function bodies### 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
  • >= 7.1.1, < 7.1.2
GitHub (opens in a new tab)
GHSA-qj8w-gfj5-8c6vModerateSerialize JavaScript has CPU Exhaustion Denial of Service via crafted array-like objects### Impact **What kind of vulnerability is it?** It is a **Denial of Service (DoS)** vulnerability caused by CPU exhaustion. When serializing a specially crafted "array-like" object (an object that inherits from `Array.prototype` but has a very large `length` property), the process enters an intensive loop that consumes 100% CPU and hangs indefinitely. **Who is impacted?** Applications that use `serialize-javascript` to serialize untrusted or user-controlled objects are at risk. While direct exploitation is difficult, it becomes a high-priority threat if the application is also vulnerable
  • >= 5.0.0, < 7.0.5
GitHub (opens in a new tab)
GHSA-5c6j-r48x-rmvqHighSerialize JavaScript is Vulnerable to RCE via RegExp.flags and Date.prototype.toISOString()### Impact The serialize-javascript npm package (versions <= 7.0.2) contains a code injection vulnerability. It is an incomplete fix for CVE-2020-7660. While `RegExp.source` is sanitized, `RegExp.flags` is interpolated directly into the generated output without escaping. A similar issue exists in `Date.prototype.toISOString()`. If an attacker can control the input object passed to `serialize()`, they can inject malicious JavaScript via the flags property of a RegExp object. When the serialized string is later evaluated (via `eval`, `new Function`, or `<script>` tags), the injected code exec
  • < 7.0.3
GitHub (opens in a new tab)
GHSA-76p7-773f-r4q5ModerateCross-site Scripting (XSS) in serialize-javascriptA flaw was found in npm-serialize-javascript. The vulnerability occurs because the serialize-javascript module does not properly sanitize certain inputs, such as regex or other JavaScript object types, allowing an attacker to inject malicious code. This code could be executed when deserialized by a web browser, causing Cross-site scripting (XSS) attacks. This issue is critical in environments where serialized data is sent to web clients, potentially compromising the security of the website or web application using this package.
  • >= 6.0.0, < 6.0.2
GitHub (opens in a new tab)
GHSA-hxcc-f52p-wc94HighInsecure serialization leading to RCE in serialize-javascriptserialize-javascript prior to 3.1.0 allows remote attackers to inject arbitrary code via the function "deleteFunctions" within "index.js". An object such as `{"foo": /1"/, "bar": "a\"@__R-<UID>-0__@"}` was serialized as `{"foo": /1"/, "bar": "a\/1"/}`, which allows an attacker to escape the `bar` key. This requires the attacker to control the values of both `foo` and `bar` and guess the value of `<UID>`. The UID has a keyspace of approximately 4 billion making it a realistic network attack.
  • < 3.1.0
GitHub (opens in a new tab)
GHSA-h9rv-jmmf-4pgxModerateCross-Site Scripting in serialize-javascriptVersions of `serialize-javascript` prior to 2.1.1 are vulnerable to Cross-Site Scripting (XSS). The package fails to sanitize serialized regular expressions. This vulnerability does not affect Node.js applications. ## Recommendation Upgrade to version 2.1.1 or later.
  • < 2.1.1
GitHub (opens in a new tab)
  • GHSA-m5mm-p8h7-m29vLow
    Serialize JavaScript: Cross-site scripting (XSS) via unescaped </script at the end of a serialized function body
    • < 7.1.3

    ### 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 exampl

    CVE: CVE-2026-115754

  • GHSA-gfhx-hw2g-v5hgLow
    Serialize JavaScript: Cross-site scripting (XSS) via unescaped </script> in serialized function bodies
    • >= 7.1.1, < 7.1.2

    ### 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

    CVE: CVE-2026-97711

  • GHSA-qj8w-gfj5-8c6vModerate
    Serialize JavaScript has CPU Exhaustion Denial of Service via crafted array-like objects
    • >= 5.0.0, < 7.0.5

    ### Impact **What kind of vulnerability is it?** It is a **Denial of Service (DoS)** vulnerability caused by CPU exhaustion. When serializing a specially crafted "array-like" object (an object that inherits from `Array.prototype` but has a very large `length` property), the process enters an intensive loop that consumes 100% CPU and hangs indefinitely. **Who is impacted?** Applications that use `serialize-javascript` to serialize untrusted or user-controlled objects are at risk. While direct exploitation is difficult, it becomes a high-priority threat if the application is also vulnerable

    CVE: CVE-2026-34043

  • GHSA-5c6j-r48x-rmvqHigh
    Serialize JavaScript is Vulnerable to RCE via RegExp.flags and Date.prototype.toISOString()
    • < 7.0.3

    ### Impact The serialize-javascript npm package (versions <= 7.0.2) contains a code injection vulnerability. It is an incomplete fix for CVE-2020-7660. While `RegExp.source` is sanitized, `RegExp.flags` is interpolated directly into the generated output without escaping. A similar issue exists in `Date.prototype.toISOString()`. If an attacker can control the input object passed to `serialize()`, they can inject malicious JavaScript via the flags property of a RegExp object. When the serialized string is later evaluated (via `eval`, `new Function`, or `<script>` tags), the injected code exec

  • GHSA-76p7-773f-r4q5Moderate
    Cross-site Scripting (XSS) in serialize-javascript
    • >= 6.0.0, < 6.0.2

    A flaw was found in npm-serialize-javascript. The vulnerability occurs because the serialize-javascript module does not properly sanitize certain inputs, such as regex or other JavaScript object types, allowing an attacker to inject malicious code. This code could be executed when deserialized by a web browser, causing Cross-site scripting (XSS) attacks. This issue is critical in environments where serialized data is sent to web clients, potentially compromising the security of the website or web application using this package.

    CVE: CVE-2024-11831

  • GHSA-hxcc-f52p-wc94High
    Insecure serialization leading to RCE in serialize-javascript
    • < 3.1.0

    serialize-javascript prior to 3.1.0 allows remote attackers to inject arbitrary code via the function "deleteFunctions" within "index.js". An object such as `{"foo": /1"/, "bar": "a\"@__R-<UID>-0__@"}` was serialized as `{"foo": /1"/, "bar": "a\/1"/}`, which allows an attacker to escape the `bar` key. This requires the attacker to control the values of both `foo` and `bar` and guess the value of `<UID>`. The UID has a keyspace of approximately 4 billion making it a realistic network attack.

    CVE: CVE-2020-7660

  • GHSA-h9rv-jmmf-4pgxModerate
    Cross-Site Scripting in serialize-javascript
    • < 2.1.1

    Versions of `serialize-javascript` prior to 2.1.1 are vulnerable to Cross-Site Scripting (XSS). The package fails to sanitize serialized regular expressions. This vulnerability does not affect Node.js applications. ## Recommendation Upgrade to version 2.1.1 or later.

    CVE: CVE-2019-16769

Showing 1-7 of 7 vulnerabilities