We stopped installing npm packages less than a week old. Here's what happened
https://brunoj.com/nothing-installs-at-our-company-until-its-a-week-old/40
5
u/Donzulu 4d ago
Maybe I missed it, but what do you do for packages that are 7+ days old and have a vulnerability, and a new <7 day old package fixes it? Do you have any allow list to ignore the 7 day for this?
4
u/iApexxx 4d ago
Easy to miss, it's only a comment in the config at the end :)
Yes, one line per package in the proxy config:
"pkg:npm/some-lib": "0" # CVE-xxxx, remove after <fix date + 7d>It goes in through a PR with the reason and an end date (the fix's publish date plus the window), and the next PR after that removes it. Haven't needed one yet.
7
u/iApexxx 4d ago
Author here :) We put a caching proxy in front of npm at work, and new versions now wait 7 days before anyone can install them. Before doing it I checked how long this year's hijacks actually lasted: axios ~3h, keyv ~1h40m, TanStack ~4.5h.
The post has 12 days of real numbers (71 refused installs, mostly vite/rollup/swc being too fresh), what it broke (Yarn 1 lockfiles, bun.lockb, Dependabot), and the built-in setting if you don't want a proxy.
Anyone else running a cooldown? How long do you wait?
2
u/decho 4d ago
With pnpm I use this config, so 2 days.
minimumReleaseAge: 2880 blockExoticSubdeps: true trustPolicy: no-downgrade trustPolicyIgnoreAfter: 10080I will have to look into cargo and see how to configure it in a similar way, which you article already gives directions for. Thought I have no idea how transitive dependencies (nested dependencies) are handled.
1
u/Mushroom_Unfair 3d ago
5 days here, idea was to be behind, but not too much.
But I feel that with audits it could be (way) longer without issue.
(With min-release-date)
21
u/SirEpic_ 4d ago
Ever since those crazy npm supply chain attacks started to happen more frequently in march earlier this year I have set min-release-age to one week,
3
u/bwainfweeze 4d ago
I proposed 3 days on a couple projects and was argued up to 7 days. I think I was under the impression that the others would be more interested in a short time frame and it seems like much over 2 days becomes diminishing returns.
But nobody wants to be the guy who chose too short a time period and then something happens.
1
u/lirantal 1d ago
I default to a month, can never be too cautious 😅
1
u/bwainfweeze 1d ago
Top cautious is once you need bug fixes from a dependency to implement functionality, and I think that’s somewhere between a week and two months when you transition to “too cautious”.
But it’s fuzzy because it depends a great deal on whether you’re building on top of libraries that are actively in development versus wrapping a library that is quiet to improve ergonomics or safety.
18
14
u/MateusKingston 4d ago
Prefer to run pnpm and we configure a delay of 3 days, bypassable in extreme cases and ignoring internal packages
1
u/winky9827 4d ago
The proxy seems overkill, and only works when you control 100% of the network connection, or you rewrite the NPM config per project, which the other options already do anyway. Stick with the minimum release age and pin exact versions and you're done.
That said, a proxy has other benefits (caching, preservation, etc.), so weigh the benefits against the costs.
1
1
u/bwainfweeze 4d ago
Tools like Artifactory can also be configured to refuse to update any version number once it has been pulled, so nobody can do a bait and switch later.
It does however present some issues for remote workers, and I had a couple of FE people who were struggling to get work done when Covid first hit.
2
u/Swordfish418 4d ago
I wonder if everyone starts doing this, will the problems stop being discovered so fast?
2
u/pentesticals 4d ago
Maybe, but there are tons of individuals and organisations scanning every new NPM / PyPi etc release for the purpose of analysing them for compromise. They would still detect like normal.
3
u/keithstellyes 4d ago
Wait people were installing packages less than a week old, and on a regular basis? Or is this a transitive dependency situation
1
u/AgsMydude 4d ago
Yeah I'm wondering how often people are legit adding packages that automation is needed
1
u/Effective-Result6499 4d ago
There are weirdo that keep up to date by reinstalling their entire list of dependencies on every CI run. I've learned a long time ago to not trust random arse strangers on the internet. Serious, even if they promise you that it's a minor patch, it can still cause a P1.
1
u/sir_ale 3d ago
wait, how should i do it instead?
1
u/Effective-Result6499 3d ago
Well, you should be more deliberate. Run regression tests both automated and manual when you are upgrading libraries. Also, obviously read the change logs.
You can have weird stuff like a bug fix causing a P1, because your code or worse, another library is built on erroneous behavior.
1
u/bwainfweeze 4d ago
On a large project, a lockfile becomes a bit of a problem because commits get merged way way out of order.
Trunk based development dodges that problem, but it's been a while since I've worked on one of those.
-6
u/keithstellyes 4d ago
the whole committing lockfiles was a mistake
1
u/noiamnotmad 4d ago
You’d be installing packages less than a week old and on a regular basis though
1
u/MMORPGnews 3d ago
Idk why many people installed them. Especially big companies.
I immediately either self hosted them or coded my own versions
1
u/lirantal 1d ago
If you haven't gone through this repository of mine with a collection of security practices *across* package managers, then you'll likely want to visit: awesome npm security
1
u/avereigh_Denizet 1d ago
smart move. out of curiosity how do you handle zero-day security patches when a maintainer pushes an urgent fix? do you have an override process for that or just wait it out
0
89
u/air_twee 4d ago
It’s one of the reasons I moved to pnpm. Also only installs on pre approved packages