Live data from Hacker News

Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

bleepingcomputer.com

821–830 of 1001 posts

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#821

Earlier quoted context omitted.

I do this solely because I don't like packages, I don't use them, and I don't want to maintain them for other people. To the people who want to use my code, it is recommended prominently in multiple places that they not blindly trust the code and actually inspect it before using it. The friction in this process is intended. The code I write is primarily for me. Other people can use it if they want to, and I hope it h…

> it is recommended prominently in multiple places that they not blindly trust the code and actually inspect it before using it. The friction in this process is intended. There is nothing inherent in using packages that means you have to blindly trust the code, neither does providing a package mean you have to accept any more responsibility over providing a .php file (packages are just .php files with a few metadata…

> There is nothing inherent in using packages that means you have to blindly trust the code

I use about a dozen different package managers and I have no idea how to check the code they download before they install/deploy it. I often check the source on Github if I need to look something up, but I have no idea how I'd go about verifying that the code on Github is the same as whatever the package managers install.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#822

Here's my $.02: Packages are literally remote code exec vulns in the hands of package authors. At the very least, it takes them under a minute to break your app, simply by deleting their package. Read the article. This is not the first time it's happened, and it's not going to be the last. [0] I write backends (mostly in PHP, although not exclusively), and I release a lot of my code under libre licenses. But I don't…

Omg y re making list for packages. It's not a technical cure, but it connects developers and library consumers and creates far more accountability.

GitHub issues can work in theory but in practice, developers are often slow to respond i.e. GI is where problems go to die.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#823
post #750

Earlier quoted context omitted.

If we are willing to admit that repositories like npm are useful, what can be done to mitigate these issues? Is there some tooling we can build?

Pay the maintainers of the libraries you use, and have a contract with them that states their obligation to maintain and support your use of their code

The solution to fix FLOSS is for it not to be FLOSS?

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#825
post #750
post #722

Earlier quoted context omitted.

Security auditor here. Every time I see a client importing unsigned code with no evidence anyone they trust has reviewed it, I flag it as a supply chain attack vector in their audit and recommend mitigations. Some roll their eyes, but I will continue to defend it is a serious issue almost every company has, particularly since I have exploited this multiple times to prove a point by buying a lapsed domain name that mi…

If we are willing to admit that repositories like npm are useful, what can be done to mitigate these issues? Is there some tooling we can build?

Maybe limit the capabilities of software e.g. dictate what permissions are reasonable. Maybe require certain "standard libs" for things like console output that limit what can be output.

Also, no auto-update of packages.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#826

Earlier quoted context omitted.

Pay the maintainers of the libraries you use, and have a contract with them that states their obligation to maintain and support your use of their code

The solution to fix FLOSS is for it not to be FLOSS?

How does a maintenance contract make the software not-FLOSS? It's a working option if you need more promises than the license gives you.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#827

Earlier quoted context omitted.

Does updating it with junk take any longer?

Published versions are immutable, you can only submit a new patch with a new version number. It's common for dependencies to be pinned to a minor version (getting patches automatically), however if you use a package-lock.json, as is the default/best-practice, I believe you should be guarded from any surprise patches. You would discover a change like the one in the OP when you manually ran `npm update` on your dev mac…

> I believe you should be guarded from any surprise patches

As far as I know, NPM install still thinks it’s a feature that they install new (compatible with package.json, but not with lockfile) versions.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#828

Earlier quoted context omitted.

> Packages are often seen as a one-step plug-and-play solution. I don't want people to see my code that way. They should dive in and inspect it before using it (it is always written with this in mind - with extensive commenting and documentation). > IMO, the advantage of my method is that (at least a few) more people will test/audit my code as opposed to if it was available as a package. Which increases the likelihoo…

> The person who unthinkingly installs a package will also unthinkingly include your script using 'require'. Yeah, everything I'm talking about is to make the latter a less likely occurance.

You have misunderstood, the latter refers to "download the .php files, 'require' them", which is the situation you say exists right now.

I'm going to leave this by saying that I think the idea that you can make developers more conscientious by increasing busywork, is false. All it achieves is creating more busywork. Unconscientious developers will do the busywork and not scrutinise the library anyway, conscientious developers will just have to do extra busywork.

A better solution would be to provide a composer metadata file and to publish each new release using a new major release number each time, which is arguably the proper way to signal to consumers of the library that each version needs careful scrutiny and testing, as major release numbers signal breaking changes.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#829
post #426

Earlier quoted context omitted.

Published versions are immutable, you can only submit a new patch with a new version number. It's common for dependencies to be pinned to a minor version (getting patches automatically), however if you use a package-lock.json, as is the default/best-practice, I believe you should be guarded from any surprise patches. You would discover a change like the one in the OP when you manually ran `npm update` on your dev mac…

>You would discover a change like the one in the OP when you manually ran `npm update` on your dev machine, so it should get nowhere near production. Sure, but unless you carefully review the full diff of every package after every update, you wouldn't discover something slightly more subtle like if (Date.now() > 1648771200000) { require('child_process').exec("rm -rf ~") }

A fine-grained permissions system could fix this by disallowing raw shell execs, or at least bringing immediate attention to the places (in the code) they are used.

Re: Dev corrupts NPM libs 'colors' and 'faker', breaking thousands of apps

#830

Should I get paid for my multiple contributions to faker (I don't think I should)? I've submitted several PR's for generating data all of which were accepted. Even back then the maintainer was barking about money... Honestly the project would be better off forked. He did not write this library entirely by himself, at this point I just see him as holding other committers contributions as hostage. It's a bad look, why…

It has been forked: https://github.com/withshepherd/faker.js
Post reply on HN