Skip to content

fix: prevent prototype pollution in objDeepCopy/objCopyProps#563

Open
MSNev wants to merge 1 commit into
nevware21:mainfrom
MSNev:MSNev/CVE-2026-46681
Open

fix: prevent prototype pollution in objDeepCopy/objCopyProps#563
MSNev wants to merge 1 commit into
nevware21:mainfrom
MSNev:MSNev/CVE-2026-46681

Conversation

@MSNev
Copy link
Copy Markdown
Contributor

@MSNev MSNev commented May 16, 2026

Restrict _copyProps to only copy own properties using objHasOwnProperty and skip dangerous keys (proto, constructor, prototype) to prevent prototype pollution attacks during deep copy operations.

Restrict _copyProps to only copy own properties using objHasOwnProperty
and skip dangerous keys (__proto__, constructor, prototype) to prevent
prototype pollution attacks during deep copy operations.
@MSNev MSNev added this to the 0.14.0 milestone May 16, 2026
Copilot AI review requested due to automatic review settings May 16, 2026 01:34
@MSNev MSNev requested review from a team as code owners May 16, 2026 01:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a prototype pollution vulnerability in objDeepCopy/objCopyProps by restricting copies to own properties and excluding dangerous keys (__proto__, constructor, prototype). It also adds a cross-env NODE_OPTIONS=--no-experimental-strip-types prefix to the node test scripts (presumably to keep ts-mocha working on newer Node versions).

Changes:

  • In _copyProps, guard the iteration with objHasOwnProperty and skip __proto__, constructor, and prototype keys.
  • Import the corresponding constants and the objHasOwnProperty helper.
  • Update test:node / test:node_esnext to disable Node's experimental type-stripping via cross-env.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/src/object/copy.ts Restrict _copyProps to own, non-dangerous properties to prevent prototype pollution.
package.json Wrap node test scripts with cross-env NODE_OPTIONS=--no-experimental-strip-types to ensure ts-mocha runs correctly.

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.

2 participants