Package: node-object-path / 0.11.5-3+deb11u1

CVE-2021-3805.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
Description: Fix prototype pollution vulnerability
Author: Mario Casciaro <mariocasciaro@gmail.com>
Origin: upstream, https://github.com/mariocasciaro/object-path/commit/4f0903fd7
Bug: https://huntr.dev/bounties/571e3baf-7c46-46e3-9003-ba7e4e623053
Forwarded: not-needed
Reviewed-By: Yadd <yadd@debian.org>
Last-Update: 2021-09-17

--- a/README.md
+++ b/README.md
@@ -172,6 +172,8 @@
 objectPath.set(obj, 'notOwn.prop', 'b');
 ```
 
+**NOTE**: For security reasons `object-path` will throw an exception when trying to access an object's magic properties (e.g. `__proto__`, `constructor`) when in "inherited props" mode.
+
 ### Immutability
 
 If you are looking for an *immutable* alternative of this library, you can take a look at: [object-path-immutable](https://github.com/mariocasciaro/object-path-immutable)
--- a/index.js
+++ b/index.js
@@ -1,87 +1,88 @@
-(function (root, factory){
-  'use strict';
+(function (root, factory) {
+  'use strict'
 
   /*istanbul ignore next:cant test*/
   if (typeof module === 'object' && typeof module.exports === 'object') {
-    module.exports = factory();
+    module.exports = factory()
   } else if (typeof define === 'function' && define.amd) {
     // AMD. Register as an anonymous module.
-    define([], factory);
+    define([], factory)
   } else {
     // Browser globals
-    root.objectPath = factory();
+    root.objectPath = factory()
   }
-})(this, function(){
-  'use strict';
+})(this, function () {
+  'use strict'
 
-  var toStr = Object.prototype.toString;
-  function hasOwnProperty(obj, prop) {
-    if(obj == null) {
+  var toStr = Object.prototype.toString
+
+  function hasOwnProperty (obj, prop) {
+    if (obj == null) {
       return false
     }
     //to handle objects with null prototypes (too edge case?)
     return Object.prototype.hasOwnProperty.call(obj, prop)
   }
 
-  function isEmpty(value){
+  function isEmpty (value) {
     if (!value) {
-      return true;
+      return true
     }
     if (isArray(value) && value.length === 0) {
-        return true;
+      return true
     } else if (typeof value !== 'string') {
-        for (var i in value) {
-            if (hasOwnProperty(value, i)) {
-                return false;
-            }
+      for (var i in value) {
+        if (hasOwnProperty(value, i)) {
+          return false
         }
-        return true;
+      }
+      return true
     }
-    return false;
+    return false
   }
 
-  function toString(type){
-    return toStr.call(type);
+  function toString (type) {
+    return toStr.call(type)
   }
 
-  function isObject(obj){
-    return typeof obj === 'object' && toString(obj) === "[object Object]";
+  function isObject (obj) {
+    return typeof obj === 'object' && toString(obj) === '[object Object]'
   }
 
-  var isArray = Array.isArray || function(obj){
+  var isArray = Array.isArray || function (obj) {
     /*istanbul ignore next:cant test*/
-    return toStr.call(obj) === '[object Array]';
+    return toStr.call(obj) === '[object Array]'
   }
 
-  function isBoolean(obj){
-    return typeof obj === 'boolean' || toString(obj) === '[object Boolean]';
+  function isBoolean (obj) {
+    return typeof obj === 'boolean' || toString(obj) === '[object Boolean]'
   }
 
-  function getKey(key){
-    var intKey = parseInt(key);
+  function getKey (key) {
+    var intKey = parseInt(key)
     if (intKey.toString() === key) {
-      return intKey;
+      return intKey
     }
-    return key;
+    return key
   }
 
-  function factory(options) {
+  function factory (options) {
     options = options || {}
 
-    var objectPath = function(obj) {
-      return Object.keys(objectPath).reduce(function(proxy, prop) {
-        if(prop === 'create') {
-          return proxy;
+    var objectPath = function (obj) {
+      return Object.keys(objectPath).reduce(function (proxy, prop) {
+        if (prop === 'create') {
+          return proxy
         }
 
         /*istanbul ignore else*/
         if (typeof objectPath[prop] === 'function') {
-          proxy[prop] = objectPath[prop].bind(objectPath, obj);
+          proxy[prop] = objectPath[prop].bind(objectPath, obj)
         }
 
-        return proxy;
-      }, {});
-    };
+        return proxy
+      }, {})
+    }
 
     var hasShallowProperty
     if (options.includeInheritedProps) {
@@ -94,213 +95,226 @@
       }
     }
 
-    function getShallowProperty(obj, prop) {
+    function getShallowProperty (obj, prop) {
       if (hasShallowProperty(obj, prop)) {
-        return obj[prop];
+        return obj[prop]
+      }
+    }
+
+    var getShallowPropertySafely
+    if (options.includeInheritedProps) {
+      getShallowPropertySafely = function (obj, currentPath) {
+        if (typeof currentPath !== 'string' && typeof currentPath !== 'number') {
+          currentPath = String(currentPath)
+        }
+        var currentValue = getShallowProperty(obj, currentPath)
+        if (currentPath === '__proto__' || currentPath === 'prototype' ||
+          (currentPath === 'constructor' && typeof currentValue === 'function')) {
+          throw new Error('For security reasons, object\'s magic properties cannot be set')
+        }
+        return currentValue
+      }
+    } else {
+      getShallowPropertySafely = function (obj, currentPath) {
+        return getShallowProperty(obj, currentPath)
       }
     }
 
-    function set(obj, path, value, doNotReplace){
+    function set (obj, path, value, doNotReplace) {
       if (typeof path === 'number') {
-        path = [path];
+        path = [path]
       }
       if (!path || path.length === 0) {
-        return obj;
+        return obj
       }
       if (typeof path === 'string') {
-        return set(obj, path.split('.').map(getKey), value, doNotReplace);
-      }
-      var currentPath = path[0];
-      if (typeof currentPath !== 'string' && typeof currentPath !== 'number') {
-        currentPath = String(currentPath)
-      }
-      var currentValue = getShallowProperty(obj, currentPath);
-      if (options.includeInheritedProps && (currentPath === '__proto__' ||
-        (currentPath === 'constructor' && typeof currentValue === 'function'))) {
-        throw new Error('For security reasons, object\'s magic properties cannot be set')
+        return set(obj, path.split('.').map(getKey), value, doNotReplace)
       }
+      var currentPath = path[0]
+      var currentValue = getShallowPropertySafely(obj, currentPath)
       if (path.length === 1) {
         if (currentValue === void 0 || !doNotReplace) {
-          obj[currentPath] = value;
+          obj[currentPath] = value
         }
-        return currentValue;
+        return currentValue
       }
 
       if (currentValue === void 0) {
         //check if we assume an array
-        if(typeof path[1] === 'number') {
-          obj[currentPath] = [];
+        if (typeof path[1] === 'number') {
+          obj[currentPath] = []
         } else {
-          obj[currentPath] = {};
+          obj[currentPath] = {}
         }
       }
 
-      return set(obj[currentPath], path.slice(1), value, doNotReplace);
+      return set(obj[currentPath], path.slice(1), value, doNotReplace)
     }
 
     objectPath.has = function (obj, path) {
       if (typeof path === 'number') {
-        path = [path];
+        path = [path]
       } else if (typeof path === 'string') {
-        path = path.split('.');
+        path = path.split('.')
       }
 
       if (!path || path.length === 0) {
-        return !!obj;
+        return !!obj
       }
 
       for (var i = 0; i < path.length; i++) {
-        var j = getKey(path[i]);
+        var j = getKey(path[i])
 
-        if((typeof j === 'number' && isArray(obj) && j < obj.length) ||
+        if ((typeof j === 'number' && isArray(obj) && j < obj.length) ||
           (options.includeInheritedProps ? (j in Object(obj)) : hasOwnProperty(obj, j))) {
-          obj = obj[j];
+          obj = obj[j]
         } else {
-          return false;
+          return false
         }
       }
 
-      return true;
-    };
+      return true
+    }
 
-    objectPath.ensureExists = function (obj, path, value){
-      return set(obj, path, value, true);
-    };
+    objectPath.ensureExists = function (obj, path, value) {
+      return set(obj, path, value, true)
+    }
 
-    objectPath.set = function (obj, path, value, doNotReplace){
-      return set(obj, path, value, doNotReplace);
-    };
+    objectPath.set = function (obj, path, value, doNotReplace) {
+      return set(obj, path, value, doNotReplace)
+    }
 
-    objectPath.insert = function (obj, path, value, at){
-      var arr = objectPath.get(obj, path);
-      at = ~~at;
+    objectPath.insert = function (obj, path, value, at) {
+      var arr = objectPath.get(obj, path)
+      at = ~~at
       if (!isArray(arr)) {
-        arr = [];
-        objectPath.set(obj, path, arr);
+        arr = []
+        objectPath.set(obj, path, arr)
       }
-      arr.splice(at, 0, value);
-    };
+      arr.splice(at, 0, value)
+    }
 
-    objectPath.empty = function(obj, path) {
+    objectPath.empty = function (obj, path) {
       if (isEmpty(path)) {
-        return void 0;
+        return void 0
       }
       if (obj == null) {
-        return void 0;
+        return void 0
       }
 
-      var value, i;
+      var value, i
       if (!(value = objectPath.get(obj, path))) {
-        return void 0;
+        return void 0
       }
 
       if (typeof value === 'string') {
-        return objectPath.set(obj, path, '');
+        return objectPath.set(obj, path, '')
       } else if (isBoolean(value)) {
-        return objectPath.set(obj, path, false);
+        return objectPath.set(obj, path, false)
       } else if (typeof value === 'number') {
-        return objectPath.set(obj, path, 0);
+        return objectPath.set(obj, path, 0)
       } else if (isArray(value)) {
-        value.length = 0;
+        value.length = 0
       } else if (isObject(value)) {
         for (i in value) {
           if (hasShallowProperty(value, i)) {
-            delete value[i];
+            delete value[i]
           }
         }
       } else {
-        return objectPath.set(obj, path, null);
+        return objectPath.set(obj, path, null)
       }
-    };
+    }
 
-    objectPath.push = function (obj, path /*, values */){
-      var arr = objectPath.get(obj, path);
+    objectPath.push = function (obj, path /*, values */) {
+      var arr = objectPath.get(obj, path)
       if (!isArray(arr)) {
-        arr = [];
-        objectPath.set(obj, path, arr);
+        arr = []
+        objectPath.set(obj, path, arr)
       }
 
-      arr.push.apply(arr, Array.prototype.slice.call(arguments, 2));
-    };
+      arr.push.apply(arr, Array.prototype.slice.call(arguments, 2))
+    }
 
     objectPath.coalesce = function (obj, paths, defaultValue) {
-      var value;
+      var value
 
       for (var i = 0, len = paths.length; i < len; i++) {
         if ((value = objectPath.get(obj, paths[i])) !== void 0) {
-          return value;
+          return value
         }
       }
 
-      return defaultValue;
-    };
+      return defaultValue
+    }
 
-    objectPath.get = function (obj, path, defaultValue){
+    objectPath.get = function (obj, path, defaultValue) {
       if (typeof path === 'number') {
-        path = [path];
+        path = [path]
       }
       if (!path || path.length === 0) {
-        return obj;
+        return obj
       }
       if (obj == null) {
-        return defaultValue;
+        return defaultValue
       }
       if (typeof path === 'string') {
-        return objectPath.get(obj, path.split('.'), defaultValue);
+        return objectPath.get(obj, path.split('.'), defaultValue)
       }
 
-      var currentPath = getKey(path[0]);
-      var nextObj = getShallowProperty(obj, currentPath)
+      var currentPath = getKey(path[0])
+      var nextObj = getShallowPropertySafely(obj, currentPath)
       if (nextObj === void 0) {
-        return defaultValue;
+        return defaultValue
       }
 
       if (path.length === 1) {
-        return nextObj;
+        return nextObj
       }
 
-      return objectPath.get(obj[currentPath], path.slice(1), defaultValue);
-    };
+      return objectPath.get(obj[currentPath], path.slice(1), defaultValue)
+    }
 
-    objectPath.del = function del(obj, path) {
+    objectPath.del = function del (obj, path) {
       if (typeof path === 'number') {
-        path = [path];
+        path = [path]
       }
 
       if (obj == null) {
-        return obj;
+        return obj
       }
 
       if (isEmpty(path)) {
-        return obj;
+        return obj
       }
-      if(typeof path === 'string') {
-        return objectPath.del(obj, path.split('.'));
+      if (typeof path === 'string') {
+        return objectPath.del(obj, path.split('.'))
       }
 
-      var currentPath = getKey(path[0]);
+      var currentPath = getKey(path[0])
+      getShallowPropertySafely(obj, currentPath)
       if (!hasShallowProperty(obj, currentPath)) {
-        return obj;
+        return obj
       }
 
-      if(path.length === 1) {
+      if (path.length === 1) {
         if (isArray(obj)) {
-          obj.splice(currentPath, 1);
+          obj.splice(currentPath, 1)
         } else {
-          delete obj[currentPath];
+          delete obj[currentPath]
         }
       } else {
-        return objectPath.del(obj[currentPath], path.slice(1));
+        return objectPath.del(obj[currentPath], path.slice(1))
       }
 
-      return obj;
+      return obj
     }
 
-    return objectPath;
+    return objectPath
   }
 
-  var mod = factory();
-  mod.create = factory;
+  var mod = factory()
+  mod.create = factory
   mod.withInheritedProps = factory({includeInheritedProps: true})
-  return mod;
-});
+  return mod
+})
--- a/test.js
+++ b/test.js
@@ -133,6 +133,43 @@
     expect(objectPath.get(extended, 'enabled')).to.be.equal(true)
     expect(objectPath.get(extended, 'one')).to.be.equal(undefined)
   })
+
+  it('[security] should not get magic properties in default mode', function () {
+    expect(objectPath.get({}, '__proto__')).to.be.undefined
+    expect(objectPath.get({}, [['__proto__']])).to.be.undefined
+
+    function Clazz() {}
+    Clazz.prototype.test = []
+
+    expect(objectPath.get(new Clazz(), '__proto__')).to.be.undefined
+    expect(objectPath.get(new Clazz(), [['__proto__']])).to.be.undefined
+    expect(objectPath.get(new Clazz(), ['constructor', 'prototype'])).to.be.undefined
+  })
+
+  it('[security] should not get magic properties in inheritedProps mode', function () {
+    expect(function() {
+      objectPath.withInheritedProps.get({}, '__proto__')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.get({}, [['__proto__']])
+    }).to.throw('For security reasons')
+
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    expect(function() {
+      objectPath.withInheritedProps.get(new Clazz(), '__proto__')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.get(new Clazz(), [['__proto__']])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.get(new Clazz(), ['constructor', 'prototype'])
+    }).to.throw('For security reasons')
+  })
 })
 
 
@@ -244,9 +281,15 @@
     objectPath.set({}, [['__proto__'], 'injected'], 'this is bad')
     expect(Object.prototype.injected).to.be.undefined
 
+    objectPath.set({}, ['__proto__'], {})
+    expect(Object.prototype.toString).to.be.a('function')
+
     function Clazz() {}
     Clazz.prototype.test = 'original'
 
+    objectPath.set({}, ['__proto__'], {test: 'this is bad'})
+    expect(Clazz.prototype.test).to.be.equal('original')
+
     objectPath.set(new Clazz(), '__proto__.test', 'this is bad')
     expect(Clazz.prototype.test).to.be.equal('original')
 
@@ -258,9 +301,10 @@
   })
 
   it('[security] should throw an exception if trying to set magic properties in inheritedProps mode', function () {
-    expect(function() {objectPath.withInheritedProps.set({}, '__proto__.injected', 'this is bad')})
-      .to.throw('For security reasons')
-    expect(Object.prototype.injected).to.be.undefined
+    expect(function() {
+      objectPath.withInheritedProps.set({}, '__proto__.injected', 'this is bad')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
 
     expect(function() {
       objectPath.withInheritedProps.set({}, [['__proto__'], 'injected'], 'this is bad')
@@ -270,21 +314,25 @@
     function Clazz() {}
     Clazz.prototype.test = 'original'
 
-    expect(function() {objectPath.withInheritedProps.set(new Clazz(), '__proto__.test', 'this is bad')})
-      .to.throw('For security reasons')
-    expect(Clazz.prototype.test).to.be.equal('original')
+    expect(function() {
+      objectPath.withInheritedProps.set(new Clazz(), '__proto__.test', 'this is bad')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
 
-    expect(function() {objectPath.withInheritedProps.set(new Clazz(), 'constructor.prototype.test', 'this is bad')})
-      .to.throw('For security reasons')
-    expect(Clazz.prototype.test).to.be.equal('original')
+    expect(function() {
+      objectPath.withInheritedProps.set(new Clazz(), 'constructor.prototype.test', 'this is bad')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
 
-    expect(function() {objectPath.withInheritedProps.set({}, 'constructor.prototype.injected', 'this is OK')})
-      .to.throw('For security reasons')
-    expect(Object.prototype.injected).to.be.undefined
+    expect(function() {
+      objectPath.withInheritedProps.set({}, 'constructor.prototype.injected', 'this is OK')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
 
-    expect(function() {objectPath.withInheritedProps.set({}, [['constructor'], 'prototype', 'injected'], 'this is bad')})
-      .to.throw('For security reasons')
-    expect(Object.prototype.injected).to.be.undefined
+    expect(function() {
+      objectPath.withInheritedProps.set({}, [['constructor'], 'prototype', 'injected'], 'this is bad')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
   })
 })
 
@@ -328,6 +376,39 @@
     expect(obj).to.have.nested.property('b.e.0.0', 'l')
   })
 
+  it('[security] should not push within prototype properties in default mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = []
+
+    objectPath.push(new Clazz(), '__proto__.test', 'pushed')
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+
+    objectPath.push(new Clazz(), [['__proto__'], 'test'], 'pushed')
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+
+    objectPath.push(new Clazz(), 'constructor.prototype.test', 'pushed')
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+  })
+
+  it('[security] should not push within prototype properties in inheritedProps mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = []
+
+    expect(function() {
+      objectPath.withInheritedProps.push(new Clazz(), '__proto__.test', 'pushed')
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.push(new Clazz(), [['__proto__'], 'test'], 'pushed')
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.push(new Clazz(), 'constructor.prototype.test', 'pushed')
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+  })
 })
 
 
@@ -361,6 +442,67 @@
     expect(any[1]).to.be.an('object')
     expect(any[1][1]).to.be.an('object')
   })
+
+  it('[security] should not set magic properties in default mode', function () {
+    objectPath.ensureExists({}, '__proto__.injected', 'this is bad')
+    expect(Object.prototype.injected).to.be.undefined
+
+    objectPath.ensureExists({}, [['__proto__'], 'injected'], 'this is bad')
+    expect(Object.prototype.injected).to.be.undefined
+
+    objectPath.ensureExists({}, ['__proto__'], {})
+    expect(Object.prototype.toString).to.be.a('function')
+
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    objectPath.ensureExists({}, ['__proto__'], {test: 'this is bad'})
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.ensureExists(new Clazz(), '__proto__.test', 'this is bad')
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.ensureExists(new Clazz(), [['__proto__'], 'test'], 'this is bad')
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.ensureExists(new Clazz(), 'constructor.prototype.test', 'this is bad')
+    expect(Clazz.prototype.test).to.be.equal('original')
+  })
+
+  it('[security] should throw an exception if trying to set magic properties in inheritedProps mode', function () {
+    expect(function() {objectPath.withInheritedProps.ensureExists({}, '__proto__.injected', 'this is bad')})
+      .to.throw('For security reasons')
+    expect(Object.prototype.injected).to.be.undefined
+
+    expect(function() {
+      objectPath.withInheritedProps.ensureExists({}, [['__proto__'], 'injected'], 'this is bad')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
+
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    expect(function() {
+      objectPath.withInheritedProps.ensureExists(new Clazz(), '__proto__.test', 'this is bad')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+
+    expect(function() {
+      objectPath.withInheritedProps.ensureExists(new Clazz(), 'constructor.prototype.test', 'this is bad')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.ensureExists({}, 'constructor.prototype.injected', 'this is OK')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.ensureExists({}, [['constructor'], 'prototype', 'injected'], 'this is bad')
+      expect(Object.prototype.injected).to.be.undefined
+    }).to.throw('For security reasons')
+  })
 })
 
 describe('coalesce', function () {
@@ -512,6 +654,40 @@
     expect(obj.instance.arr).to.be.an('array')
     expect(obj['function']).to.equal(null)
   })
+
+  it('[security] should not empty prototype properties in default mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    objectPath.empty(new Clazz(), '__proto__')
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.empty(new Clazz(), [['__proto__']])
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.empty(new Clazz(), 'constructor.prototype')
+    expect(Clazz.prototype.test).to.be.equal('original')
+  })
+
+  it('[security] should throw an exception if trying to delete prototype properties in inheritedProps mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    expect(function() {
+      objectPath.withInheritedProps.empty(new Clazz(), '__proto__')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.empty(new Clazz(), 'constructor.prototype')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.empty({}, [['constructor'], 'prototype'])
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+  })
 })
 
 describe('del', function () {
@@ -588,6 +764,56 @@
     expect(obj.b.d).to.have.length(0)
     expect(obj.b.d).to.be.deep.equal([])
   })
+
+  it('[security] should not delete prototype properties in default mode', function () {
+    objectPath.del({}, '__proto__.valueOf')
+    expect(Object.prototype.valueOf).to.be.a('function')
+
+    objectPath.del({}, [['__proto__'], 'valueOf'])
+    expect(Object.prototype.valueOf).to.be.a('function')
+
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    objectPath.del(new Clazz(), '__proto__.test')
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.del(new Clazz(), [['__proto__'], 'test'])
+    expect(Clazz.prototype.test).to.be.equal('original')
+
+    objectPath.del(new Clazz(), 'constructor.prototype.test')
+    expect(Clazz.prototype.test).to.be.equal('original')
+  })
+
+  it('[security] should throw an exception if trying to delete prototype properties in inheritedProps mode', function () {
+    expect(function() {
+      objectPath.withInheritedProps.del({}, '__proto__.valueOf')
+      expect(Object.prototype.valueOf).to.be.a('function')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.del({}, [['__proto__'], 'valueOf'])
+      expect(Object.prototype.valueOf).to.be.a('function')
+    }).to.throw('For security reasons')
+
+    function Clazz() {}
+    Clazz.prototype.test = 'original'
+
+    expect(function() {
+      objectPath.withInheritedProps.del(new Clazz(), '__proto__.test')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.del(new Clazz(), 'constructor.prototype.test', 'this is bad')
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.del({}, [['constructor'], 'prototype', 'test'])
+      expect(Clazz.prototype.test).to.be.equal('original')
+    }).to.throw('For security reasons')
+  })
 })
 
 describe('insert', function () {
@@ -630,6 +856,45 @@
       'asdf'
     ])
   })
+
+  it('[security] should not insert within prototype properties in default mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = []
+
+    objectPath.insert(new Clazz(), '__proto__.test', 'inserted', 0)
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+
+    objectPath.insert(new Clazz(), [['__proto__'], 'test'], 'inserted', 0)
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+
+    objectPath.insert(new Clazz(), 'constructor.prototype.test', 'inserted', 0)
+    expect(Clazz.prototype.test).to.be.deep.equal([])
+  })
+
+  it('[security] should not insert within prototype properties in inheritedProps mode', function () {
+    function Clazz() {}
+    Clazz.prototype.test = []
+
+    expect(function() {
+      objectPath.withInheritedProps.insert(new Clazz(), '__proto__.test', 'inserted', 0)
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.insert(new Clazz(), [['__proto__'], 'test'], 'inserted', 0)
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.insert(new Clazz(), 'constructor.prototype.test', 'inserted', 0)
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+
+    expect(function() {
+      objectPath.withInheritedProps.insert(new Clazz().constructor, 'prototype.test', 'inserted', 0)
+      expect(Clazz.prototype.test).to.be.deep.equal([])
+    }).to.throw('For security reasons')
+  })
 })
 
 describe('has', function () {