r/node • u/Justyn2 • Sep 28 '24
Suspicious Packages
apparently “-“ is a package and so is “g” So if I type "npm install - g npm". I get 3 packages installed instead of npm installed globally!
25
u/KnightYoshi Sep 28 '24
Well, make sure you type your npm args correctly 🤣
22
18
Sep 28 '24
must be nice to be so perfect all the time
-22
u/KnightYoshi Sep 28 '24
I mean, CLI commands aren't exactly the hardest thing 🤣
8
u/Agreeable_Tell9415 Sep 28 '24
Typos are a human thing
-5
u/KnightYoshi Sep 28 '24
So you’re saying humans are the problem. Therefore we must Destroy All Humans!™
93
u/Aksh247 Sep 28 '24
For those who mistype -g with - g get rekt
42
u/Curious_Cantaloupe65 Sep 28 '24
19
3
8
u/robercal Sep 28 '24
A few months ago while reviewing dependencies on an project I noticed this i package.
According to git blame it was added by a coworker almost a year ago when working on feature X, but feature X didn't require any use of inflections so I removed it but I had no idea how it ended up in package.json.
It was a few weeks later when I saw included by the same coworker this other package ins when I realized what was happening.
The first one seems to be a proper package while the second one doesn't have any code so I guess it was a rogue one at some point.
4
7
24
19
u/lirantal Sep 28 '24
I don't understand why in 2024 developers don't use npq to protect against accidental or phished installation of npm packages.
Please take a look here and use npq: https://github.com/lirantal/npq
As simple as:
$ npq install <package>
and npq will first scan the package information, show you details, and will interactively ask you whether to continue installing or abort the process.
Stay safe fellow devs! ❤️
39
Sep 28 '24
I don't understand why npm doesn't include those same protections in 2024
3
u/emreyc Sep 29 '24
because it has to be implemented by another package manager first. god forbid if npm spearheads sth
4
14
u/lIlIlIIlIIIlIIIIIl Sep 28 '24
But how do we know if npq is safe? 😭
Okay it was a joke at first but now I'm actually curious... By reading the source code ourselves can we fully verify npq is safe?
3
u/lirantal Sep 28 '24
I like your trust-but-verify mindset :-)
You are invited to review the code and dependencies (which are due to a good refactor and an update but I'm mostly awaiting new ecosystem API to be available before I do that)
11
u/NiteShdw Sep 28 '24
Because I haven't ever heard of it. It's hard to use something you don't know about.
So it's weird to say "why isn't everyone already using this?". The answer is self-evident.
2
u/shepde Sep 29 '24
If I’m remembering correctly that ‘-‘ package was created by a researcher and eventually turned over to npm and it’s now frozen. Not sure about the ‘g’ package.
1
1
1
u/Ceigey Sep 29 '24
At least on Deno this is a bit trickier to do - ideally gotta use either JSR (requires namespaces/orgs), or the npm: qualifier. But surprised they can typo squat a dash theoretically… the good ol’ Wild West days of server side Js…
1
-34
225



105
u/xemns4 Sep 28 '24
isnt there a way to report this? seems malevolent