Show HN: Safe-NPM – only install packages that are +90 days old
90 points| kevinslin | 3 months ago |github.com
Install: npm install -g @dendronhq/safe-npm Usage: safe-npm install react@^18 lodash
How it works: - Queries npm registry for all versions matching your semver range - Filters out anything published in the last 90 days - Installs the newest "aged" version
Limitations: - Won't protect against packages malicious from day one - Doesn't control transitive dependencies (yet - looking into overrides) - Delays access to legitimate new features
This is meant as a 80/20 measure against recently compromised NPM packages and is not a silver bullet. Please give it a try and let me know if you have feedback.
sebmellen|3 months ago
Pardon me, I couldn’t help myself :D
mort96|3 months ago
The problem with NPM isn't any one young package. The problem with the NPM is that any time you run 'npm install', you download potentially thousands of packages, and you get the most recent patch release from all of them. Installing one 1-day-old NPM package to forever avoid day 1 releases of thousands of packages seems like a worthwhile trade.
Still, I would maybe choose the tried and true PNPM instead, which supports this too.
MuffinFlavored|3 months ago
h33t-l4x0r|3 months ago
moritzwarhier|3 months ago
And as far as cat-and-mouse-games go in other package managers, I'd say that pinning dependencies and disabling postinstall scripts is a much better option. Sure, not a foolproof one either, but as good as it gets.
edit: misspelled someotherguyy's user name
buu700|3 months ago
Related to that is the proposal for `stabilityDays`, which seems way more practical: https://github.com/npm/cli/issues/8570#issuecomment-33004136.... So rather than merely saying "I only want package versions more than N days old", you'd be adding the requirement that "...and also they should have gone at least N days without a subsequent patch release". e.g. if mylib@6.0.0 is released, only to be quickly followed by 6.0.1 and 6.0.2, you ideally wouldn't want to risk ever installing the probably-broken 6.0.0 or 6.0.1 based on luck of the draw; the better behavior would be to stick with the last 5.x release until 6.0.2 has aged past the threshold.
2muchcoffeeman|3 months ago
tkzed49|3 months ago
zelphirkalt|3 months ago
someothherguyy|3 months ago
zelphirkalt|3 months ago
A cooldown time alone is not actually a sufficient solution. What people really need to stop doing, is not properly pinning their versions and checksums, and installing whatever newer version is available. That would cause a problem even, if the date line is moved 90 days into the future for all packages. If however, one only updates versions of dependencies when one consciously makes that choice, there are far fewer points in time, when versions change, and therefore the chance of catching something is also much lower. Combine that with a cooldown time/minimum age for versions, and you got an approach.
LelouBil|3 months ago
mrconter11|3 months ago
jagged-chisel|3 months ago
pr0xyb0i|3 months ago
silverwind|3 months ago
asdkkthrowaway|3 months ago
beepbooptheory|3 months ago
https://blog.yossarian.net/2025/11/21/We-should-all-be-using...
Most of the time, you need quick patches because of fairly recent dependency changes, so if you just wait and kind of "debounce" you dependency updates, you can cover a lot of supply chain vulnerabilities etc.
moritzwarhier|3 months ago
Scheduled, audited updates are good.
Installing random npm packages as suggested here is also bad. Especially with "--global", although I'm not sure if that makes any difference because Node by default of course can access all of your file system.
yokto|3 months ago
ttoinou|3 months ago
lelandbatey|3 months ago
aussieguy1234|3 months ago
Its the opposite of "keep your software up to date"
waterTanuki|3 months ago
PunchyHamster|3 months ago
> Installs the newest "aged" version
Probably want to install version that has CVE-fixed instead, i.e find the cve for packages and install latest version that has all of them fixed but not later.
Technically someone could fake a cve to get people to upgrade but that's a far more involved process
codezero|3 months ago
spullara|3 months ago
unknown|3 months ago
[deleted]
vrighter|3 months ago
mdx97|3 months ago
robkop|3 months ago
m4rtink|3 months ago
ghtbircshotbe|3 months ago
unknown|3 months ago
[deleted]
arrty88|3 months ago
actionfromafar|3 months ago
zelphirkalt|3 months ago
catlifeonmars|3 months ago
cheesekunator|3 months ago
Waterluvian|3 months ago
The idea of “safe” in terms of risk and security has misled a lot of people into this wrong idea that there’s a binary state of safe and unsafe.
It’s all about risk management. You want to reduce risk as inexpensively as possible. One of many inexpensive approaches is “don’t install dependencies that are new.” Along with “don’t install dependencies that nobody else uses.” You might also apply the rule, “don’t install dependencies that aren't shipped with the OS.” Or “don’t use dependencies that haven’t been formally proven.” Etc.
Indeed, calling it “Safe-NPM” can be misleading. As if using it achieves some binary state of safety.
femiagbabiaka|3 months ago
PunchyHamster|3 months ago
unknown|3 months ago
[deleted]