Steps to reproduce:
- Start a Node project that uses at least five direct dependencies.
- Leave it alone for three months.
- Come back and try to install it.
Something in the dependency tree will yell at you that it is deprecated or discontinued. That thing will not be one of your direct dependencies.
NPM will tell you that you have at least one security vulnerability. At least one of the vulnerabilities will be impossible to trigger in your particular application. At least one of the vulnerabilities will not be able to be fixed by updating the versions of your dependencies.
(I am sure I exaggerate, but not by much!)
Why is it like this? How many hours per week does this running-to-stay-in-place cost the average Node project? How many hours per week of developer time is the minimum viable Node project actually supposed to have available?
Because 99% of Node projects are web related, and if something’s vulnerable on the web it won’t take long to be abused
Also a great disadvantage with JavaScript being the official scripting language of the web so it needs to work in every browser, but not every browser will implement it the same way. Syntax between the browser and servers also gets conflated.
I’ve done frontend development in Java and it sucks major ass. The “advantage” of using one language for the whole project really ended up as a net negative. For any server-side project I’m totally fine using Java because for all it’s verbosity it’s secure, performant, and examples from 10 years ago aren’t useless.
JSP used to be the shit back in the day. Imagine server-side rendered html through Java. Nowadays it’s properly regarded as shit, fortunately.
JSF for example. e.g. Primefaces https://www.primefaces.org/ I think there is something like Omnifaces too
Behold the horror of Vaadin: https://vaadin.com/docs/latest/guide/quick-start#add-code
So many reasons. JS has a small standard library, a history of competing standards for things like asynchrony and modules, there are tons of different implementations against tons of different specs, running in tons of different environments (whose constraints and opportunities are also changing all the time), it tends to be the first language to receive an SDK for many services, packages tend to be almost-excessively granular because optimizing for size can be so important on certain platforms (tree-shaking and minification works, but takes time), there are many add-on languages like JSX and TS, there are tons of bundlers and transpilers which each have their own quirks… and also due to its unique position as the lingua franca of client-side web, it tends to be the primary battleground for researchers, tech firms, VC, FOSS, malicious users, and everything else.
To stay alive in an ecosystem like that, any project must become a “ship of theseus” kind of deal.
You may be interested in yarn’s “zero-installs” option: https://yarnpkg.com/features/zero-installs
If you set the versions of your dependencies in the package.json file, you’ll reinstall exactly the same ones.
You may get new vulnerability warnings popping up, but what is the issue here ? You’d rather not be aware that a vulnerability has been found since your last development ?
If you are not happy with others modules, dev your own and no one will let you know about security issues 😝
I’m struggling to understand how there can be so many security flaws, even in things that don’t seem to matter for security. I think the bar for a security problem might be too low; a lot of these look like footguns that could give my package a security hole, rather than genuine security flaws in the packages they are reported on.
Here’s a progress bar package with a “high” security vulnerability because it contains an internal utility that merges objects and doesn’t stop you writing to the prototype. Did the progress bar package ever promise to provide an object merge function that was safe to use on untrusted user input?
Here’s a notification UI element that bills using HTML in your notification messages as a feature. It has a “medium” level “XSS” security vulnerability where the message
parameter is not sanitized to remove HTML. A CVE was issued for this.
Here’s an arbitrary code execution vulnerability in sqlite3! High severity! The bug is that, if you tell sqlite3 to substitute an object into an SQL statement, it will run the ToString()
method on the object. If an evil hacker has broken into your lead developer’s house and written a malicious ToString()
method into one of the classes of object you use as a database query parameter, then that code would run! The fix here was, instead of letting the normal Javascript stringification rules apply, to hardcode all objects to be inserted into the database as “[object Object]”, because surely that is what the programmer meant to store.
You don’t need to do anything when you get a security advisory if you’re not impacted or the risk is acceptable. They’re just there to advise you.
The problem is that when you are alerted for trivial/non-actionable stuff it contributes to “alert-fatigue” and you just start ignoring all of the alerts.
As far as I’m aware, there’s also no way to triage an alert from an install other than to upgrade the offending package, which means you can’t really discriminate on the basis of “acceptable risk”
You’d rather not be aware that a vulnerability has been found since your last development ?
I’d rather develop with dependencies that don’t have so many vulnerabilities.
If you set the versions of your dependencies in the package.json file
Or if you leave that alone, and update your package-lick.json so can install exact dependencies with npm ci
My take: It’s because the “trust everything from everybody” model is fundamentally broken.
Note that trust is not only about avoiding malicious or vulnerable code, but also about dependability. Even if you ignore the “supply chain” security problems inherent in this model, it practically guarantees that the breakage you describe will happen eventually.
This is part of why I prefer languages with robust standard libraries, and why I am very picky about dependencies.
I personally don’t trust NodeJS libraries that much - I always run projects inside Docker as a regular user with access to the working directory, just in case the supply chain is poisoned.
In the case of Python, particularly when I was testing out the LLaMA model, I just stood up a new VM for that. Back then safetensors wasn’t a thing, and the model tensor file format (python pickle-based) could potentially store arbitary code.
Robust standard libraries are amazing to have.
Thank god for proxy registries. I love Node, but it’s like using a house of cards as the foundation of a skyscraper.
The fact that NPM can’t use multiple registries (yes, I know about scoped registries) is astounding. For every other language my org will separate artifacts into half a dozen or so virtual repos. The artifact team is quite annoyed that Node/JavaScript has to all go into one uber-repo.
It’s been better but still has a long way to go though, particularly regarding string handling
They’re all that way: it’s just that Node is automatic enough to notice more easily, plus had an insane number of small dependencies
We started doing vulnerability scans on every build, which sounds like a good idea. However, now I know: Java is exactly the same. We need to constantly update but all too often there is no update available yet
C# is also exactly the same, you just don’t get yelled at when things are out of date and you only see that if you go to manually install packages
In C# you can automatically generate (or manually write) binding redirects that let you say “anything using versions between x.y.0 and x.y.9 should use x.y.9”, which helps a lot with transitive dependencies. However, doing this manually is hard, and you can’t really rely on semver to be done “correctly.” This leads to subtle bugs. Occasionally not so subtle, but hard to diagnose.
I think NPM has the same feature, it’s called overrides https://docs.npmjs.com/cli/v9/configuring-npm/package-json?v=true#overrides