cbor-x 1.5.7 → 1.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/test.js CHANGED
@@ -499,7 +499,11 @@
499
499
  }
500
500
 
501
501
  function safeKey(key) {
502
- return key === '__proto__' ? '__proto_' : key
502
+ // protect against prototype pollution
503
+ if (typeof key === 'string') return key === '__proto__' ? '__proto_' : key
504
+ if (typeof key !== 'object') return key.toString()
505
+ // protect against expensive (DoS) string conversions
506
+ throw new Error('Invalid property name type ' + typeof key);
503
507
  }
504
508
 
505
509
  let readFixedString = readStringJS;