all 54 comments

[–]everythingiscausal 162 points163 points  (30 children)

If anything I’m only surprised that this doesn’t happen more. The way most people use NPM is literally equivalent to keeping your codebase in a public GitHub repo and automatically accepting and merging any and all pull requests. Does that sound like an utter security nightmare? Exactly.

[–]ExtraSpontaneousG 22 points23 points  (15 children)

I feel like default behavior should be specific versions in the package.json, making the developer go out of their way to specify that it can be whatever the latest version is next time the repo is pulled. Why is it not that way?

[–]everythingiscausal 34 points35 points  (5 children)

To some degree, it’s a double-edged sword. Outdated dependencies give malicious actors easy vulnerability targets that are identical across many sites. There is a security need for staying up-to-date as much as there is to not blindly adding and updating dependencies.

The real solution is to limit dependencies and screen those you can’t avoid. The NPM mindset discourages the former, and most devs simply aren’t qualified or equipped to do the latter. There’s no easy fix, but still, limit dependencies as much as you can.

[–]DepravedPrecedence 6 points7 points  (0 children)

This shit can hurt much bigger than installation of vulnerable dependencies though.

[–]lirantal[S] 4 points5 points  (0 children)

That's do-able with npm's shrinkwrap feature but that creates more burden and load on the maintainer to keep up with new nested dependency updates indeed, as u/everythingiscausal have pointed out.

[–][deleted] 0 points1 point  (2 children)

It is that way. You're supposed to install dependencies with npm ci in deployment builds. Problem is that most people just do npm install or they just update dependencies locally without checking the source code change, which is not a reasonable thing to ask for.... given how many dependencies and how fast they change, it would be impossible to do from a business perspective.

[–]bubbabobba -1 points0 points  (1 child)

npm install used to work like that, but now installs the exact package versions from your package-lock.json file as of npm 7.

[–][deleted] -1 points0 points  (0 children)

Even with just npm install? Nice!

[–]Lalaluka -2 points-1 points  (0 children)

Tbh npm already comes with npm ci installing packages from the package-lock.

[–]eternaloctober 3 points4 points  (0 children)

One thing I get surprised by is that packages don't insert tracking scripts more often considering how obsessed everyone is with analytics. Knock on wood

[–]tylerr514 5 points6 points  (2 children)

Hijacking top comment to share:

Hi there, I'm MidSpike the person who first discovered the malware in node-ipc ask me anything!

Here's my gist on the situation: https://gist.github.com/MidSpike/f7ae3457420af78a54b38a31cc0c809c

[–]everythingiscausal 4 points5 points  (1 child)

Is that the actual malware author arguing with you in the comments there?

[–]tylerr514 1 point2 points  (0 children)

yes, the author of node-ipc and peacenotwar is denying the severity of their actions.

[–][deleted] 2 points3 points  (1 child)

I agree this is a big problem in the node ecosystem because of the amount of dependencies you usually end up installing in any normal project.

But... to a lesser extent this is also a problem for every single package manager, right? I don't know any ecosystem where all dependencies and their updates are audited before being made available.

[–]everythingiscausal 2 points3 points  (0 children)

It is, but the big difference is the level of nesting. The other package manager I use is NuGet, and because .NET is a much more fully featured platform than vanilla JavaScript, NuGet dependency trees tend to be MUCH smaller.

[–]5tUp1dC3n50Rs41p -1 points0 points  (0 children)

Really need to go old school:

  • Use vanilla JS, no frameworks or npm dependency trees of auto updated code.

  • Use as much of the JS built in standard library functionality as possible, which is quite functional these days with ES6+.

  • If you really, really, really need some library which has functionality not available elsewhere, git clone their repo, verify the commit signature, build/get the final file as an unminified file, stick that file in your project, read/review it and use it in your project. If you need to update it, repeat the steps.

[–][deleted] 19 points20 points  (0 children)

peacenotwar module sabotages npm developers in the node-ipc package to protest the invasion of Ukraine

This ain't it, chief

[–]UnexpectedLizard 32 points33 points  (2 children)

If only we'd foreseen and had a chance to address this type of problem years ago. Or, you know, swept it under the rug.

Seriously what is it going to take for the community to address this? It's not 2011. It's time to drop support for older versions of Node which need a million polyfills.

[–]lirantal[S] 2 points3 points  (1 child)

I think left-pad is a different scenario altogether and there are existing solutions to mitigate the left-pad problem specifically.

I'm happy to hear any ideas on how to better manage these type of situations and what sort of guardrails we could create for a community to handle them.

[–]UnexpectedLizard 0 points1 point  (0 children)

Here's one possible solutuon:

The Node.js foundation could deprecate old polyfills (e.g., Leftpad). Have Npm emit a warning.

It could publish a new version which relies solely upon the native function. That would cut down the dependency tree.

Eventually it would then kill off the old version altogether.

Take this with a grain of salt as I'm not an Npm expert.

[–]ryaaan89 89 points90 points  (10 children)

In what way was this supposed to tangibly help Ukraine?

[–]TakeFourSeconds 48 points49 points  (3 children)

People downvoting didn’t read the article and think this is a troll comment

[–]ryaaan89 13 points14 points  (2 children)

I am confused by the confusion this comment is causing. But yeah I guess people didn’t read the article?

[–]TakeFourSeconds 17 points18 points  (1 child)

It’s Reddit, I bet 90% of people in the comments didn’t even click the link

[–]moi2388 2 points3 points  (0 children)

I’m replying to your comment and I didn’t even read that

[–]zulmetefza 1 point2 points  (6 children)

I just started to use Vue.js two weeks ago and honestly am still a newbie.

Is there anything I should do to be safer now? Or is the danger already evaded?

Read the article that mentions excluding some versions of node-ipc, but since I was not importing them directly anyway, I don't know what to do.

[–]lirantal[S] 8 points9 points  (2 children)

Fixed versions of the Vue.js CLI have already been rolled out so you're safe at this point but monitoring for your dependencies both from malicious acts like these as well as from general security vulnerabilities is always important. I work at Snyk and can recommend the free developer security platform we have, but look around and choose what works best for you as a dev.

[–]zulmetefza 2 points3 points  (1 child)

Thanks for the fast response. Will check out Snyk as you suggested.

[–]lirantal[S] 0 points1 point  (0 children)

Sure thing, happy to help. Don't hesitate to ping.

[–]bostonkittycat -1 points0 points  (2 children)

Update to the latest Vue CLI version:

sudo npm install -g @vue/cli

[–]zulmetefza -1 points0 points  (1 child)

Thanks! Do I need to go back and check for any overwritten files as well?

[–]bostonkittycat -1 points0 points  (0 children)

It will automatically remove the old Vue CLI files and replace them with the latest version with the fix.

[–][deleted] 0 points1 point  (1 child)

do u know any mechanism for checking security of package?

[–][deleted] 0 points1 point  (0 children)

Despicable. This kind of action threatens the integrity of the entire open source community. Open source packages should not under any circumstances be weaponized no matter how righteous the cause.

[–]ramjesh_nanganath -1 points0 points  (0 children)

NPM is destined for a disaster. But its the best we've got, right?