@@ -38,6 +38,23 @@ export default function (dset) {
3838 assert . is ( Object . create ( null ) . hello , undefined ) ;
3939 } ) ;
4040
41+ pollution ( 'should protect against ["__proto__"] assignment :: implicit string' , ( ) => {
42+ let input = { abc : 123 } ;
43+ let before = input . __proto__ ;
44+
45+ dset ( input , [ [ '__proto__' ] , 'polluted' ] , true ) ;
46+
47+ assert . equal ( input . __proto__ , before ) ;
48+ assert . equal ( input , { abc : 123 } ) ;
49+
50+ assert . is ( { } . polluted , undefined ) ;
51+ assert . is ( input . polluted , undefined ) ;
52+ assert . is ( ( new Object ) . polluted , undefined ) ;
53+ assert . is ( Object . create ( null ) . polluted , undefined ) ;
54+ } ) ;
55+
56+
57+
4158 pollution ( 'should ignore "prototype" assignment' , ( ) => {
4259 let input = { a : 123 } ;
4360 dset ( input , 'a.prototype.hello' , 'world' ) ;
@@ -85,7 +102,7 @@ export default function (dset) {
85102 } ) ;
86103 } ) ;
87104
88- // Test for CVE-2022-25645 - CWE-1321
105+ // Test for CVE-2022-25645 - CWE-1321
89106 pollution ( 'should ignore JSON.parse crafted object with "__proto__" key' , ( ) => {
90107 let a = { b : { c : 1 } } ;
91108 assert . is ( a . polluted , undefined ) ;
0 commit comments