News for hackers. Stuff that matters.
Re:Alert: NPM modules hijacked by SlashmanX on Wednesday March 23, 2016 @11:18AM (#11345236)
It's insane that NPM allows anybody to just take over a module name if the original is unpublished, without even a warning to users.
Re:Alert: NPM modules hijacked by na85 on Wednesday March 23, 2016 @12:12PM (#11345736)
Insane, yes, but not unexpected. This is the sort of amateur behaviour that is emblematic of the entire nodejs community.
Re:Alert: NPM modules hijacked by PeCaN on Wednesday March 23, 2016 @01:28PM (#11346467)
...Along with allowing packages to run arbitrary JS code when installed.

That's the part that really got me. Questionable dependency practices is one thing; but running whatever JS when a package is installed, with no warning whatsoever, is probably a very bad idea.

A year ago I never ever would've thought I'd be happier writing C than NodeJS, but here I am. Weird how that works.

Re:Alert: NPM modules hijacked by jordigh on Wednesday March 23, 2016 @04:11PM (#11347799)
Essentially every package manager has to allow that, and every package manager I can think of does allow that. What's your threat model anyway? The package itself will run arbitrary code once you start using it. Is it so problematic if it starts doing that at installation instead of later?
Re:Alert: NPM modules hijacked by akerro on Wednesday March 23, 2016 @12:25PM (#11345863)
That's what happens when a language and framework have very low entry level, more and more not responsible people gather in one place. Yes, they make it popular and trendy, but they're dangerous for themselves and others.
Re:Alert: NPM modules hijacked by petetnt on Wednesday March 23, 2016 @01:30PM (#11346487)
Amazingly shameful cheap shots and mudslinging against hundreds of people from both you and @na85. Bravo.
Re:Alert: NPM modules hijacked by xredlinexx1 on Wednesday March 23, 2016 @02:26PM (#11346971)
Npm is the most miserable tool I've ever used. I just spent the last 30 minutes waiting for Windows (robocopy) to delete the node_modules directory.

It destroys days of development.

Re:Alert: NPM modules hijacked by joshuacc on Wednesday March 23, 2016 @04:49PM (#11348101)
This problem is largely solved in npm 3.
Re:Alert: NPM modules hijacked by stonogo on Wednesday March 23, 2016 @01:47PM (#11346618)
Those people deserve criticism, because they're making bad decisions.
Re:Alert: NPM modules hijacked by sangnoir on Wednesday March 23, 2016 @03:51PM (#11347641)
and by 'Those people', you mean the entire NodeJS community?

> This is the sort of amateur behaviour that is emblematic of the entire nodejs community.

This is pure mudslinging

Re:Alert: NPM modules hijacked by akerro on Wednesday March 23, 2016 @05:02PM (#11348206)
No, I'm sure he didn't meant whole community. There was a reason why njs became so popular, and there are great people behind it, but as everything that's easy to start with, it attracts people with no skills, no experience. When learning C one of the first things you learn is how operating systems work, what memory leaks are, why they are dangerous, C, C++ have higher entry level, people who stay longer with C/C++ have very good experience, they know more about security, risks, standards, systems... When you have low entry lever, you don't even bother reading on wiki what XSS is, what .ssh folder is. We just learnt the hard way that package manager for NJS is crap, just to compare it, take a look at crates of a language that has high entry level:

https://www.reddit.com/r/rust/comments/4bm3rk/how_would_crat...

Re:Alert: NPM modules hijacked by prodigal_erik on Wednesday March 23, 2016 @05:29PM (#11348408)
If any of thousands of strangers could push a button and prevent me from deploying to production, I have made several bad decisions. This seems to apply to the majority of NPM users.
Re:Alert: NPM modules hijacked by sangnoir on Saturday March 26, 2016 @05:58AM (#11365081)
> If any of thousands of strangers could push a button and prevent me from deploying to production, I have made several bad decisions.

That's a strange thing to say considering how insanely complex modern hardware and software are. While the NPM setup is indefensible, there are countless ways a stranger can prevent your deployment, if that stranger works at Microsoft, Intel, or the manufacturer of any production hardware component. OS bugs, driver bugs, compiler bugs, and hardware/microprocessor bugs are a thing. At any point, you are dependent on the work of many thousands of strangers, no matter how perfect your decisions are.

Re:Alert: NPM modules hijacked by prodigal_erik on Sunday March 27, 2016 @09:10PM (#11372200)
A proper build is hermetic. Sure we have to deal with pre-existing bugs, but nobody outside our org can make intentional changes to our build today without our actively consenting to deploy their updates after first testing them.
Re:Alert: NPM modules hijacked by akerro on Wednesday March 23, 2016 @04:12PM (#11347805)
And it's somehow one of my most upvoted answers on HN.
Re:Alert: NPM modules hijacked by dominotw on Wednesday March 23, 2016 @01:16PM (#11346377)
I use github to get golang/bundler dependencies. This could easily happen on github when someone deletes their account( or changes handle), someone could hijack their account and create a repo with same name.
Re:Alert: NPM modules hijacked by choward on Wednesday March 23, 2016 @12:54PM (#11346158)
It's insane that NPM allows anybody to un-publish modules to begin with.

Even if I have a dependency locked down in my NPM shrinkwrap file, it can change underneath me? That is pretty absurd and gives me zero confidence in my packages. It means I MUST commit them to source control or risk having my project completely broken some day.

I thought for sure that since NPM removed the ability to re-publish the same version of a package with different content that they also wouldn't let you remove versions of a package. It also means you should never user the "^" version specifier or risk downloading some completely different project.

They do have a "warning" at https://docs.npmjs.com/cli/unpublish: > WARNING > > It is generally considered bad behavior to remove versions of a library that others are depending on!

Seriously, what good does that do? Nobody takes warnings seriously.

Re:Alert: NPM modules hijacked by Wintamute on Wednesday March 23, 2016 @01:03PM (#11346263)
A specific version of a package is immutable on npm. So if you depend on exactly [email protected] in your shrinkwrap you'll always get the same code. In other words, even if the package is unpublished, and picked up by a new user they can't re-publish new code to 1.2.3.

If you depend on a version range like ^1.2.3 or ~1.2.3 its a different story, of course.

Moral of the story is imo always pin to exact versions and use shrinkwrap for production apps.

EDIT: This may not be true .. see below.

Re:Alert: NPM modules hijacked by choward on Wednesday March 23, 2016 @01:19PM (#11346397)
> A specific version of a package is immutable on NPM.

That's not true. I thought it was but it's not. That's the terrible part.

To demonstrate with one of the packages that was removed, run:

$ npm info andthen

You'll see that versions 0.0.1 and 0.0.2 were published at one point. However, for "versions" it only mentions 2.0.0. And of course, if you run:

$ npm install [email protected]

It blows up in your face.

Re:Alert: NPM modules hijacked by Wintamute on Wednesday March 23, 2016 @02:00PM (#11346744)
:o
Re:Alert: NPM modules hijacked by henrikfr on Wednesday March 23, 2016 @11:35AM (#11345389)
Insane, yes, but I guess it's just never really been that much of a problem until now. Hopefully something good will come out of this..
Re:Alert: NPM modules hijacked by smt88 on Wednesday March 23, 2016 @11:57AM (#11345578)
> it's just never really been that much of a problem until now

That's a reasonable excuse in the 90s, before automatic updates over HTTP were common. Our industry now has decades of experience securing HTTP updates and package managers, with various Linux solutions demonstrating good practices.

Re:Alert: NPM modules hijacked by gst on Wednesday March 23, 2016 @12:08PM (#11345705)
Something similar is (or at least was) true for Github: I changed my username a couple of years ago and I recently found out that another user is now using my original username. Less of an issue due to the much longer timeframe, but I think not allowing username re-use would be a safer choice.
Re:Alert: NPM modules hijacked by CorpOverreach on Wednesday March 23, 2016 @12:05PM (#11345672)
You would think this is part of security 101 for these things...

And people wonder why big enterprises are scared of touching open source stuff.

Re:Alert: NPM modules hijacked by nyan4 on Wednesday March 23, 2016 @12:57PM (#11346195)
> And people wonder why big enterprises are scared of touching open source stuff.

some open source stuff. Most enterprises dig distributions, especially with LTS.

Re:Alert: NPM modules hijacked by cyphar on Thursday March 24, 2016 @03:29AM (#11351159)
Many big enterprises run on free software. Just because this particular free software project is a shit-show doesn't make all free software projects this bad.
Re:Alert: NPM modules hijacked by FranOntanaya on Wednesday March 23, 2016 @12:49PM (#11346087)
Module repositories have been a thing for decades. Even a platform as crusty-old as WordPress doesn't allow repository take-overs for plugins. Surely someone had some experience outside npm to think about this.
Re:Alert: NPM modules hijacked by drdaeman on Wednesday March 23, 2016 @12:28PM (#11345901)
Link rot and domain squatting are a well-known decades-old issues. NPM identifiers can be considered as just another weird form of pseudo-URIs and aren't special here.

It is insane that modules don't have signatures (that are actually verified, of course). Because npm can feed you basically anything.

It's not a problem that something else gets published under the old address. It's perfectly natural. The real problem is the trust model - that new content's accepted without even warnings.

Re:Alert: NPM modules hijacked by viperscape on Wednesday March 23, 2016 @12:19PM (#11345806)
https://twitter.com/_scape/status/700453739182817281

My semi relevant tweet, it's just asking for it with that warning

Re:Alert: NPM modules hijacked by irl_zebra on Wednesday March 23, 2016 @12:35PM (#11345963)
Why not just post the tweet here instead of spamming your Twitter feed?
Re:Alert: NPM modules hijacked by viperscape on Wednesday March 23, 2016 @01:30PM (#11346479)
That's a perma link to the direct tweet... why paste in the tweet when I can just link it...
Re:Alert: NPM modules hijacked by aw3c2 on Wednesday March 23, 2016 @02:18PM (#11346895)
Re:Alert: NPM modules hijacked by prodigal_erik on Wednesday March 23, 2016 @01:49PM (#11346638)
HN would be unusable if everyone stopped writing comments and just pasted links to an ephemeral third-party service.
Re:Alert: NPM modules hijacked by douche on Wednesday March 23, 2016 @03:02PM (#11347270)
Bravo, you've illustrated the whole problem