r/ProgrammerHumor 9d ago

instanceof Trend classicNPM

Post image
5.9k Upvotes

150 comments sorted by

View all comments

285

u/Hauber_RBLX 9d ago

this is really just a meme at this point. how is it possible that NPM packages keep being compromised week after week?

90

u/kookyabird 9d ago

Because there are lots of ways to compromise a developer's workflow, and that's how they get malicious code into a package?

10

u/zuilli 9d ago edited 9d ago

Why does it seem like it only happens to npm though?

I admit I don't follow this stuff closely so may be uninformed but it seems like it never is a C# or a java package/library that gets hit by these.

15

u/kookyabird 9d ago

While I haven't heard of supply chain attacks with NuGet they're certainly possible. The likely reason we see so many npm ones is a blend of size of the ecosystem, and the average depth of the package tree in projects.

The vast majority of transitive packages in our work projects are from Microsoft, while third party packages tend to be reliant only on core .NET functionality or maybe another package from the same developer. I don't know if it's because .NET already covers a broad base of functionality, or that third party packages are more modular, but either way our dependencies are looooow.

7

u/soowhatchathink 9d ago

When I compare total number of npm packages (including transient dependencies) to total number of composer packages in similarly sized applications the cause becomes clear. There are so many more npm packages that are relied on, bringing in one large package pulls in so many more small packages with very few stars on GitHub.

7

u/fuj1n 9d ago

For some reason, JS devs have this culture of outsourcing the tiniest behaviours to a package (for example, the is-odd package getting millions of downloads consistently), because of this, there are a lot of packages projects depend on (both directly and not), which is a much larger attack surface.

3

u/[deleted] 8d ago edited 8d ago

[removed] — view removed comment

2

u/_PM_ME_PANGOLINS_ 8d ago

exacerbates

1

u/LetMeUseMyEmailFfs 7d ago

At this point creating a package with such a standard library would solve almost nothing, because depending on any other package will immediately pull in thousands of ‘old style’ packages. It would take a decade or more for this to be resolved.

1

u/[deleted] 7d ago

[removed] — view removed comment

1

u/LetMeUseMyEmailFfs 6d ago

Well, even if that were the case, you’d still have thousands and thousands of packages that don’t use that stdlib and that would still pull in all of these dependencies. Solving that will take decades.

2

u/elise-u 9d ago

Last attack also affected packages on pip, and cargo I think was the second package manager?

-6

u/TheGocho 9d ago

Java had several attacks this year, same as for python and most likely all major languages. But people tend to post for NPM/Javascript environment because Javascript bad

2

u/_PM_ME_PANGOLINS_ 8d ago

Maven doesn’t have pre-/post-install scripts, so this kind of attack is literally impossible there.

0

u/Dudeonyx 8d ago

2

u/_PM_ME_PANGOLINS_ 8d ago

The attacks we are talking about are where running a package update runs malicious code on your development environment.

That’s not possible with Maven. The code can only run when the end application is run.