News for hackers. Stuff that matters.
Re:Small world with high risks: a study of security threats ... by segphault on Monday September 30, 2019 @04:37AM (#21112913)
What the npm ecosystem really needs is something like the distinction between Ubuntu's "main" and "universe" repositories, so that you have a smaller subset of known-good packages with harmonized transitive dependencies, stronger centralized curation, a lot more direct scrutiny, tighter control over versioning, and some party that is responsible for addressing vulnerabilities and ensuring appropriate maintainership. If you could rely on that for core functionality and only needed to go outside of it for the long tail of more specialized things, it would be a lot cleaner and safer than what we do today.

Linux distros have many, many years of experience curating packages at scale. It is crazy to me that the node community just totally disregards all of the best practices learned by the Linux distros in favor of practices that are lazy and unambiguously dangerous.

Re:Small world with high risks: a study of security threats ... by bostik on Monday September 30, 2019 @05:22AM (#21113163)
Intel and Nokia were trying to add repository trust levels to rpm back in 2010/2011.

To this day, if you can add a new repository, it is fully trusted and can provide trojaned updates to any core package. Bump the version number to something higher than what the core distro would use and you can persist for quite a long time. I remember pointing this out at a Nokia project (would have been no later than early 2008) as an attack vector via apt repositories.

We wanted to prevent a rogue or compromised repository from being able to provide an update to, say, glibc or libstdc++. Never got to work on that - Elopcalypse took it all down.

Re:Small world with high risks: a study of security threats ... by hnarn on Monday September 30, 2019 @07:57AM (#21114272)
> To this day, if you can add a new repository, it is fully trusted and can provide trojaned updates to any core package.

Invent idiot-proof security and someone will invent a better idiot. Even if you have a "trusted=1" flag for repos, you can be sure people will set external repos to be just as trusted as the core ones without a second thought as soon as they stop them from doing what they want to do (whatever that is, or however in/sane it is).

It's maybe not the most elegant option, but for security-conscious sysadmins you could already today disable all repos ad hoc and run your "system wide update" only from certain whitelisted repos, while still allowing specific one-off package installs from third party repos.

By adding a third party repo you have already said you trust that repo to install software, probably as root, on your machine. It doesn't get much worse than that from a security standpoint anyway right, will "trust flags" really make much of a difference to the wider security issue?

Sorry if I'm making too many assumptions here or thinking out loud.

Re:Small world with high risks: a study of security threats ... by bostik on Monday September 30, 2019 @03:09PM (#21118648)
> Even if you have a "trusted=1" flag for repos, you can be sure people will set external repos to be just as trusted as the core ones

That was the thing - you couldn't.

I don't remember which way the level hierarchy went, but the idea was that rpm could not be executed directly even by root (LSM prevented that), and all package installation logic was confined to Zypper/libzypp. Packages and repos could declare their security level. Trying to pull in an upgrade to a LEVEL(core) package from a LEVEL(media) repository would fail. Zypper simply would not allow to install a package from a lower-security repository over an installed package that had come from a higher-security origin. Manually added LEVEL(core) repos would have been ignored.

There were a few layers of applied crypto, package signatures and immutable keyrings involved too. I had a prototype Zypper/libzypp with package-level signature verification almost ready just before my vacation and planned to polish it to an RFC after coming back. Best laid plans... During those two weeks the entirety of Nokia's linux development had been axed, maemo killed and thousands of good embedded systems engineers were suddenly looking for new jobs.

Funny thing, though. Zypper's source code was almost pleasant to work with after having seen the Lovecraftian horrors that made up libapt.

Re:Small world with high risks: a study of security threats ... by marcosdumay on Monday September 30, 2019 @11:03AM (#21116082)
Take a look at Debian's package pining.

It's not a security feature, but a convenience one for forbidding repositories from updating the packages from the ones you trust more (with correctness). Yes, a binary flag would be useless. What the GP wants also does not add any security, but it's an important part of a stable system that language-specific repositories have been overlooking for a while.

Re:Small world with high risks: a study of security threats ... by pferde on Monday September 30, 2019 @09:30AM (#21115114)
Debian-based distros can use package pinning to this effect, but since it is an opt-in feature for advanced users, it is not a full solution. I'm mentioning it here just for sake of completeness.
Re:Small world with high risks: a study of security threats ... by blobs on Monday September 30, 2019 @05:43AM (#21113280)
Totally second this. I see novice web developers writing in Typescript in an effort to be more type save and at the same time using hundreds of npm packages that are often written by amateurs that make basic mistakes.

Just take an average startups web project node_modules directory, what's inside there? Hundreds and hundreds of packages of which most are dependencies of other packages. Anyone could have written it! Novice devs swear by using Typescript, but at the same time using hundreds of black boxes that can easily contain stuff way more damaging that a string applied to a number..

Remember left-pad? That was an easy one to fix, but still caused damage at large scale. What about a vulnerability in a larger and more complex package, owned by some bad party?

Re:Small world with high risks: a study of security threats ... by jannes on Monday September 30, 2019 @05:53AM (#21113325)
For me the biggest problem is webpack. Do you know an alternative bundler with less dependencies and typescript support? I already use webpack without the webpack-cli package in most of my projects in order to avoid the extra dependencies.

I'm currently investigating rollup because it only has 3 dependencies (2 of which are @types)

Re:Small world with high risks: a study of security threats ... by marcus_holmes on Monday September 30, 2019 @11:21AM (#21116282)
I'm trying to use Vue in a secure web app, and Webpack is a nightmare. I have to trust hundreds of dependencies to use it at all. Trying to avoid this and use some other method of compiling multiple .vue single-file components into a larger single js file is proving tricky (to say the least). How did the JS ecosystem end up in this situation?
Re:Small world with high risks: a study of security threats ... by rmilejczz on Monday September 30, 2019 @08:52AM (#21114782)
I recommend rollup for libraries and parcel for web apps.
Re:Small world with high risks: a study of security threats ... by lucideer on Monday September 30, 2019 @09:35AM (#21115162)
I'll 2nd the rollup recommendation for libraries, but unfortunately parcel has the same (or worse) problems as Webpack with it's proliferation of dependencies.

Rollup does have some issues with webapps since it's so heavily oriented toward JS-as-entrypoint, but tbh Webpack has the same issues; it just works around them by layering some extra complexity on top in the form of plugins (which you can actually do relatively easily in rollup too, though it's still not ideal in either situation).

Edit: Just measured those dependencies for comparison.

- rollup: 3 dependencies (all top-level, none have subdependencies. 2 are just typings which contain no executable code)

- webpack: 425 dependencies (23 top-level)

- parcel: 837 dependencies (57 top-level)

I haven't used parcel, so can't comment on its function. By the sounds of their website they're focused on speed, so if performance is your only concern they might be a good shout. If you're looking to reduce your security surface area, their approach to dependency management seems pretty irresponsible.

Re:Small world with high risks: a study of security threats ... by rmilejczz on Monday September 30, 2019 @11:46AM (#21116615)
Yeah I actually didn’t realize parcel had so many dependencies. I choose it over webpack not for speed but because it’s highly opinionated and requires essentially zero config.

So I guess I’ll change my suggestion and say just use rollup

Re:Small world with high risks: a study of security threats ... by jannes on Monday September 30, 2019 @09:31AM (#21115135)
Parcel has 57 dependencies... (not even counting transient dependencies)

That sort of defeats the purpose of switching from webpack.

And for libraries: Why do you even need a bundler? Can you not distribute the library as multiple files?

Re:Small world with high risks: a study of security threats ... by rmilejczz on Monday September 30, 2019 @12:02PM (#21116810)
Yeah I made some incorrect assumptions about the nature of parcel, foolish mistake on my part.

For your other question it depends on your library. If you’re only targeting ESM or CJS sure, if you need a UMD or want separate outputs for separate targets a bundler like rollup can help prevent a lot of pointless boilerplate.

Re:Small world with high risks: a study of security threats ... by sebazzz on Monday September 30, 2019 @10:34AM (#21115767)
Isn't parcel a front-end for webpack?
Re:Small world with high risks: a study of security threats ... by pjc50 on Monday September 30, 2019 @06:22AM (#21113457)
> It is crazy to me that the node community just totally disregards all of the best practices learned by the Linux distros in favor of practices that are lazy and unambiguously dangerous.

"Move fast and break things."

The whole Javascript ecosystem depends on high churn rapid adoption of "new" technologies. Stopping to check things would slow this down. Higher-QA technologies get outcompeted by lower-QA technologies.

Re:Small world with high risks: a study of security threats ... by zbentley on Monday September 30, 2019 @08:36AM (#21114640)
> Higher-QA technologies get outcompeted by lower-QA technologies.

While both are still relatively strong, it seems that JS's recent (~8y) surge in popularity over established mainstays like Java may stands counter to that point.

Re:Small world with high risks: a study of security threats ... by pjc50 on Monday September 30, 2019 @08:38AM (#21114662)
JS has a unique position in being the only supported language in browsers after Java Applets, Flash, and ActiveX were all killed off (mostly for valid reasons).

Given that the frontend has to be written in Javascript, it's tempting to use it for the backend as well.

Re:Small world with high risks: a study of security threats ... by xkcd-sucks on Monday September 30, 2019 @11:09AM (#21116145)
The software industry is where quality goes to die, if anything the surge in popularity proves the point
Re:Small world with high risks: a study of security threats ... by dsfyu404ed on Monday September 30, 2019 @10:29AM (#21115702)
>Linux distros have many, many years of experience curating packages at scale. It is crazy to me that the node community just totally disregards all of the best practices learned by the Linux distros in favor of practices that are lazy and unambiguously dangerous.

"Screw your wheel, we can invent invent our own" is not exactly a surprising strategy when it comes from the language/development community that is mostly building framework after framework that gets abandoned in a year or two.

Re:Small world with high risks: a study of security threats ... by lachenmayer on Monday September 30, 2019 @09:31AM (#21115130)
In the React Native ecosystem, the Expo project https://expo.io is doing a great job at providing this kind of centralized curation, with monthly release cycles, constistent APIs and dealing with the version hell that makes "raw" React Native such a pain to work with.