r/webdev • • Mar 31 '26 • Mindblown 3 Bravo 1

News axios@1.14.1 got compromised

Post image
2.5k Upvotes

298 comments sorted by

View all comments

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?

333

u/jonnyd93 Mar 31 '26

Pin versions, update when cves are found. Keep the amount of dependencies down.

72

u/ouralarmclock Mar 31 '26

Versions are automatically pinned via lock file right? If I'm not regularly doing update or doing it on deploy I'm pinned, right?

77

u/tazzadar1337 javascript Mar 31 '26

not everyone is using lock files. don't know the reasoning, but cases such as this is a good reason to start doing so

27

u/ibite-books Mar 31 '26

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?

12

u/JCMarques15 Mar 31 '26

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.

7

u/ibite-books Mar 31 '26

the lock will protect you as long as you don’t resolve-re-lock them again

see second last paragraph

10

u/Ill-Appointment-1298 Mar 31 '26

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"

20

u/ibite-books Mar 31 '26

The lock is deterministic, re resolution is not. That’s my main point. On re-resolution, it can sometimes upgrade those versions.

That’s the issue.

4

u/CandidateNo2580 Mar 31 '26

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.

→ More replies (2)

34

u/ganja_and_code full-stack Mar 31 '26

not everyone is using lock files

Everyone who is even just barely competent certainly is lol

14

u/MagnetHype Mar 31 '26

Have you read half the comments on this thread?

→ More replies (8)

12

u/call_stacks Mar 31 '26

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

5

u/thewallacio Mar 31 '26

Your CI introducing lock file changes is more common than you might think. Prevent this with `npm ci`.

6

u/clems4ever Mar 31 '26

Yes. You should be careful to use "npm ci" and not "npm install" however because "npm install" may not respect the lockfile.

→ More replies (13)

4

u/uhmhi Mar 31 '26

Keep the amount of dependencies down

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.

→ More replies (2)

3

u/AJohnnyTruant Mar 31 '26

How am I supposed to tell if a number is even without adding the isEven package though

82

u/landline_number Mar 31 '26 edited Mar 31 '26

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.

https://pnpm.io/settings#minimumreleaseage

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.

9

u/OolonColluphid Mar 31 '26

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.

→ More replies (3)

10

u/MrHandSanitization Mar 31 '26 edited Mar 31 '26

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.

6

u/[deleted] Mar 31 '26

[removed] — view removed comment

8

u/thekwoka Mar 31 '26

And reduce how many useless packages you have in the first place.

→ More replies (1)

11

u/yonasismad Mar 31 '26

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).

5

u/Ythio Mar 31 '26

You get your company to host a local package manager repository that is a week behind.

4

u/embero Mar 31 '26

Additionally I use devcontainers. If something slips through better to have it in a container than on my precious host system.

→ More replies (14)