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.
magic-error
Advanced tools
npm install --save magic-error
import createMagicError from 'magic-error';
const err = createMagicError(new ReferenceError('Impossible does not exist'));
It uses proxy and sets traps for 2 internal methods:
Ok, cool, but I still don't have a clue how this crap is supposed to work. I'll probably fail to describe it in a meaningful way and skip a couple of details, but let me try. If you take a look at a method like Object.keys, you should be able to see it invokes [[EnumerableOwnPropertyNames]]. Now, please take a look at the step 2 of [[EnumerableOwnPropertyNames]]. Yes, you see it right. It 'calls' [[OwnPropertyKeys]]. Then, step 4.II is kind of important (but not in our case, more on this later) as well in general, as if the desc[[Enumerable]] is not true, the key won't be included in the list. All descriptors we return have enumerable set to true, because we'd have a nice TypeError otherwise. The trap for [[GetOwnProperty]] internal method is needed due to that - we need to make properties enumerable and configurable.
ownKeys
?It's caused by the fact the trap result cannot return duplicate entries. See the step 9 of [[OwnPropertyKeys]] internal slot.
Pretty much the same story. It has different steps, as, [[EnumerableOwnPropertyNames]] unlike it doesn't 'filter out' non-enumerable properties, but since everything is enumerable in our case, the output should be equal.
for in
loop?Alright - we need to get the syntax right first.
As you can see, all for in
iteration methods 'pass' enumerate
'to' ForIn/OfHeadEvaluation.
Now, go ahead, look at step 6. EnumerateObjectProperties is described quite nicely - there is even a code sample.
Google it or search in spec.
Serialize-error can be used on production, while this thingy... well, I wouldn't use it.
Besides that, there a few other differences you most likely don't care about, but to name a few:
FAQs
Developer friendly JS Errors
The npm package magic-error receives a total of 23,834 weekly downloads. As such, magic-error popularity was classified as popular.
We found that magic-error 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.