CVE-2020-7638 (published 2020-04-06T13:15Z)

confinit through 0.3.0 is vulnerable to Prototype Pollution.The 'setDeepProperty' function could be tricked into adding or modifying properties of 'Object.prototype' using a '__proto__' payload.

Severity: MEDIUM
CVSS v2 base score: 5.0 (AV:N/AC:L/Au:N/C:N/I:P/A:N)
CVSS v3 base score: 5.3, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N)

Weakness information:
cwe_id: CWE-1321
cwe_name: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
description: 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.
extended_description: 
				By adding or modifying attributes of an object prototype, it is possible to create attributes that exist on every object, or replace critical attributes with malicious ones. This can be problematic if the product depends on existence or non-existence of certain attributes, or uses pre-defined attributes of object prototype (such as hasOwnProperty, toString or valueOf).
				This weakness is usually exploited by using a special attribute of objects called proto,  constructor or prototype. Such attributes give access to the object prototype. This weakness is often found in code that assigns object attributes based on user input, or merges or clones objects recursively.
			
			

Fix information:
repo_url: https://github.com/davideicardi/confinit
commit_details: repo_url: https://github.com/davideicardi/confinit
author: Davide Icardi
author_date: 2020-03-01 10:59:42+01:00
msg: Close #1
repository: repo_url: https://github.com/davideicardi/confinit
repo_name: davideicardi/confinit
description: Configuration library for Node.Js
repo_language: TypeScript
owner: davideicardi
file_changes: filename: index.d.ts
change_type: ModificationType.MODIFY
diff: @@ -6,6 +6,8 @@ export declare function validate(configuration: any): void;
 export declare function applyEnvVariables(configuration: any, envVariables: NodeJS.ProcessEnv, envPrefix?: string): void;
 export declare function applyConfigFile(configuration: any, configFile: string): void;
 export declare function applyCommandArgs(configuration: any, argv: string[]): void;
-export declare function setDeepProperty(obj: any, propertyPath: string, value: any): void;
+export declare function setDeepProperty(obj: {
+    [key: string]: any;
+}, propertyPath: string, value: any): void;
 export declare function getDeepProperty(obj: any, propertyPath: string): any;
 export declare function objectsAreEqual(obj1: any, obj2: any, leftOnly?: boolean): boolean;

programming_language: TypeScript
filename: index.js
change_type: ModificationType.MODIFY
diff: @@ -58,14 +58,24 @@ function applyCommandArgs(configuration, argv) {
         return;
     }
     debug("Appling command arguments:", parsedArgv);
