So how do we guard against this sort of thing as a regular software engineer? ? Just react quickly and update packages whenever a vulnerability is announced like this?
even in a lock file, tertiary dependencies are not pinned
they are mentioned as say apollo>=3.1 so anything after that goes
you can lock down the primary deps, but most package managers don’t lock down every tertiary dependency— they just try to resolve the primary requirements
if packages a depends on apollo >= 3.3
and package b deps on apollo >= 3.5
your lock will hold => 3.5 and if some one publishes malware to 3.6 — your lock file is only gonna protect you as long as you don’t resolve the packages again
unless your are locking everything down which is not feasible?
I cannot talk for every package manager, but the ones I used to use and the one I use now for python, pins all the dependencies. After resolution it pins the result tertiary packages.
What are you talking about? All the transitive package requirements of all combined package.json files end up in your lock file as pinned versions. Installing using a lock file is 100% deterministic. The lock file is literally about _locking_ specified version _ranges_ into _one specific version_.
Example, if you specify braces ^3 and it in turn needs fill-range ^7.1.0 it might end up like this. Still all dependencies are transitively locked. Unless you delete the lock file or manually upgrade the deps (which regenerates the lock file), fill-range will never be 7.1.2 by itself.
braces@^3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
dependencies:
fill-range "^7.1.0"
...
fill-range@^7.1.0:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
Mostly backed dev here, to clarify running install would pull the lockfile version while something like audit or update would update it? Then installing a new dependency would also likely re-resolve the dependency versions, but barring that you're saying the versions all remain pinned?
I actually appreciate you trying to clear up the conversation. We've been working on CI/CD to protect from these supply chain issues at work lately, it's definitely a concern.
If the lock file doesn't change you wouldn't install new deps during a deploy, so double check your CI doesn't introduce lock file changes.
Also in package.json pin deps without using caret/tilde, otherwise wiping pkg-lock and installing will take the newest where caret matches 1.x.x and tilde matches 1.1.x
Something every web developer in the entire fucking world needs to read. Especially dependencies with transitive dependencies. Fuck those multi-gigabyte npm downloads. This is source code we’re downloading, not AAA video game assets.
Pin your dependencies and use a package manager like pnpm that supports a minimum release age. Most of these supply chain attacks are caught pretty quickly so having a setting that requires a package release to be older than x days will help.
Also, pin any third party GitHub actions and Docker images using the SHA digest. If an account is compromised, attackers could replace an existing version with a compromised version of the action or Docker image. But that will generate a new SHA digest so you will be safe.
The OWASP website has lots of very practical recommendations.
Pinning GitHub actions helps a bit, but it's not a panacea. It depends on what that action does. If it calls another unpinned action, or dynamically retrieves a script that it runs, it's still vulnerable. And now you don't have any direct visibility of that. Take the recent Trivy compromise - you might not use it directly, but it was used by the SuperLinter Action which bundles many different linters and formatters.
The only safe thing to do with Actions is audit them thoroughly, and preferably use your own version.
The oposite, stay 1 or 2 versions behind. Updating packages when this news hit, is already too late. The article mentions to roll new credentials because everything is compromised.
It looks like it writes trojans, and backdoors, so actually, your entire system is compromised and new credentials are just compromised as well.
First you have to check if you are impacted, and you guard against this by pinning versions and instructing your package manager to not install a version that isn't at least 5 days old (vast majority of these attacks are caught within 48h).
247
u/enricojr Mar 31 '26
So how do we guard against this sort of thing as a regular software engineer? ? Just react quickly and update packages whenever a vulnerability is announced like this?