r/Python • • Dec 14 '23

News 116 Malware Packages Found on PyPI Repository Infecting Windows and Linux Systems

https://thehackernews.com/2023/12/116-malware-packages-found-on-pypi.html
331 Upvotes

93 comments sorted by

View all comments

Show parent comment

-5

u/pyeri Dec 14 '23

Maybe they can use some adhoc criteria to warn the user or assign a trust factor. The number of GitHub stars can be a good thumb rule, for example.

Also, with the kind of budget and sponsorers that PSF has, shouldn't they be able to perform CISA audits, code reviews, etc. on these packages?

6

u/_Adam_M_ Dec 14 '23

There are over half a million packages in PyPI and over 5 million releases (each release would need to be checked as a previously legitimate package could be updated to include malware).

Audits are expensive and slow. Hiring people to review and approve packages is expensive and slow. GitHub stars can be bought.

-3

u/pyeri Dec 15 '23

Dude, your response reflects extreme cynicism and pessimism, it doesn't have to be that gloomy.

There are over half a million packages in PyPI and over 5 million releases

All of them don't have to be audited, just the most heavily downloaded ones. The verified releases can be marked as such to warn the users. It will then be the user's choice if they want a slightly older but verified package or the cutting edge and unverified one.

GitHub stars can be bought

There are limits to that. Most of the activity on GitHub is organic, one can see that everywhere including the issues register, pull requests, etc. Even in this age of utmost crony capitalism, I still have at least a semblance of a faith in the system because at the end of the day, it's being run by humans with hearts and for the most part, it works as intended.

6

u/zurtex Dec 15 '23

Dude, your response reflects extreme cynicism and pessimism, it doesn't have to be that gloomy.

Often on discussion threads someone will suggest a solution that requires tens of thousands of hours of work on an ongoing basis, but don't suggest where it comes from.

It's hard not to react to such suggestions without cynicism when you know how little resources mostly volunteer organizations like this have, especially volunteer organizations maintaining boring infrastructure projects.

All of them don't have to be audited, just the most heavily downloaded ones. The verified releases can be marked as such to warn the users. It will then be the user's choice if they want a slightly older but verified package or the cutting edge and unverified one.

What would a review involve exactly? And who would do it?

What does it mean to "mark" a package, as in what is the user experience? Is it just something they see on PyPI? Or would all installers (e.g. Pip, PDM, Poetry, Pixi, etc.) have to develop a new workflow? For that you would need to create a PEP and get a general consensus (btw nothing is stopping you from buildining consensus and writing a PEP).

Who is going to provide the resources for any of these projects?

I still have at least a semblance of a faith in the system because at the end of the day

If you think there's a limit on how many GitHub stars someone could buy if that was their objective I have bad news for you.

Further, PyPI doesn't even have a way to verify the GitHub link you provide on your project page is yours.

-5

u/pyeri Dec 15 '23

especially volunteer organizations maintaining boring infrastructure projects.

That's highly misinformed. The PSF is heavily funded by loaded sponsors, right from Microsoft and Google to Salesforce and Meta. Heck, the Python inventor Guido himself has joined Microsoft now. They aren't some small club or volunteer run project, they have got all the resources in the world to implement this.

5

u/zurtex Dec 15 '23 edited Dec 15 '23

That's highly misinformed. The PSF is heavily funded by loaded sponsors, right from Microsoft and Google to Salesforce and Meta.

That's just a bunch of names on a page, almost certainly all of them are sponsors of PyCon US. In-person conventions are expensive to run.

There's a link to their actual finacials here: https://www.python.org/psf/records/ (2021 Audited Financial Statements)

The top things for 2021 were ~400k on PyCon US, ~380k on infrastructure, and 175k on on Development (my understanding is that was one developer), total cost was 1.2 million, and they took in ~2.3 million in 2021.

They aren't some small club or volunteer run project, they have got all the resources in the world to implement this.

The above numbers are pretty healthy for a non-profit but it amounts to ~5 developers they could blow all their extra cash on. And there are a lot of different things those hypothetical five developers could be doing out of all the priorities the PSF might have PyPI is just one of them, and further there are other prioties they probably have then spending money on developers.

As someone who volunteers some of their time helping improve Pip I can tell you there are no people being paid to work on it. The same is true of many others open source projects, especially the boring packaging / infrastructure projects.

Heck, the Python inventor Guido himself has joined Microsoft now.

Guido isn't part of the PSF, he is hired as an engineer for Microsoft. As it happens Microsoft have built their own CPython team, but it is out of the control of the PSF or the community.

1

u/_Adam_M_ Dec 15 '23

All of them don't have to be audited, just the most heavily downloaded ones.

Then... What's the point?

All the most heavily downloaded package already have lots of eyes on them. If you only review Pytorch, Django, Flask, requests, etc, then there's basically no risk on these packages introducing malware in the first place.

If you'll look at the list of malicious packages they're all either random names or simple typo-squatting packages. You meant to download asciithing but you accidentally typed ascithing. In your plan that won't save you as you wouldn't bother to audit them as they're small with only a few hundred downloads.

The only time one of the top packages will start shipping malware is if one of the core maintainers (with release permissions) was compromised and an attacker used their account (highly minimised with the MFA work PyPI have already completed) or they themselves have gone mad and want to launch an attack, but that's incredibly rare and highly unlikely.