-    if (parsedArgv.config) {
-        const configFile = path.resolve(process.cwd(), parsedArgv.config);
+    const CONFIG_PROP = 'config';
+    if (parsedArgv[CONFIG_PROP]) {
+        const configFile = path.resolve(process.cwd(), parsedArgv[CONFIG_PROP]);
         applyConfigFile(configuration, configFile);
     }
     for (const key in parsedArgv) {
         if (!parsedArgv.hasOwnProperty(key)) {
             continue;
         }
+        if (key.startsWith('_')) {
+            continue;
+        }
+        if (key.endsWith('_')) {
+            continue;
+        }
+        if (key === CONFIG_PROP) {
+            continue;
+        }
         const configKey = key
             .replace(/_/g, ".");
         debug(`Found config value from cmd args '${key}' to '${configKey}'`);
@@ -74,19 +84,37 @@ function applyCommandArgs(configuration, argv) {
 }
 exports.applyCommandArgs = applyCommandArgs;
 function setDeepProperty(obj, propertyPath, value) {
-    const a = splitPath(propertyPath);
-    const n = a.length;
-    for (let i = 0; i < n - 1; i++) {
-        const k = a[i];
-        if (!(k in obj)) {
-            obj[k] = {};
+    if (!obj) {
+        throw new Error("Invalid object");
+    }
+    if (!propertyPath) {
+        throw new Error("Invalid property path");
+    }
+    const pathParts = splitPath(propertyPath);
+    const pathPartsLen = pathParts.length;
+    for (let i = 0; i < pathPartsLen - 1; i++) {
+        const pathPart = pathParts[i];
+        if (!(pathPart in obj)) {
+            setProp(obj, pathPart, {});
         }
-        obj = obj[k];
+        obj = getProp(obj, pathPart);
     }
-    obj[a[n - 1]] = value;
+    setProp(obj, pathParts[pathPartsLen - 1], value);
     return;
 }
 exports.setDeepProperty = setDeepProperty;
+function setProp(obj, property, value) {
+    if (!obj.hasOwnProperty(property)) {
+        throw new Error(`Property '${property}' is not valid`);
+    }
+    obj[property] = value;
+}
+function getProp(obj, property) {
+    if (!obj.hasOwnProperty(property)) {
+        throw new Error(`Property '${property}' is not valid`);
+    }
+    return obj[property];
+}
 function getDeepProperty(obj, propertyPath) {
     let ret = obj;
     const a = splitPath(propertyPath);

programming_language: TypeScript
filename: index.js.map
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAE7B,+BAA+B;AAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AAG9B,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAMtC,SAAS,SAAS,CAAC,KAAU;IAC5B,OAAO,KAAK,IAAK,KAAwB,CAAC,QAAQ,KAAK,SAAS,CAAC;AAClE,CAAC;AAED,SAAgB,QAAQ,CAAC,aAAkB;IAC1C,KAAK,MAAM,cAAc,IAAI,aAAa,EAAE;QAC3C,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;YAClD,SAAS;SACT;QAED,MAAM,KAAK,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5C,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACrB,KAAK,CAAC,QAAQ,EAAE,CAAC;SACjB;KACD;AACF,CAAC;AAXD,4BAWC;AAED,SAAgB,iBAAiB,CAAC,aAAkB,EAAE,YAA+B,EAAE,SAAS,GAAG,UAAU;IAC5G,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE;QAClC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC;eACpC,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ;eACxC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;eAC7B,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,EAAE;YACtC,SAAS;SACT;QAED,MAAM,SAAS,GAAG,MAAM;aACtB,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;aACxB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;Q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xC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;YAC5B,OAAO,KAAK,CAAC;SACb;QAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YACvC,OAAO,KAAK,CAAC;SACb;KACD;IAED,IAAI,CAAC,QAAQ,EAAE;QACd,0CAA0C;QAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;gBAC5B,SAAS;aACT;YAED,wCAAwC;YACxC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;gBAC5B,OAAO,KAAK,CAAC;aACb;SACD;KACD;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAlDD,0CAkDC;AAED,SAAS,SAAS,CAAC,YAAoB;IACtC,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,gCAAgC;IAC1F,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAW,sBAAsB;IAChF,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC/B,2CAA2C;IAC3C,MAAM,SAAS,GAAG,0QAA0Q,CAAC;IAC7R,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
\ No newline at end of file

programming_language: Scala
filename: index.ts
change_type: ModificationType.MODIFY
diff: @@ -75,8 +75,10 @@ export function applyCommandArgs(configuration: any, argv: string[]) {
 
 	debug("Appling command arguments:", parsedArgv);
 
-	if (parsedArgv.config) {
-		const configFile = path.resolve(process.cwd(), parsedArgv.config);
+	const CONFIG_PROP = 'config';
+
+	if (parsedArgv[CONFIG_PROP]) {
+		const configFile = path.resolve(process.cwd(), parsedArgv[CONFIG_PROP]);
 		applyConfigFile(configuration, configFile);
 	}
 
@@ -85,6 +87,16 @@ export function applyCommandArgs(configuration: any, argv: string[]) {
 			continue;
 		}
 
+		if (key.startsWith('_')) {
+			continue;
+		}
+		if (key.endsWith('_')) {
+			continue;
+		}
+		if (key === CONFIG_PROP) {
+			continue;
+		}
+
 		const configKey = key
 			.replace(/_/g, ".");
 
@@ -95,24 +107,44 @@ export function applyCommandArgs(configuration: any, argv: string[]) {
 }
 
 
-export function setDeepProperty(obj: any, propertyPath: string, value: any): void {
-	const a = splitPath(propertyPath);
-	const n = a.length;
+export function setDeepProperty(obj: {[key: string]: any}, propertyPath: string, value: any): void {
+	if (!obj) {
+		throw new Error("Invalid object");
+	}
+	if (!propertyPath) {
+		throw new Error("Invalid property path");
+	}
 
-	for (let i = 0; i < n - 1; i++) {
-		const k = a[i];
+	const pathParts = splitPath(propertyPath);
+	const pathPartsLen = pathParts.length;
+
+	for (let i = 0; i < pathPartsLen - 1; i++) {
+		const pathPart = pathParts[i];
 
-		if (!(k in obj)) {
-			obj[k] = {};
+		if (!(pathPart in obj)) {
+			setProp(obj, pathPart, {});
 		}
-		obj = obj[k];
+		obj = getProp(obj, pathPart);
 	}
 
-
-	obj[a[n - 1]] = value;
+	setProp(obj, pathParts[pathPartsLen - 1], value);
 	return;
 }
 
+function setProp(obj: {[key: string]: any}, property: string, value: any): void {
+	if (!obj.hasOwnProperty(property)) {
+		throw new Error(`Property '${property}' is not valid`);
+	}
+	obj[property] = value;
+}
+
+function getProp(obj: {[key: string]: any}, property: string): any {
+	if (!obj.hasOwnProperty(property)) {
+		throw new Error(`Property '${property}' is not valid`);
+	}
+	return obj[property];
+}
+
 export function getDeepProperty(obj: any, propertyPath: string): any {
 	let ret: any = obj;
 

programming_language: TypeScript
filename: index.js
change_type: ModificationType.MODIFY
diff: @@ -1,4 +1,5 @@
 "use strict";
+// See README.md for details
 Object.defineProperty(exports, "__esModule", { value: true });
 const confinit = require("../index");
 const path = require("path");
@@ -36,11 +37,14 @@ class Configuration {
         if (!env) {
             env = process.env;
         }
+        // Enable config file
         if (env.config) {
             const configFile = path.resolve(process.cwd(), env.config);
             confinit.applyConfigFile(this, configFile);
         }
+        // Enable environment variables
         confinit.applyEnvVariables(this, process.env, "cfg_");
+        // Enable command arguments
         confinit.applyCommandArgs(this, process.argv);
         confinit.validate(this);
     }

programming_language: TypeScript
filename: index.js.map
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AACrC,6BAA6B;AAE7B,MAAa,cAAc;IAA3B;QACC,QAAG,GAAW,EAAE,CAAC;IAOlB,CAAC;IALA,QAAQ;QACP,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC1C;IACF,CAAC;CACD;AARD,wCAQC;AAED,MAAa,eAAe;IAG3B;QAFA,SAAI,GAAG,IAAI,CAAC;QAGX,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjC,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SAClC;IACF,CAAC;IAED,QAAQ;QACP,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;SAChC;QACD,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;CACD;AAhBD,0CAgBC;AAED,MAAa,aAAa;IAIzB,YAAY,GAAuB;QAH1B,aAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QAChC,cAAS,GAAG,IAAI,eAAe,EAAE,CAAC;QAG1C,IAAI,CAAC,GAAG,EAAE;YACT,GA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CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD;AArBD,sCAqBC;AAED,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACpC,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;AAEnC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACzB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC7B,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAC1B,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC"}
\ No newline at end of file

programming_language: Scala
filename: index.ts
change_type: ModificationType.MODIFY
diff: @@ -1,3 +1,5 @@
+// See README.md for details
+
 import * as confinit from "../index";
 import * as path from "path";
 
@@ -37,11 +39,15 @@ export class Configuration {
 		if (!env) {
 			env = process.env;
 		}
+
+		// Enable config file
 		if (env.config) {
 			const configFile = path.resolve(process.cwd(), env.config);
 			confinit.applyConfigFile(this, configFile);
 		}
+		// Enable environment variables
 		confinit.applyEnvVariables(this, process.env, "cfg_");
+		// Enable command arguments
 		confinit.applyCommandArgs(this, process.argv);
 
 		confinit.validate(this);

programming_language: TypeScript
filename: setDeepProperty.test.js
change_type: ModificationType.MODIFY
diff: @@ -1,13 +1,13 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 const assert = require("assert");
-const __1 = require("..");
+const index_1 = require("../index");
 describe('setDeepProperty', () => {
     it('should set a property with deep 1', () => {
         const obj = {
             test: "A"
         };
-        __1.setDeepProperty(obj, "test", "B");
+        index_1.setDeepProperty(obj, "test", "B");
         assert.equal(obj.test, "B");
     });
     it('should set a property with deep 2', () => {
@@ -16,8 +16,32 @@ describe('setDeepProperty', () => {
                 test: "A"
             }
         };
-        __1.setDeepProperty(obj, "parent.test", "B");
+        index_1.setDeepProperty(obj, "parent.test", "B");
         assert.equal(obj.parent.test, "B");
     });
+    it('should not allow to set a not existing property', () => {
+        const obj = {
+            test: "A"
+        };
+        assert.throws(() => index_1.setDeepProperty(obj, "not_existing", "B"));
+    });
+    it('should not allow to set a property on null/undefined obj', () => {
+        assert.throws(() => index_1.setDeepProperty(null, "not_existing", "B"));
+        assert.throws(() => index_1.setDeepProperty(undefined, "not_existing", "B"));
+    });
+    it('should not allow to set a null/undefined property', () => {
+        const obj = {
+            test: "A"
+        };
+        assert.throws(() => index_1.setDeepProperty(obj, null, "B"));
+        assert.throws(() => index_1.setDeepProperty(obj, undefined, "B"));
+        assert.throws(() => index_1.setDeepProperty(obj, "", "B"));
+    });
+    it('should not allow to set __proto__ property', () => {
+        const obj = {
+            test: "A"
+        };
+        assert.throws(() => index_1.setDeepProperty(obj, "__proto__.xyz", "B"));
+    });
 });
 //# sourceMappingURL=setDeepProperty.test.js.map
\ No newline at end of file

programming_language: TypeScript
filename: setDeepProperty.test.js.map
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-{"version":3,"file":"setDeepProperty.test.js","sourceRoot":"","sources":["setDeepProperty.test.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,0BAAqC;AAErC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAE/B,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,GAAG;SACV,CAAA;QACD,mBAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,GAAG,GAAG;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,GAAG;aACV;SACF,CAAA;QACD,mBAAe,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
\ No newline at end of file
+{"version":3,"file":"setDeepProperty.test.js","sourceRoot":"","sources":["setDeepProperty.test.ts"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC,oCAA2C;AAE3C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAE/B,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,GAAG;SACV,CAAA;QACD,uBAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,GAAG,GAAG;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,GAAG;aACV;SACF,CAAA;QACD,uBAAe,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,GAAG;SACV,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,IAAW,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,SAAgB,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,GAAG;SACV,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,GAAG,EAAE,IAAW,EAAE,GAAG,CAAC,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,GAAG,EAAE,SAAgB,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,GAAG;SACV,CAAA;QACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAe,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
\ No newline at end of file

programming_language: Scala
filename: setDeepProperty.test.ts
change_type: ModificationType.MODIFY
diff: @@ -1,5 +1,5 @@
 import * as assert from 'assert';
-import { setDeepProperty } from '..';
+import { setDeepProperty } from '../index';
 
 describe('setDeepProperty', () => {
 
@@ -21,4 +21,32 @@ describe('setDeepProperty', () => {
     assert.equal(obj.parent.test, "B");
   });
 
+  it('should not allow to set a not existing property', () => {
+    const obj = {
+      test: "A"
+    }
+    assert.throws(() => setDeepProperty(obj, "not_existing", "B"));
+  });
+
+  it('should not allow to set a property on null/undefined obj', () => {
+    assert.throws(() => setDeepProperty(null as any, "not_existing", "B"));
+    assert.throws(() => setDeepProperty(undefined as any, "not_existing", "B"));
+  });
+
+  it('should not allow to set a null/undefined property', () => {
+    const obj = {
+      test: "A"
+    }
+    assert.throws(() => setDeepProperty(obj, null as any, "B"));
+    assert.throws(() => setDeepProperty(obj, undefined as any, "B"));
+    assert.throws(() => setDeepProperty(obj, "", "B"));
+  });
+
+  it('should not allow to set __proto__ property', () => {
+    const obj = {
+      test: "A"
+    }
+    assert.throws(() => setDeepProperty(obj, "__proto__.xyz", "B"));
+  });
+
 });
\ No newline at end of file

programming_language: TypeScript