r/node • • 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!

290 Upvotes

43 comments sorted by

105

u/xemns4 Sep 28 '24

isnt there a way to report this? seems malevolent

30

u/Justyn2 Sep 28 '24

What worries me more is the dependents

105

u/MindStalker Sep 28 '24

If you look into both packages they don't do anything. Arguably npm should freeze them to make sure they never do anything, but having them there as placeholders to keep someone else from using them is probably best.

40

u/xemns4 Sep 28 '24

as placeholders is an interesting take. but maybe its a sleeper, and its relying on not having anything at the moment and then in the future one dev does an npm install it'll suddenly have something in it.

34

u/MindStalker Sep 28 '24

Also, that 600 packages are dependent on g is a bit messed up. 

1

u/[deleted] Sep 29 '24

[removed] — view removed comment

5

u/fucking_passwords Sep 30 '24 edited Sep 30 '24

If I recall correctly, npm packages can have a postinstall script to execute arbitrary code after you install the package. Useful for packages that need to compile native code, I believe node-sass used that hook...

Same thing with "The author of core-js is looking for a job" (I think)

0

u/xemns4 Sep 29 '24

im a noob but i think its downloading code that can be used in unexpected ways. you do x() and it's usually imported from x library, but small change and instead of from x library and its from this one and it does black crypto voodoo on your machine...

1

u/FancyADrink Sep 30 '24

I believe that even un-imported code can override globals in some cases.

25

u/KnightYoshi Sep 28 '24

Well, make sure you type your npm args correctly 🤣

22

u/Justyn2 Sep 28 '24

I know! Just a PSA

18

u/[deleted] 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

u/MCFRESH01 Sep 28 '24 edited Sep 29 '24

Whoever owns that needs to throw some ads on there

4

u/veegaz Sep 29 '24

However

Are we doing a misspellung contest here?

3

u/thisisjoy Sep 29 '24

best website

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

u/AshKetchupppp Sep 29 '24

To this day he is still trying to figure out how to npm install

7

u/[deleted] Sep 28 '24

NPM is a mess man

24

u/Riday2001 Sep 28 '24

npm is actually the official package

19

u/1kings2214 Sep 28 '24

The description with the images explains what OP is worried about

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

u/[deleted] 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

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

u/[deleted] Sep 28 '24

Now with free Velvet Ant dependency injections.

1

u/agustin_edwards Sep 29 '24

The danger is not the library per se, but the fuck ton of dependencies

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

u/na_rm_true Sep 30 '24

Dependency confusion. Don't use what u shouldn't trust.

-34

u/mimahihuuhai Sep 28 '24

This why you should use yarn, pnpm, bun /s

2

u/xemns4 Sep 28 '24

how do they differ? couldn't it also happen in them as well?

225

u/[deleted] Sep 28 '24

[removed] — view removed comment