Hardware Security Module (HSM) or Key Management Services ✓ Mask any sensitive data before it appears in the log files ✓ To reduce impact of a leak, use short-lived tokens.
to generate random values in security- sensitive context (random tokens, resource IDs, or UUIDs). • Math.random() is cryptographically insecure. It can produce predictable values.
logic to match user inputs against sensitive values. • JavaScript native string comparison operators (=== and ==) perform the non-constant time fail-first string comparison .
a number as an argument, generates a Buffer instance with uninitialized underlying memory. ▪ The contents of a newly created Buffer remain unknown and might contain sensitive data. Root Cause for Remote Memory Exposure
new Error('something bad happened!'); 1. callback(new Error('something bad happened!')); 1. return Promise.reject(new Error('something bad happened!'));
new Error('something bad happened!'); 1. callback(new Error('something bad happened!')); 1. return Promise.reject(new Error('something bad happened!')); 1. myEmitter.emit('error', new Error(something bad happened!'));