Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
serializerr
Advanced tools
Convert Errors & Objects into an easily-serialized vanilla Object.
serializerr
creates a vanilla Object
with a flattened prototype
chain & any non-enumerable properties mapped to enumerable properties.
This allows Error
objects to be serialised to JSON without losing
important data.
npm install serializerr
var wellSerializedError = JSON.parse(JSON.stringify(
serializerr(error)
))
console.log(wellSerializedError.name) // Error
console.log(wellSerializedError.message) // an error occurred
console.log(wellSerializedError.stack) // Error: an error occurred\n at Test.<anonymous> ...
var serializerr = require('serializerr')
var error = new Error('an error')
// simulate transferring an Error object over the wire as JSON
// without first passing through serializerr
var poorlySerializedError = JSON.parse(JSON.stringify(error))
// oh dear:
console.log(poorlySerializedError.name) // undefined
console.log(poorlySerializedError.message) // undefined
console.log(poorlySerializedError.stack) // undefined
// bring forth the serializerr
var errorObject = serializerr(error)
var wellSerializedError = JSON.parse(JSON.stringify(errorObject))
// properties are conserved!
console.log(wellSerializedError.name) // Error
console.log(wellSerializedError.message) // an error occurred
console.log(wellSerializedError.stack) // Error: an error occurred\n at Test.<anonymous> ...
// note errorObject is a vanilla Object, not an Error
errorObject instanceof Error // false
If you've ever tried to send an Error over a JSON-encoded connection
you've probably been surprised to find all the useful information is
sapped out of it; all the juicy properties like name
, message
&
stack
are non-enumerable thus they are not included in the
stringified JSON. This may be non-standard behaviour, as I could not
locate any mention in either the ES5.1 or the ES6 spec about it, but
Error properties are non-enumerable both in V8 (Chrome/io.js/Node.js) &
SpiderMonkey (Firefox).
I believe Error property non-enumerability was added as a security measure to prevent stack traces and other sensitive information accidentally leaking, but it's not uncommon to actually want to send the data in Error objects over the wire.
serializerr
makes an Object suitable for serializing to & from
JSON. Not restricted to use with Errors, will work with any Object.
Name was selected as programming world is mostly Americanised, and npm search does not seem to do effective stemming.
This decision came with strong feelings of guilt and shame about what I thought was blasphemous Americanised spelling, but it turns out this is a misconception thus I am pardoned:
The -ize spelling is often incorrectly seen as an Americanism in Britain. However, the Oxford English Dictionary (OED) recommends -ize and notes that the -ise spelling is from French.
From Wikipedia: American and British English spelling differences
ISC
FAQs
Convert Errors & Objects into an easily-serialized vanilla Object.
The npm package serializerr receives a total of 38,235 weekly downloads. As such, serializerr popularity was classified as popular.
We found that serializerr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.