Skip to content

Prototype Pollution in objDeepCopy/objCopyProps via for...in without hasOwnProperty

High
nev21 published GHSA-x7j8-49r8-mr43 May 19, 2026

Package

npm @nevware21/ts-utils (npm)

Affected versions

<= 0.13.0

Patched versions

0.14.0

Description

Summary

The _copyProps function in lib/src/object/copy.ts uses for...in to iterate over source object properties without an Object.hasOwnProperty check, and does not filter dangerous keys (proto, constructor, prototype). This allows an attacker to pollute the prototype chain of all objects in the application.

Details

In _copyProps() (copy.ts lines 186-191), the code iterates all enumerable properties including inherited ones and dangerous keys like proto. Any object with a proto key (e.g., from untrusted JSON input) will overwrite the target's prototype.

PoC

const malicious = JSON.parse('{"proto": {"polluted": true}}');
objDeepCopy(malicious);
console.log({}.polluted); // true

Suggested Fix

Add objHasOwnProperty check and filter proto, constructor, prototype keys.

Severity

High (CVSS ~7.5) - requires attacker-controlled input to reach objDeepCopy, but impact is global prototype pollution.

Severity

High

CVE ID

CVE-2026-46681

Weaknesses

Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. Learn more on MITRE.